def run_subject_glm(jobfile, protocol, subject, session=None, smooth=None, lowres=False): """ Create jobfile and run it """ if protocol == 'preferences' and subject in ['sub-11']: jobfile = 'ini_files/IBC_preproc_preferences_sub-11.ini' output_name = os.path.join( '/tmp', os.path.basename(jobfile)[:-4] + '_%s.ini' % subject) _adapt_jobfile(jobfile, subject, output_name, session) list_subjects_update = generate_glm_input(output_name, smooth, lowres) clean_anatomical_images(IBC) if lowres: mask_img = '../ibc_data/gm_mask_3mm.nii.gz' else: mask_img = '../ibc_data/gm_mask_1_5mm.nii.gz' for subject in list_subjects_update: subject['onset'] = [onset for onset in subject['onset'] if onset is not None] clean_subject(subject) if len(subject['session_id']) > 0: if protocol == 'clips4': first_level(subject, compcorr=True, additional_regressors=RETINO_REG, smooth=smooth, mask_img=mask_img) else: first_level(subject, compcorr=True, smooth=smooth, mask_img=mask_img) fixed_effects_analysis(subject, mask_img=mask_img)
def run_subject_surface_glm(jobfile, subject, session, protocol, lowres=False): """ Create jobfile and run it """ output_name = os.path.join( '/tmp', os.path.basename(jobfile)[:-4] + '_%s.ini' % subject) _adapt_jobfile(jobfile, subject, output_name, session) list_subjects_update = generate_glm_input(output_name, lowres) clean_anatomical_images(IBC) for subject in list_subjects_update: clean_subject(subject) if len(subject['session_id']) > 0: print(len(subject['session_id'])) if len(subject['session_id']) > 0: #if protocol == 'retino': # first_level(subject, compcorr=True, # additional_regressors=RETINO_REG, # smooth=None, surface=True) #else: first_level(subject, compcorr=True, smooth=None, surface=True) fixed_effects_analysis(subject, surface=True, lowres=True)
for subject, session in subject_session) subject_data = subject_data + subject_data_[0] list_subject_update = [] list_files_parameter = [] for dict_subject in subject_data: dict_subject = dict_subject.__dict__ update_dict_subject_data = { k: v for (k, v) in dict_subject.items() if v.__class__.__module__ == 'builtins'} update_dict_subject_data.pop('nipype_results') list_subject_update.append(update_dict_subject_data) # FileName for the dumped dictionnary from the preproc json_file_name = 'subjects_data.json' json_file = open(json_file_name, "w") json.dump(list_subject_update, json_file) json_file.flush() # resampling toward pre-defined shape resample_func_and_anat() # Load the dump data list_subjects_update = json.load(open(json_file_name)) for subject in list_subjects_update: subject = clean_subject(subject) print(subject['subject_id'], subject['onset']) if len(subject['session_id']) > 0: first_level(subject, compcorr=True) fixed_effects_analysis(subject)