External Email - Use Caution        

Okay, here it is. I just want to stress that it's not my script, but the 
amygdala subfield module released by Freesurfer 
(https://surfer.nmr.mgh.harvard.edu/fswiki/HippocampalSubfieldsAndNucleiOfAmygdala).
 I don't have permission to directly edit it, but please let me know if I'm 
misunderstanding your request, or if you'd like further clarification.

Thanks again.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#! /bin/tcsh -f

set tcsh61706 = (`tcsh --version | grep "6\.17\.06"`)
if ("$tcsh61706" != "") then
  echo ""
  echo "WARNING: tcsh v6.17.06 has an exit code bug! Please update tcsh!"
  echo ""
  # workaround to force expected behavior:
  set anyerror
endif

# check MCR installation
checkMCR.sh
if ($status) then
    exit 1
endif


# If no arguments given
if( $#argv == 0 || $#argv > 2) then
  echo " "
  echo "Usage: "
  echo " "
  echo "   segmentHA_T1.sh SUBJECT_ID [SUBJECT_DIR]"
  echo " "
  echo "Or, for help"
  echo " "
  echo "   segmentHA_T1.sh --help"
  echo " "
  exit 1
endif

# If requesting help
if( $1 == "--help") then
  echo " "
  echo "SEGMENTATION OF HIPPOCAMPAL SUBFIELDS AND NUCLEI OF THE AMYGDALA (T1)"
  echo " "
  echo "Use this script to segment the hippocampal subfields and nuclei of the 
amygdala"
  echo "from the main T1 scan used in the recon-all stream. It supports 
standard (1mm)"
  echo "and high resolution T1 scans."
  echo " "
  echo "To use this module, you first need to process the input scan with the 
main "
  echo "FreeSurfer pipeline (recon-all). If you want to analyze high-resolution 
scans"
  echo "(i.e., voxel size smaller than 1mm) at their native resolution, they 
must be"
  echo "processed with the recon-all flag -cm. Then, you can run the following 
command"
  echo "to obtain the segmentation: "
  echo " "
  echo "   segmentHA_T1.sh SUBJECT_ID [SUBJECT_DIR]"
  echo " "
  echo "   (the argument [SUBJECT_DIR] is only necessary if the"
  echo "    environment variable SUBJECTS_DIR has not been set"
  echo "    or if you want to override it)"
  echo " "
  echo "The segmentation method is described in [1], and the atlases are 
described in [1]"
  echo "(hippocampus) and [2] (amygdala):"
  echo " "
  echo "See further information, including how to visualize the results, at:"
  echo " "
  echo 
"https://surfer.nmr.mgh.harvard.edu/fswiki/HippocampalSubfieldsAndNucleiOfAmygdala";
  echo " "
  echo "[1] Iglesias, J.E., Augustinack, J.C., Nguyen, K., Player, C.M., 
Player, A., Wright,"
  echo "M., Roy, N., Frosch, M.P., McKee, A.C., Wald, L.L., Fischl, B., and Van 
Leemput, K.,"
  echo "A computational atlas of the hippocampal formation using ex vivo, 
ultra-high resolution"
  echo "MRI: Application to adaptive segmentation of in vivo MRI.  Neuroimage 
115, 2015, 117-137."
  echo "http://dx.doi.org/10.1016/j.neuroimage.2015.04.042";
  echo " "
  echo "[2] Saygin, Z.M. & Kliemann, D. (joint 1st authors), Iglesias, J.E., 
van der Kouwe, A.J.W.,"
  echo "Boyd, E., Reuter, M., Stevens, A., Van Leemput, K., McKee, A., Frosch, 
M.P., Fischl, B.,"
  echo "and Augustinack, J.C., High-resolution magnetic resonance imaging 
reveals nuclei of the"
  echo "human amygdala: manual segmentation to automatic atlas. Neuroimage 155, 
2017, 370-382."
  echo "http://doi.org/10.1016/j.neuroimage.2017.04.046";
  echo " "
  exit 0
endif

# Error if SUBJECTS_DIR (the environment variable) does not exist
if ($#argv == 1) then
  if (! $?SUBJECTS_DIR)  then
    echo " "
    echo "SUBJECTS_DIR variable does not exist"
    echo "Please define it or provide subjects directory as second input"
    echo " "
    exit 1
  endif
endif

# Error if SUBJECTS_DIR (the environemnt variable) is empty
if ($#argv == 1) then
  if ( $SUBJECTS_DIR == "" ) then
    echo " "
    echo "SUBJECTS_DIR variable is empty"
    echo "Please redefine it or provide subjects directory as second input"
    echo " "
    exit 1
  endif
endif

# If SUBJECTS_DIR is provided, just set it
if ($#argv == 2) then
  set SUBJECTS_DIR = $2
endif

# Set name of subject
set SUBJECTNAME = $1

# Error if subject directory does not exist
if (! -d $SUBJECTS_DIR ) then
  echo " "
  echo "Subjects directory:"
  echo "   $SUBJECTS_DIR"
  echo "does not exist"
  echo " "
  exit 1
endif

# Error if directory of specific subject does not exist
if (! -d $SUBJECTS_DIR/$SUBJECTNAME ) then
  echo " "
  echo "Directory of subject to process:"
  echo "   $SUBJECTS_DIR/$SUBJECTNAME"
  echo "does not exist"
  echo " "
  exit 1
endif

# Error if subject not processed (far enough)
if (! -e ${SUBJECTS_DIR}/${SUBJECTNAME}/mri/wmparc.mgz || \
    ! -e ${SUBJECTS_DIR}/${SUBJECTNAME}/mri/norm.mgz || \
    ! -e ${SUBJECTS_DIR}/${SUBJECTNAME}/mri/transforms/talairach.xfm ) then
  echo " "
  echo "Cannot find wmparc.mgz or norm.mgz or talairach.xfm for the subject."
  echo "Has the subject been procesed with recon-all?"
  echo " "
  exit 1;
endif

# Make sure that the (T1) hippocampal subfields are not running already for 
this subject
set IsRunningFile = 
${SUBJECTS_DIR}/${SUBJECTNAME}/scripts/IsRunningHPsubT1.lh+rh
if(-e $IsRunningFile) then
  echo ""
  echo "It appears that T1 Hippocampal Subfields is already running"
  echo "for this subject based on the presence of IsRunningHPsub.lh+rh"
  echo "It could also be that T1 Hippocampal Subfields was running at one"
  echo "point but died in an unexpected way. If it is the case that there"
  echo "is a process running, you can kill it and start over or"
  echo "just let it run. If the process has died, you should type:"
  echo ""
  echo "rm $IsRunningFile"
  echo ""
  echo "and re-run."
  echo "----------------------------------------------------------"
  cat  $IsRunningFile
  echo "----------------------------------------------------------"
  exit 1;
endif

# If not explicitly specfied, set to 1
if($?ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS == 0) then
  setenv ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS 1
endif

# If everything is in place, let's do it! First, we create the IsRunning file
echo "------------------------------" > $IsRunningFile
echo "SUBJECT $SUBJECTNAME" >> $IsRunningFile
echo "DATE `date`"     >> $IsRunningFile
echo "USER $user"      >> $IsRunningFile
echo "HOST `hostname`" >> $IsRunningFile
echo "PROCESSID $$ "   >> $IsRunningFile
echo "PROCESSOR `uname -m`" >> $IsRunningFile
echo "OS `uname -s`"       >> $IsRunningFile
uname -a         >> $IsRunningFile
if($?PBS_JOBID) then
  echo "pbsjob $PBS_JOBID"  >> $IsRunningFile
endif

# Parameters
set RUNTIME="$FREESURFER_HOME/MCRv84/";
set RESOLUTION="0.333333333333333333333333333333333333";
set ATLASMESH="$FREESURFER_HOME/average/HippoSF/atlas/AtlasMesh.gz";
set ATLASDUMP="$FREESURFER_HOME/average/HippoSF/atlas/AtlasDump.mgz";
set LUT="$FREESURFER_HOME/average/HippoSF/atlas/compressionLookupTable.txt";
set K="0.05";
set OPTIMIZER="L-BFGS";
set MRFCONSTANT="0";
set SUFFIX="v21";

# Now the real job
set hippohemilist=(left right)
set HSFLOG = 
(${SUBJECTS_DIR}/${SUBJECTNAME}/scripts/hippocampal-subfields-T1.log)
rm -f $HSFLOG

echo "------------------------------" > $HSFLOG
echo "USER $user"      >> $HSFLOG
echo "HOST `hostname`" >> $HSFLOG
echo "PROCESSID $$ "   >> $HSFLOG
echo "PROCESSOR `uname -m`" >> $HSFLOG
echo "OS `uname -s`"       >> $HSFLOG
echo "ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS 
$ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS " >> $HSFLOG
uname -a         >> $HSFLOG
if($?PBS_JOBID) then
  echo "pbsjob $PBS_JOBID"  >> $HSFLOG
endif
echo "------------------------------" >> $HSFLOG
echo " " >> $HSFLOG
cat $FREESURFER_HOME/build-stamp.txt  >> $HSFLOG
echo " " >> $HSFLOG
echo "setenv SUBJECTS_DIR $SUBJECTS_DIR"  >> $HSFLOG
echo "cd `pwd`"   >> $HSFLOG
echo $0 $argv  >> $HSFLOG
echo ""  >> $HSFLOG

foreach hemi ($hippohemilist)
  echo "#--------------------------------------------" \
    |& tee -a $HSFLOG
  echo "#@# Hippocampal Subfields processing (T1) $hemi `date`" \
    |& tee -a $HSFLOG

  # command
  set cmd="run_segmentSubjectT1_autoEstimateAlveusML.sh $RUNTIME $SUBJECTNAME 
$SUBJECTS_DIR $RESOLUTION $ATLASMESH $ATLASDUMP $LUT $K $hemi $OPTIMIZER 
$SUFFIX ${FREESURFER_HOME}/bin/ $MRFCONSTANT"

  fs_time ls >& /dev/null
  if ($status) then
    $cmd |& tee -a $HSFLOG
    set returnVal=$status
  else
    fs_time $cmd |& tee -a $HSFLOG
    set returnVal=$status
  endif

  if ($returnVal) then

    uname -a | tee -a $HSFLOG
    echo "" |& tee -a $HSFLOG
    echo "T1 hippocampal subfields exited with ERRORS at `date`" \
    |& tee -a $HSFLOG
    echo "" |& tee -a $HSFLOG
    echo "For more details, see the log file $HSFLOG"
    echo ""
    rm -f $IsRunningFile
    exit 1;
  endif
end

# Convert the txt files into a stats file so that asegstats2table can
# be run Note: the number of voxels is set to 0 and there is no info
# about intensity. The only useful info is the volume in mm and the
# structure name. The segmentation IDs also do not mean anything.
# Could run mri_segstats instead, but the volumes would not include
# partial volume correction.
foreach hemi (lh rh)
  set txt=$SUBJECTS_DIR/$SUBJECTNAME/mri/$hemi.hippoSfVolumes-T1.$SUFFIX.txt
  set 
stats=$SUBJECTS_DIR/$SUBJECTNAME/stats/hipposubfields.$hemi.T1.$SUFFIX.stats
  echo "# Hippocampal subfield volumes as created by segmentHA_T1.sh" > $stats
  cat $txt | awk '{print NR" "NR"  0 "$2" "$1}' >> $stats
  set txt=$SUBJECTS_DIR/$SUBJECTNAME/mri/$hemi.amygNucVolumes-T1.$SUFFIX.txt
  set 
stats=$SUBJECTS_DIR/$SUBJECTNAME/stats/amygdalar-nuclei.$hemi.T1.$SUFFIX.stats
  echo "# Amygdala nuclei volumes as created by segmentHA_T1.sh" > $stats
  cat $txt | awk '{print NR" "NR"  0 "$2" "$1}' >> $stats
end

# All done!
rm -f $IsRunningFile

echo " "
echo "All done!"
echo " "
echo "If you have used results from this software for a publication, please 
cite:"
echo " "
echo "Iglesias, J.E., Augustinack, J.C., Nguyen, K., Player, C.M., Player, A., 
Wright,"
echo "M., Roy, N., Frosch, M.P., McKee, A.C., Wald, L.L., Fischl, B., and Van 
Leemput, K.,"
echo "A computational atlas of the hippocampal formation using ex vivo, 
ultra-high resolution"
echo "MRI: Application to adaptive segmentation of in vivo MRI.  Neuroimage 
115, 2015, 117-137."
echo "http://dx.doi.org/10.1016/j.neuroimage.2015.04.042";
echo " "
echo "In addition, if you have used the segmentation of the nuclei of the 
amygdala, please also cite:"
echo ""
echo "Saygin, Z.M. & Kliemann, D. (joint 1st authors), Iglesias, J.E., van der 
Kouwe, A.J.W.,"
echo "Boyd, E., Reuter, M., Stevens, A., Van Leemput, K., McKee, A., Frosch, 
M.P., Fischl, B.,"
echo "and Augustinack, J.C., High-resolution magnetic resonance imaging reveals 
nuclei of the"
echo "human amygdala: manual segmentation to automatic atlas. Neuroimage 155, 
2017, 370-382."
echo "http://doi.org/10.1016/j.neuroimage.2017.04.046";
echo " "

exit 0

________________________________
From: freesurfer-boun...@nmr.mgh.harvard.edu 
<freesurfer-boun...@nmr.mgh.harvard.edu> on behalf of Rosalia Dacosta Aguayo 
<rdacos...@gmail.com>
Sent: Thursday, October 10, 2019 2:44 PM
To: Freesurfer support list <freesurfer@nmr.mgh.harvard.edu>
Subject: Re: [Freesurfer] Issues with segmentHA_T1.sh command


        External Email - Use Caution

Hi,

Yes, otherwise there is no way to debug the lines in your script.

Best,
Rosalia

El jue., 10 oct. 2019 14:41, Olamide Abiose 
<oabi...@stanford.edu<mailto:oabi...@stanford.edu>> escribió:

        External Email - Use Caution

Hi Rosalia,

I'm running this as a command line argument, because I'm only testing one 
subject. Are you asking for the segmentHA_T1.sh script?
________________________________
From: 
freesurfer-boun...@nmr.mgh.harvard.edu<mailto:freesurfer-boun...@nmr.mgh.harvard.edu>
 
<freesurfer-boun...@nmr.mgh.harvard.edu<mailto:freesurfer-boun...@nmr.mgh.harvard.edu>>
 on behalf of Rosalia Dacosta Aguayo 
<rdacos...@gmail.com<mailto:rdacos...@gmail.com>>
Sent: Thursday, October 10, 2019 2:34 PM
To: Freesurfer support list 
<freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>>
Subject: Re: [Freesurfer] Issues with segmentHA_T1.sh command


        External Email - Use Caution

Hi Olamide,

How to check your line errors without the bash script you are using?
Could you at least send the .sh script?

Best regards,
Rosalia

On Thu, Oct 10, 2019 at 8:29 PM Olamide Abiose 
<oabi...@stanford.edu<mailto:oabi...@stanford.edu>> wrote:

        External Email - Use Caution

Hello,

I'm having great difficulty running the segmentHA_T1.sh command. I'm using the 
latest development version of Freesurfer and have downloaded Matlab R2014b. I 
get the following message when I try to run the command. Any advice/suggestions 
you can offer would be greatly appreciated!

Thank you very much.


#--------------------------------------------
#@# Hippocampal Subfields processing (T1) left Wed Oct  9 17:49:49 PDT 2019
/usr/bin/time -o /dev/stdout
@#@FSTIME 2019:10:09:17:49:49 run_segmentSubjectT1_autoEstimateAlveusML.sh N 13 
e %e S %S U %U P %P M %M F %F R %R W %W c %c w %w I %I O %O L 41.67 41.74 45.01
run_segmentSubjectT1_autoEstimateAlveusML.sh /opt/freesurfer-dev/MCRv84/ PI004 
/mnt/barry/projects/Mormino_TauPET/PI2620/Analysis/Ola_Practice 
0.333333333333333333333333333333333333 
/opt/freesurfer-dev/average/HippoSF/atlas/AtlasMesh.gz 
/opt/freesurfer-dev/average/HippoSF/atlas/AtlasDump.mgz 
/opt/freesurfer-dev/average/HippoSF/atlas/compressionLookupTable.txt 0.05 left 
L-BFGS v21 /opt/freesurfer-dev/bin/ 0
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is 
.:/usr/lib/x86_64-linux-gnu:/opt/freesurfer-dev/MCRv84//runtime/glnxa64:/opt/freesurfer-dev/MCRv84//bin/glnxa64:/opt/freesurfer-dev/MCRv84//sys/os/glnxa64:/native_threads:/server:/client::
Error using checkRequiredMCRProducts (line 25)
Java exception occurred:
java.lang.NullPointerException
        at 
com.mathworks.install.InstalledProductFactory$1.execute(InstalledProductFactory.java:56)
        at 
com.mathworks.install.InstalledProductFactory$1.execute(InstalledProductFactory.java:49)
        at 
com.mathworks.install.InstalledProductFactory$InstallerWorkSpace.executeTask(InstalledProductFactory.java:193)
        at 
com.mathworks.install.InstalledProductFactory$InstallerWorkSpace.access$200(InstalledProductFactory.java:108)
        at 
com.mathworks.install.InstalledProductFactory.getInstalledProducts(InstalledProductFactory.java:67)

Error in deployrc (line 9)

Error in matlabrc (line 238)


Command exited with non-zero status 255
@#@FSTIME  2019:10:09:17:49:49 run_segmentSubjectT1_autoEstimateAlveusML.sh N 
13 e 26.55 S 0.33 U 5.00 P 20% M 235704 F 0 R 45707 W 0 c 211 w 2331 I 0 O 
84096 L 41.67 41.74 45.01
@#@FSLOADPOST 2019:10:09:17:50:15 run_segmentSubjectT1_autoEstimateAlveusML.sh 
N 13 41.42 41.68 44.90
Linux gene 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC 2019 
x86_64 x86_64 x86_64 GNU/Linux

T1 hippocampal subfields exited with ERRORS at Wed Oct  9 17:50:15 PDT 2019

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

Reply via email to