You can combine the labels into an annotation (mris_label2annot), then map the annotation to the new subjects, then break the annot back into labels (mri_annotation2label)
On 5/23/2022 11:55 AM, Deck,Benjamin wrote:
External Email - Use Caution
Apologies, my version and distro are below:
FS: freesurfer-linux-ubuntu18_x86_64-7.2.0-20210721-aa8f76b
OS: Windows via WSL-2
Ben
*From:* Deck,Benjamin *Sent:* Thursday, May 19, 2022 4:57 PM *To:* freesurfer@nmr.mgh.harvard.edu *Subject:* Overlapping label files and issue with --ldir in mris_label2annot
Hi there,
Thanks for putting together FS, great software!
I am having trouble running mris_label2annot
Currently I have extracted individually estimated .mgh overlay files from Li 2019 et a., /Performing group-level functional image analyses based on homologous functional regions mapped in individuals,/ software suite in matlab. These individual .mgh files are for every ROI from every one of Yeo 2011’s 17 network parcellation scheme.
I then take the .mgh files and convert them into label files with the following script.
if [[ $# -lt 1 ]]; then
cat <<USAGE
$0 <inDir> <subjects> <SUBJECTS_DIR>
inDir - input directory --path to matchrate folder from li 2019
subjects - list of subjects to run
SUBJECTS_DIR - Freesurfer SUBJECTS_DIR
USAGE
exit 1
fi
# echo inputs
echo "input 1 is ${1}"
echo "input 2 is ${2}"
echo "input 3 is ${3}"
# parse inputs
inDir=$1
subjects=$2
subDir=$3
networks='Net_10 Net_11 Net_12 Net_13 Net_14 Net_15 Net_16 Net_17 Net_18 Net_19
Net_2 Net_3 Net_4 Net_5 Net_6 Net_7 Net_8 Net_9'
export SUBJECTS_DIR=${subDir} # gather the freesurfer subjects directory
# loop over subjects
for sub in ${subjects}; do
for net in ${networks}; do
# extract networks masks
masks=$(find ${inDir}/Indi_Matched_ROIs/${net}/${sub} -iname '*Net_*.mgh')
# extract confidence masks
echo
echo --------------------------------------------
echo -- START: creating .cor files ${sub} --
echo --------------------------------------------
echo
# loop over masks
for mask in ${masks}; do
netMaskName=$(basename ${mask} .mgh) # gather mask name by network number (Yeo 2011)
hemi=$(echo ${mask} | grep -Eo '[lr]h') # designate the hemisphere
# resample to native
mri_surf2surf --srcsubject fsaverage4 \
--srcsurfval ${mask} \
--trgsubject ${sub} \
--trgsurfval ${inDir}/Indi_Matched_ROIs/${net}/${sub}/${netMaskName}.mgh \
--hemi ${hemi} \
--cortex
mri_vol2label --i ${inDir}/Indi_Matched_ROIs/${net}/${sub}/${netMaskName}.mgh \
--id 1 \
--l ${inDir}/Indi_Matched_ROIs/${net}/${sub}/${netMaskName}.label \
--surf ${sub} ${hemi} white
echo
echo --------------------------------------------
echo -- START: creating label files ${sub} --
echo --------------------------------------------
echo
mri_label2label --srclabel ${inDir}/Indi_Matched_ROIs/${net}/${sub}/${netMaskName}.label \
--s ${sub} \
--hemi ${hemi} \
--dilate 2 \
--trglabel ${subDir}/${sub}/label/${sub}_${netMaskName}_dil2.label \
--regmethod surface
done
done
done
After this script runs to completion, I then run mris_label2annot with the following command
mris_label2annot --s sub-DAEK --hemi rh \
--ctab /mnt/c/Users/Ben/Documents/GitHub/parcellationPipeline/li2019_to_dti/yeo2011nodesLUT.txt \
--a yeo2011nodes \
--surf orig \
--maxstatwinner \
--l Net_10_ROIs_1_rh.label --l Net_11_ROIs_1_rh.label --l Net_12_ROIs_1_rh.label --l Net_12_ROIs_2_rh.label \
--l Net_13_ROIs_1_rh.label --l Net_13_ROIs_2_rh.label --l Net_13_ROIs_3_rh.label --l Net_13_ROIs_4_rh.label \
--l Net_14_ROIs_1_rh.label --l Net_14_ROIs_2_rh.label --l Net_14_ROIs_3_rh.label --l Net_14_ROIs_4_rh.label \
--l Net_14_ROIs_5_rh.label --l Net_15_ROIs_1_rh.label --l Net_16_ROIs_1_rh.label --l Net_16_ROIs_2_rh.label \
--l Net_16_ROIs_3_rh.label --l Net_17_ROIs_1_rh.label --l Net_17_ROIs_2_rh.label --l Net_17_ROIs_3_rh.label \
--l Net_17_ROIs_4_rh.label --l Net_18_ROIs_1_rh.label --l Net_18_ROIs_2_rh.label \
--l Net_18_ROIs_3_rh.label --l Net_18_ROIs_4_rh.label --l Net_19_ROIs_1_rh.label --l Net_2_ROIs_1_rh.label \
--l Net_2_ROIs_2_rh.label --l Net_3_ROIs_1_rh.label --l Net_3_ROIs_2_rh.label --l Net_3_ROIs_3_rh.label \
--l Net_4_ROIs_1_rh.label --l Net_5_ROIs_1_rh.label --l Net_5_ROIs_2_rh.label --l Net_6_ROIs_1_rh.label \
--l Net_6_ROIs_2_rh.label --l Net_6_ROIs_3_rh.label --l Net_7_ROIs_1_rh.label --l Net_7_ROIs_2_rh.label \
--l Net_8_ROIs_1_rh.label --l Net_8_ROIs_2_rh.label --l Net_8_ROIs_3_rh.label --l Net_8_ROIs_4_rh.label \
--l Net_8_ROIs_5_rh.label --l Net_8_ROIs_6_rh.label --l Net_9_ROIs_1_rh.label --l Net_9_ROIs_2_rh.label \
--l Net_9_ROIs_2_rh.label --l Net_9_ROIs_3_rh.label --l Net_9_ROIs_4_rh.label --l Net_9_ROIs_5_rh.label \
--l Net_9_ROIs_6_rh.label --l Net_7_ROIs_3_rh.label
However, the label files are overlapping. Is there a way to fix this, perhaps with some thresholding scheme?
Finally, I also noticed that the –ldir argument from mris_label2annot doesn’t seem to be working.
Here is my LUT:
#
#No. Label Name: R G B A
#
0 Unknown 0 0 0 0
1 Net_2_ROIs_1_lh 25 5 25 0
2 Net_2_ROIs_1_rh 25 100 40 0
3 Net_2_ROIs_2_lh 70 130 180 0
4 Net_2_ROIs_2_rh 125 100 160 0
5 Net_3_ROIs_1_lh 196 58 250 0
6 Net_3_ROIs_1_rh 100 25 0 0
7 Net_3_ROIs_2_lh 120 70 50 0
8 Net_3_ROIs_2_rh 220 20 10 0
9 Net_3_ROIs_3_lh 220 20 100 0
10 Net_3_ROIs_3_rh 180 40 120 0
11 Net_4_ROIs_1_lh 122 186 220 0
12 Net_4_ROIs_1_rh 140 20 140 0
13 Net_5_ROIs_1_lh 12 48 255 0
14 Net_5_ROIs_1_rh 20 30 140 0
…………. Etc etc
Thanks,
Ben
Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer