-
Notifications
You must be signed in to change notification settings - Fork 6
MAGeT Brain Related Masking
This wiki describes the steps to:
- Mask a MAGeT Brain atlas
- Modify a MAGeT Brain atlas to only include certain labels
- Mask a MAGeT Brain output label using bpipe output
I've found this step to be useful for situations where I am seeing large over-segmentation (particularly in striatum labels)
ThresholdImage 3 brain1.mnc otsu1.mnc Otsu 1
mincresample -keep -near -byte -like brain1_labels.mnc otsu1.mnc otsu1mod.mnc
mincmath -2 -mult brain1_labels.mnc otsu1mod.mnc brain1_labels_mod.mnc
Note: Remember that you will have to do this for each label file. Also, remember that the name of your label files needs to be in line with the name of the corresponding brain. So, you would likely not want it to be brain1_labels_mod.mnc and instead to be brain1_labels.mnc (corresponding to brain1.mnc).
I've found this useful for breaking the subcortical atlas into separate structures that are left-right split.
minclookup -discrete -lut_string "1 1; 2 0; 3 0; 4 0; 5 0; 6 0;" brain1_labels.mnc X_brain1_labels.mnc
minclookup -discrete -lut_string "1 0; 2 1; 3 0; 4 0; 5 0; 6 0;" brain1_labels.mnc X_brain1_labels.mnc
minclookup -discrete -lut_string "1 0; 2 0; 3 1; 4 0; 5 0; 6 0;" brain1_labels.mnc X_brain1_labels.mnc
minclookup -discrete -lut_string "1 0; 2 0; 3 0; 4 1; 5 0; 6 0;" brain1_labels.mnc X_brain1_labels.mnc
minclookup -discrete -lut_string "1 0; 2 0; 3 0; 4 0; 5 1; 6 0;" brain1_labels.mnc X_brain1_labels.mnc
minclookup -discrete -lut_string "1 0; 2 0; 3 0; 4 0; 5 0; 6 1;" brain1_labels.mnc X_brain1_labels.mnc
#Remember that you will have to do this for each label file. Also, remember that the name of your label files needs to be in line with the name of the corresponding brain. So, you would likely not want it to be X_brain1_labels.mnc and instead to be brain1_labels.mnc (corresponding to brain1.mnc).
INFILE=$1
VOLDIR=~/scratch/komagino_allants/Mask_Test/preprocessed/bpipe-outputs
VOLSUFFIX=.convert.n4correct.cutneckapplyautocrop.brainvolume.mnc
OUTDIR=~/scratch/komagino_allants/Mask_Test/striatum_left_majority_vote
FILENAME=$(basename $INFILE .convert.n4correct.cutneckapplyautocrop.beastextract_labels.mnc)
echo $FILENAME
# Ensure brain volume and labels have the same dimensions
mincresample -like $INFILE $VOLDIR/${FILENAME}$VOLSUFFIX $OUTDIR/${FILENAME}_resampled.mnc
# Mask
mincmath -2 -mult $INFILE $OUTDIR/${FILENAME}_resampled.mnc $OUTDIR/${FILENAME}_labels.mnc
Note: save the above as a .sh. As an example of how it can be run:
for file in *; do bash ~/scratch/komagino_allants/Mask_Test/mask_apply.sh $file; done