I am trying to perform some analysis about main tracts in the CNS, and I need, for tckgen code, to give a mask for seeds to start and finish (-seed_image). I was hoping to feed the code with a binary mask using the AAL atlas. Is there a way, using FSL, FreeSurfer or MRtrix3 commands, to transform voxels values to 1 in the ROIs that I am interested in, and transform the rest of the voxels to 0? Using fslmaths -roi is a problem, as I can only transform one ROI in particular, and not a bunch of them.
If anyone has an idea, I am willing to listen to it!
If you have the indexes of the AAL regions you want to use in a text file (one index per line), you can loop through them to threshold and binarize to obtain separate ROIs. For example to extract mutiple regions from the AAL atlas:
for i in `list_indices.txt` ; do fslmaths AAL_atlas.nii.gz -thr ${i} -uthr ${i} -bin ROI_${i}.nii.gz ; done
When you have the set of seed regions you can add these together into one image.
(in case the number of regions is variable…)
it’s also possible to do a big OR operation on a list of voxel values using mrcalc and some bash hocus pocus:
# simple example with parcellation indices 1018 and 1020:
mrcalc AAL_atlas.nii.gz 1018 -eq AAL_atlas.nii.gz 1020 -eq -or seed_mask.nii.gz
# for arbitrary number of (at least 2) indices, stored in i:
i=(1018 1019 1020 2018 2019 2020);
mrcalc $(printf 'AAL_atlas.nii.gz %d -eq ' $i[@]) $(printf ' -or%.0s' {1..$((${#i[@]}-1))}) seed_mask.nii.gz
I was assuming the same format as used in @NicDC’s answer, which I expect to be a simple list of numbers, one for each label to be included. These could be one per line, or separated by space – I think both would work. So no, that wouldn’t be similar to a lookup table, which would also contain text labels and other bits & pieces such as RGB components, etc.
Just to clarify: yes, it works both as a one-per-line list (\n list) or as a separated-by-space list (\b list). I tried both and it worked the same way. Just add the label for each ROI and you’ll be good to go.
Hello, I want to ask you a question. Why can you extract ROI directly with AAL map? Have you registered DWI with MNI? How can I register from the atlas to DWI? Thank you very much for explaining
Once you have your subject’s T1 segmented in the atlas you want it to be (in my case, AAL), you can use that T1.nii to transform, interpolating with mrtransform + fslroi + transformations via fslmaths the AAL-T1 into AAL-b0 (DWI format) in order to work with it and the DWI per se. In fact, once you’ve finished with all transformations, you should have only one file: the AAL_b0 for WM of your subjects. With that, you can do whatever you want in further steps.
Hope I helped you with your question! If you have any unresolved point, please let me know.
Another (and perhaps less complex) way to do it is to calculate the (linear or non-linear) transformation of your T1-weighted image in B0 space to the MNI T1-weighted standard template (make sure the AAL atlas is in the same MNI space), and then apply the inverse of this transform to move the AAL atlas into B0 space, using nearest neighbor interpolation. Then you can extract the labels for the tractography.