Combining Atlases Using FSLMaths

Hi Everyone,

Background

I’m using multiple ROIs from a parcelated atlas (Schaefer et al., 2018) to run an analysis. It has 400 parcels but I’m hoping to generate a new atlas excluding any parcels or ROIs that are not in the Default Mode Network (DMN). I don’t want a single mask covering all of the DMN regions, but rather an atlas that clearly delineates between each of the DMN ROIs. I’m using thresholding via fslmaths to eliminate the ROIs that are not part of the DMN. For example:

# Atlas path 
ATLAS=/data/tools/schaefer_parcellations/MNI/
SCRIPTS=/data/project/scripts

# Using fslmaths to exclude any ROI whose index or value is greater than 41
# ROIs 1 through 41 contain DMN-related regions in the left hemisphere
fslmaths ${ATLAS}/Schaefer2018_400Parcels_Kong2022_17Networks_order_FSLMNI152_2mm.nii.gz \
         -uthr 41 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_L_DMN.nii.gz

# DMN-related regions in the right hemisphere correspond to ROI indices 201 through 236.
# As such I'll use thresholding again to generate an atlas containing only those regions 
fslmaths ${ATLAS}/Schaefer2018_400Parcels_Kong2022_17Networks_order_FSLMNI152_2mm.nii.gz \
         -thr 201 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \
         -uthr 236 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

This leaves me with a separate atlas for left and right cortices which I need to recombine. Before I do so, I want to reindex the right hemisphere ROIs to be 42 through 77 rather than 201 through 236. This way, when I combine them the ROIs indices will be 1 through 77. I use the subtract argument for that:

# Reindexing values from the right hemisphere
fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \
         -sub 159 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

This appears to work great. When I view the two separate atlases the left ROI indices range from 1 to 41 and the right indices range from 42 to 77. I then combine the two using the add function:

# Combining the Atlases
fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_L_DMN.nii.gz \
         -add ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_DMN.nii.gz

The Problem:

However, after doing this I’m left with this issue wherein the ROIs in the right cortex remain indexed as 42 through 77 and the ROIs on the left hemisphere are re-indexed as -159 through -118. It seems like after being recombined they somehow redefined their position according to how far away they were from the greatest index. (i.e., Because the highest value index changed from 236 to 77, a change of 159, all left hemisphere ROIs also were reduced by 159).

Am I misunderstanding what the -add, -thr, and -sub arguments are fundamentally doing? Is there perhaps an easier way to do what I’m trying to do? Of course, if any of the code or details above are not reproducing well or are confusing, please let me know. I appreciate the help!

Hi,

One issue is coming from this line:

# Reindexing values from the right hemisphere
fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \
         -sub 159 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

Indeed, it would change your labels ranging from 201 to 236 to labels ranging from 42 to 77. However, the rest of the voxels, whose intensity was set to zero after thresholding, is now at -159!

You just need to add a new line after the command above:

 fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \ 
               -thr 0 \
               ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

and go on with the rest of your script.

Also:

# DMN-related regions in the right hemisphere correspond to ROI indices 201 through 236.
# As such I'll use thresholding again to generate an atlas containing only those regions 
fslmaths ${ATLAS}/Schaefer2018_400Parcels_Kong2022_17Networks_order_FSLMNI152_2mm.nii.gz \
         -thr 201 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \
         -uthr 236 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz

Could just be written in one command:

fslmaths ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz \
         -uthr 236 -thr 201 \
         ${SCRIPTS}/dir_ROIs/Schaefer_400Parcel_R_DMN.nii.gz
1 Like

Oh man, of course! Seems so obvious in retrospect. I spent a couple hours scratching my head over this and reapplying -thr did not occur to me. Thank you so much. I really appreciate it.