I have made a simple post-processing workflow for task-fmri with 2 runs. Data has been pre-processed using fmriprep.
The first few steps, are performed on each run separately. So far, files are iterated over using IdentityInterface
and SelectFiles
:
from os.path import joinpath as opj
from nipype.interfaces import io as nio
from nipype.interfaces.utility import Node
# Subjects to process
subject_list = ['01', '02']
# Session to process
session_list = [1, 2]
# Task to process
task_list = ['name']
# Runs to Process
run_list = [1, 2]
# Image space to be processed
space_list = ['MNI152NLin2009cAsym']
infosource = Node(niu.IdentityInterface(fields=["subject_id",
"session",
"task",
"run",
"space"]),
name="infosource")
infosource.iterables = [("subject_id", subject_list),
("session", session_list),
("task", task_list),
("run", run_list),
("space", space_list)]
mask_file = opj('sub-{subject_id}', 'ses-{session}', 'func',
'sub-{subject_id}_ses-{session}_task-{task}_run-{run}_space-{space}_desc-brain_mask.nii.gz')
func_file = opj('sub-{subject_id}', 'ses-{session}', 'func',
'sub-{subject_id}_ses-{session}_task-{task}_run-{run}_space-{space}_desc-preproc_bold.nii.gz')
templates = {"mask": mask_file,
"func": func_file}
selectfiles = Node(nio.SelectFiles(templates,
base_directory=bas_dir),
name="selectfiles")
The final step step requires mask
inputs from all runs within a session. How could I join these? (i.e. join only mask
inputs that have varying run
fields, but constant subject_id
, session
, etc. fields)