Hi guys,
I’m trying to loop through all folders in a BIDS directory and create a JSON file for each subject and session. These files will be used for fmriprep pre-processing. I’m trying to do glob.glob and write the list to string but getting the [0] index but it only gives me the first element. Could someone help.
Example:
mid_task = sorted(glob.glob(os.path.join(base_path, 'TERBO', 'YT', 'BIDS', f'sub-{subj}', f'ses-{sess}', 'func', '*task-mid*bold.nii.gz')))
Output of above code Example:
['/fs/ess/PCON0341/projects/TERBO/YT/BIDS/sub-YT7056167F/ses-1/func/sub-YT7056167F_ses-1_task-mid_run-01_bold.nii.gz', '/fs/ess/PCON0341/projects/TERBO/YT/BIDS/sub-YT7056167F/ses-1/func/sub-YT7056167F_ses-1_task-mid_run-02_bold.nii.gz']
Looking to get into JSON format:
"mid": {
"func": "/fs/ess/PCON0341/projects/TERBO/YT/BIDS/sub-YT7056167F/ses-1/func/sub-YT7056167F_ses-1_task-mid_run-01_bold.nii.gz",
"/fs/ess/PCON0341/projects/TERBO/YT/BIDS/sub-YT7056167F/ses-1/func/sub-YT7056167F_ses-1_task-mid_run-02_bold.nii.gz"