#! /bin/tcsh -f # # talairach2 # # USAGE: talairach2 subjectid # subjectid - name of the subject # mgzflag - if anything is present, then it will assume # that the nu volume is stored as nu.mgz in the mri # directory (ie, the nu dir does not exist and there # is no COR volume). # # originally mri/orig was used for this purpose # The algorithm of mritotal is correlation based and thus # it is better to use the intensity normalized volume, nu. # # # Copyright © 2021 The General Hospital Corporation (Boston, MA) "MGH" # # Terms and conditions for use, reproduction, distribution and contribution # are found in the 'FreeSurfer Software License Agreement' contained # in the file 'LICENSE' found in the FreeSurfer distribution, and here: # # https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense # # Reporting: freesurfer@nmr.mgh.harvard.edu # # ######################################################### set VERSION = 'talairach2 dev'; set MGZ = (); # MNI perl module needs the following setting setenv LANG C # Look for version # set n = `echo $argv | egrep -e --version | wc -l` if($n != 0) then echo $VERSION ## gather version info used by this script mri_convert --version set prog = `which mritotal` strings $prog | grep mritotal.in exit 0; endif if($#argv < 1 || $#argv > 2) then echo "USAGE: talairach2 subjectid " exit 1; endif set subject = $argv[1]; shift; if($#argv != 0) set MGZ = ".mgz" set base = $SUBJECTS_DIR/$subject/mri if(! -e $base) then echo "ERROR cannot find $base" exit 1; endif # model=/homes/nmrnew/home/inverse/local/lib/model/average_305.mnc # dir=`pwd` mkdir -p $base/transforms set transform = $base/transforms/talairach.xfm pushd $base > /dev/null echo "INFO: registering $subject" date echo "--------------------------------------------" set cmd = (mri_convert nu$MGZ nu.mnc) echo $cmd $cmd if($status) then echo "ERROR: mri_convert failed" exit 1; endif if(! -e nu.mnc) then echo "ERROR: cannot find nu.mnc" exit 1; endif echo "--------------------------------------------" set cmd = (mritotal -verbose -debug -clobber \ -modeldir ${MINC_BIN_DIR}/../share/mni_autoreg \ -protocol icbm \ nu.mnc transforms/talairach.xfm) echo $cmd $cmd > ../scripts/mritotal.log set st = $status rm nu.mnc if($st) then echo "ERROR: mritotal failed, see scripts/mritotal.log" exit 1; endif echo "--------------------------------------------" set cmd = (mri_add_xform_to_header $transform $base/orig$MGZ $base/orig$MGZ) echo $cmd $cmd if($status) then echo "ERROR: mri_add_xform_to_header $base/orig$MGZ failed" exit 1; endif echo "--------------------------------------------" set cmd = (mri_add_xform_to_header $transform $base/nu$MGZ $base/nu$MGZ) echo $cmd $cmd if($status) then echo "ERROR: mri_add_xform_to_header $base/nu$MGZ failed" exit 1; endif popd > /dev/null date exit 0