subjects_dir = os.path.join(scratch_folder, "fs_subjects_dir") script_dir = proj_folder + "/scripts/" included_subjects = db.get_subjects() # just test with first one! sub_new = [] # for sub in [included_subjects[5]]: if not os.path.isfile(fs_subjects_dir + "%s/%s_t1.nii.gz" % (sub[:4], sub[:4])): # this is an example of getting the DICOM files as a list # sequence_name='t1_mprage_3D_sag' MR_study = db.get_studies(sub, modality="MR") if len(MR_study) > 0: # This is a 2D list with [series_name, series_number] series = db.get_series(sub, MR_study[0], "MR") t1 = series["t1_mpr_sag_weakFS"] t2 = series["t2_tse_sag_HighBW"] # Change this to be more elegant: check whether any item in series # matches sequence_name in_t1 = db.get_files(sub, MR_study[0], "MR", t1) in_t2 = db.get_files(sub, MR_study[0], "MR", t2) subj_fname = sub[:4] sub_new += [sub] convert_t1 = "mri_convert %s %s_t1.nii.gz" % (in_t1[0], subj_fname) print(convert_t1) convert_t2 = "mri_convert %s %s_t2.nii.gz" % (in_t2[0], subj_fname) print(convert_t2)
scratch_folder = os.path.join(proj_folder, 'scratch/maxfiltered_data/') subjects_dir = os.path.join(scratch_folder, 'fs_subjects_dir') script_dir = proj_folder + '/scripts/' included_subjects = db.get_subjects() # just test with first one! included_subjects = included_subjects[-3:] for sub in included_subjects: # this is an example of getting the DICOM files as a list # sequence_name='t1_mprage_3D_sag' MEG_study = db.get_studies(sub, modality='MEG') if len(MEG_study) > 0: # This is a 2D list with [series_name, series_number] series = db.get_series(sub, MEG_study[0], 'MEG') series = series["data"] # only use the "data" series for now. # Change this to be more elegant: check whether any item in series # matches sequence_name in_name = db.get_files(sub, MEG_study[0], 'MEG', series) out_name = "%s_%s_mc_raw_tsss.fif" % (sub[:4], "data") # print(out_name) # if len(in_name) > 1: for j, in_file in enumerate(in_name): if j == 0: out_fname = scratch_folder + out_name else: out_fname = scratch_folder\ + out_name[:-4] + "-%d.fif" % j