Running multiple ROIs via probtrackx2

I am trying to run a set of ROI’s on the same subject via FSL probtrackx2, and want each ROI to be run independently. Initially I had my datagrabber (below), match mniROIs=‘addlInfo/subjContainer/%s/DTI_ROIs/Human_Left_Hippocampus.nii.gz’ so that the mniROI only returned a single file. I changed it to return to a wildcard, so it returns a list of all files in the DTI_ROIs subdirectory (and the output looks correct in the _report.rst below…)

In my workflow, I initially just connected the single ROI to the “seed” input for pbx2.

runpbx2.connect( datasource,‘mniROIs’, pbx2, ‘seed’)

After changing to a wildcard, I added an iterfield (i.e. seed)

pbx2 = pe.Node(interface=fsl.ProbTrackX2(), name=‘pbx2’, iterfield=[‘seed’])

But the workflow keeps creating a “seeds.txt” file which is a text file containing all of the ROIs. I feel like I am missing something obvious, but I’m not exactly sure what.

Long story short, I want to run a set of X ROI’s from a datagrabber node independently through probtrackx2.

Any pointers or examples on how to do that? I must just be screwing up the syntax somewhere.


Setup for DataGrabber inputs needed for probtrackx2


datasource = pe.Node(interface=nio.DataGrabber(infields=[‘subject_id’],

create a node to obtain the functional images

datasource.inputs.base_directory = “/data/HCP_BedpostData/”
datasource.inputs.template =’
datasource.inputs.sort_filelist = True
datasource.inputs.field_template = dict(

datasource.inputs.template_args = dict(
thsamples = [[‘subject_id’,‘th1samples’]],
phsamples = [[‘subject_id’,‘ph1samples’]],
fsamples = [[‘subject_id’,‘f1samples’]],
nodif_brain_mask = [[‘subject_id’,‘nodif_brain_mask’]],
xfm = [[‘subject_id’,‘acpc_dc2standard’]],
invxfm = [[‘subject_id’, ‘standard2acpc_dc’]],
mniROIs = [[‘subject_id’]]

  • fsamples : /data/HCP_BedpostData/100206/T1w/Diffusion.bedpostX/merged_f1samples.nii.gz
  • invxfm :
  • mniROIs : [’/data/HCP_BedpostData/100206/DTI_ROIs/Human_BasalForebrain_Bilat_wimt.nii.gz’, ‘/data/HCP_BedpostData/100206/DTI_ROIs/Human_Hippocampus_Left_wimt.nii.gz’, ']
  • nodif_brain_mask : /data/HCP_BedpostData/100206/T1w/Diffusion.bedpostX/nodif_brain_mask.nii.gz
  • phsamples : /data/HCP_BedpostData/100206/T1w/Diffusion.bedpostX/merged_ph1samples.nii.gz
  • thsamples : /data/HCP_BedpostData/100206/T1w/Diffusion.bedpostX/merged_th1samples.nii.gz
  • xfm :

You might want to look at the shell script or the Matlab function doDtiTractSub(). Both assume a region of interest map that has been resliced to the native space of the DWI data (make sure to use nearest neighbor interpolation: a partial volume voxel with portions of region 17 and 19 should not be interpolated as label 18). The Matlab function will use the GPU if available, which is a good idea for these applications. While complex (and tuned for stroke applications), the full pipeline will generate connectomes that can be analyzed with NiiStat (either GLM or machine learning).

Thanks Chris-- I’ll check out that script/workflow.

I realized when I specified the iterfield=[‘seed’] I also needed to wrap the pbx2 command as a MapNode instead of a Node.

Now it’s running each ROI separately… I just need to figure out the naming convention for each of the mapNode outputs which are just named numerically for now.

Thanks again