Example #1
0
    def _run_interface(self, runtime):
        MNI_brain_mask, _ = broccoli.load_nni(self.inputs.MNI_brain_mask_file)
        

        first_level_results = np.array([self.load_first_level_result(subject) for subject in os.listdir(self.inputs.GLM_path)])
        number_of_subjects = first_level_results.shape[3]

        X_GLM = self.load_regressors(number_of_subjects)
        xtx = np.linalg.inv(np.dot(X_GLM.T, X_GLM))
        xtxxt_GLM = xtx.dot(X_GLM.T)

        contrasts = np.array([[1, 0], [1, 0], [1, 0], [1, 0]])
        ctxtxc_GLM = [contrasts[i:i+1].dot(xtx).dot(contrasts[i:i+1].T) for i in range(len(contrasts))]
        
        broccoli.performSecondLevelAnalysis(
            first_level_results, MNI_brain_mask,
            X_GLM, xtxxt_GLM, contrasts, ctxtxc_GLM,
            statistical_test, permutation_matrix, number_of_permutations, inference_mode, cluster_defining_threshold,
            self.inputs.opencl_platform, self.inputs.opencl_device, self.inputs.show_results,
        )
        
        return runtime
Example #2
0
 def load_first_level_result(self, subject):
     print("Loading first level result for subject %s" % subject)
     filename = os.path.join(self.inputs.GLM_PATH, subject, 'model/model001/task001.gfeat/cope1.feat/stats/cope1.nii.gz')
     data, _ = broccoli.load_nni(filename)
     return data