3dRoimaker: similar ROI sizes


I’m trying to create 4 different target masks for tractography. My ROIs differ in size but I would like them to be of (approximately) the same size. Is there a specific option in 3dRoimaker I can use to achieve this?

Many thanks,

Hi, Sandra-

Does that mean that you have a single 3D dataset with 4 ROIs already in it, and you would like to differentially inflate them to be of the same (or at least similar) volume?


Yes, that is exactly what I would like to achieve (and I have already created the single 3D dataset with 4 ROIs)

Hi, Sandra-

Hmm, OK. I don’t know of one single command that can do that. You could inflate them separately/individually, while leaving the other ones there so that nothing overlaps…

Taking a step back, I’m a bit curious about inflating them differentially. Can I ask where the original ROIs come from (anatomical, FMRI, other…)? From purely tractographic considerations, there isn’t really an expectation that the target ROIs are the same size

But if you really want to, theeeeen you could do something like this:


set ivol = start_roi.nii  # your starting volume name-- the 3D dset of ROIs

set opref    = INF

set roi_inds = ( 1 2 3 4 ) # whatever the ROI indices happen to be-- don't have to be consecutive
set infl_val = ( 2 3 1 4 ) # how much to inflate each ROI (matching order of ROI inds)
set Nrois    = $#roi_inds

# initialize 
set basevol = "$ivol" 

foreach ii ( `seq 1 1 $Nrois` )
    # will inflate [i]th ROI each time
    set rrr = ${roi_inds[$ii]}

    # make a list of The Other ROIs-- the ones not inflated in this
    # step. '0' just here for being able to put commas from the start.
    set all_others = "0"  
    foreach jj ( `seq 1 1 $Nrois` )
        if ( $jj != $ii ) then
            set all_others = "${all_others},${roi_inds[$jj]}"

    set ovol   = "${opref}_${ii}"                # inflated ROI this round
    set ovol2  = "${opref}_${ii}_recon.nii.gz"   # infl ROI + The Others

    echo "++ For output dset $ovol, ii=$ii and the others are $all_others"
    3dROIMaker -echo_edu                          \
        -inset "${basevol}<${rrr}>"               \
        -refset "${basevol}<${rrr}>"              \
        -inflate "$infl_val[$ii]"                 \
        -wm_skel DTI/DT_FA+orig.                  \
        -skel_thr 0.2                             \
        -skel_stop                                \
        -csf_skel "${basevol}<${all_others}>"     \
        -mask mask_DWI+orig                       \
        -prefix ${ovol}                          \

    # put back together: the newly inflated ROI and The Others
    3dcalc \
        -a "${basevol}<${all_others}>" \
        -b ${ovol}_GMI.nii.gz          \
        -expr 'a + b'                  \
        -prefix "$ovol2"

    # take the inflated one as the basevol for the next pass
    set basevol = "$ovol2"

echo "++ Done.  Final volume of interest should be:"
echo "   $basevol"

One way to make equal size ROIs is to put spheres around the centers of each. See this link for some ways to create spheres.


Thanks both, those are good ideas to play with. I’m going to try it out!

@ptaylor I sent a private message about my project :slight_smile: