import os def create_key(template, outtype=('nii.gz',), annotation_classes=None): if template is None or not template: raise ValueError('Template must be a valid format string') return template, outtype, annotation_classes def infotodict(seqinfo): """Heuristic evaluator for determining which runs belong where allowed template fields - follow python string module: item: index within category subject: participant id seqitem: run number during scanning subindex: sub index within group """ t1w = create_key('CTRL{subject}/anat/CTRL{subject}_T1w') t2w = create_key('CTRL{subject}/anat/CTRL{subject}_acq-tse_T2w') func_task1= create_key('CTRL{subject}/func/CTRL{subject}_task_run-00{item:01d}_bold') func_task2= create_key('CTRL{subject}/func/CTRL{subject}_task_run-00{item:01d}_bold') info = {t1w: [], t2w: [], func_task1: [], func_task2: []} #last_run = len(seqinfo) #for idx, s in enumerate(seqinfo): for s in enumerate(seqinfo): if (s.dim1 == 256) and (s.TR == 2.3): info[t1w] = append(s.series_id) if (s.dim1 == 512) and (s.dim2 == 408): info[t2w] = append(s.series_id) if (s.dim1 == 72) and ('run1' in s.dcm_dir_name): info[func_task1] = append(s.series_id) if (s.dim1 == 72) and ('run2' in s.dcm_dir_name): info[func_task2] = append(s.series_id) return info