I’m aiming to extract the entorhinal cortex area for multiple subjects using Freesurfer.
I used mri_extract_label to do that. but I’m facing a challenge to extract the area for all the subjects in one command. since I have more than 700 subjects.
this is the command that I used to extract the area from one subject.
for subjectfolder in /fefs1/fcit/ezahamalyoubi/freesurfer/subjects/*;
do mri_extract_label $subjectfolder/mri/aparc.DKTatlas+aseg.mgz 1006 2006 \
$subjectfolder/mri/LeftandRightERC.mgz;
done
After doing this process and extract the area for all the subjects. how can I collect all the extracted areas for each subject and save them in one folder?
I am not sure I can help best because I do not know which Freesurfer commands do that, but if you meant just moving the outputs from the previous command, then you can just change the last argument of the code above to put outputs somewhere more central instead of in the $subjectfolder.
sounds great.
so if I want to collect all the areas in CN_Male folder, I could edit the code this way, right?
for subjectfolder in /fefs1/fcit/ezahamalyoubi/freesurfer/subjects/*;
do mri_extract_label $subjectfolder/mri/aparc.DKTatlas+aseg.mgz 1006 2006 \
CN_Male/$subjectfolder/mri/LeftandRightERC.mgz;
$subjectfolder is an absolute path (that is, fully defined, begins with /); $subjectfolder is the same as /fefs1/fcit/ezahamalyoubi/freesurfer/subjects/(ONE_OF_YOUR_SUBJECTS).
I don’t know where CN_Male is on your system, but if you do not specify the path beginning with a /, then it is a relative path, and assumes that CN_Male is a folder that exists in whereever your code terminal is running.
This is the path for CN_Male : /fefs1/fcit/ezahamalyoubi/freesurfer
How can I edit the code so each extracted area will be saved in CN_Male folder with the name of the subject?
pushd /fefs1/fcit/ezahamalyoubi/freesurfer/subjects/;
for subject in *;
do mri_extract_label $subject/mri/aparc.DKTatlas+aseg.mgz 1006 2006 \
/fefs1/fcit/ezahamalyoubi/freesurfer/CN_Male/${subject}_LeftandRightERC.mgz;
done
popd