Skip to content

Commit

Permalink
vlrmerge. #NF. Added ability to merge CVS volumes and fsaverage surfa…
Browse files Browse the repository at this point in the history
…ces.
  • Loading branch information
Douglas Greve committed Nov 29, 2021
1 parent 8352175 commit 83582e0
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions fsfast/bin/vlrmerge
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set lrvol = ();
set subcortmask = ();
set DoCorrection = 0; # Correction for multiple comparsisons
set subject = fsaverage
set DoFSA2CVS = 0;

set tmpdir = ();
set cleanup = 1;
Expand Down Expand Up @@ -67,16 +68,39 @@ echo $VERSION | tee -a $LF
cat $FREESURFER_HOME/build-stamp.txt | tee -a $LF
uname -a | tee -a $LF

set cvstemplate = $FREESURFER/subjects/cvs_avg35_inMNI152/mri.2mm/orig.mgz
set cvslta = $FREESURFER/subjects/cvs_avg35_inMNI152/mri.2mm/register.lta

if($DoFSA2CVS) then
# Map surfaces to fsaverage to cvs
foreach hemi (lh rh)
set cvssurf = $tmpdir/input.cvs.$hemi.mgh
if($hemi == lh) set insurf = $lhsurf
if($hemi == rh) set insurf = $rhsurf
set cmd = (mris_apply_reg --src $insurf --trg $cvssurf \
--streg $FREESURFER/subjects/fsaverage/surf/$hemi.sphere.reg \
$FREESURFER/subjects/cvs_avg35_inMNI152/surf/$hemi.sphere.reg)
echo $cmd | tee -a $LF
$cmd | tee -a $LF
if($status) exit 1;
if($hemi == lh) set lhsurf = $cvssurf
if($hemi == rh) set rhsurf = $cvssurf
end
endif

# 1. Map the lh and rh into the volume
set surfvol = $tmpdir/junk.mgh
set cmd = (mri_surf2vol --fstal 2 \
--template $SUBJECTS_DIR/$subject/mri.2mm/orig.mgz \
set cmd = (mri_surf2vol --template $SUBJECTS_DIR/$subject/mri.2mm/orig.mgz \
--hemi lh --surfval $lhsurf --o $surfvol --fillribbon)
if($subject == fsaverage) set cmd = ($cmd --fstal 2)
if($subject == cvs_avg35_inMNI152) set cmd = ($cmd --template $cvstemplate --reg $cvslta)
echo $cmd | tee -a $LF
$cmd | tee -a $LF
if($status) exit 1;
set cmd = (mri_surf2vol --fstal 2 --merge $surfvol \
set cmd = (mri_surf2vol --merge $surfvol \
--hemi rh --surfval $rhsurf --o $surfvol --fillribbon)
if($subject == fsaverage) set cmd = ($cmd --fstal 2)
if($subject == cvs_avg35_inMNI152) set cmd = ($cmd --template $cvstemplate --reg $cvslta)
echo $cmd | tee -a $LF
$cmd | tee -a $LF
if($status) exit 1;
Expand Down Expand Up @@ -154,6 +178,16 @@ while( $#argv != 0 )
set subject = $argv[1]; shift;
breaksw

case "--cvs":
set subject = cvs_avg35_inMNI152
set DoFSA2CVS = 1;
breaksw

case "--cvs-no-fsa2cvs":
set subject = cvs_avg35_inMNI152
set DoFSA2CVS = 0;
breaksw

case "--lh":
if($#argv < 1) goto arg1err;
set lhsurf = $argv[1]; shift;
Expand Down Expand Up @@ -260,7 +294,7 @@ if($#outvol == 0) then
exit 1;
endif
if($#subcortmask == 0) then
echo "ERROR: must specify a subcortical mask "
echo "ERROR: must specify a subcortical mask with --subcortmask"
exit 1;
endif

Expand Down Expand Up @@ -288,7 +322,9 @@ usage_exit:
echo " --rh rhsurf"
echo " --subcortmask mask (--scm)"
echo " --correct : bonferroni correct across 3 spaces"
echo " "
echo " --s subject : default is fsaverage"
echo " --cvs : set subject to cvs_avg35_inMNI152 (ie, volume is in cvs, not fsaverage, space)"
echo " --cvs-no-fsa2cvs : set subject to cvs_avg35_inMNI152 and assume that suraces are in CVS surf space"
echo " --lrvol lrvol : output a volume with only lh and rh"
echo ""
echo " --help"
Expand All @@ -310,7 +346,13 @@ left hemisphere, and right hemisphere, and group analysis results are
produced in each space. This program allows these maps to be merged
into a single volume using the surface-based analysis for the cortex
and volume-based analysis for subcortical. This can allow you to look
at all results inside the volume.
at all results inside the volume. By default, it is assumed that the
surface and volume maps are in fsaverage space. If the volume maps are
in CVS space (cvs_avg35_inMNI152) and the surface maps are in
fsaverage space, then add --cvs; in this case, it will convert the
maps from fsaverage to CVS surface space. If both the volume and
surface maps are in CVS space, then use --cvs --no-fsa2cvs (Note:
--no-fsa2cvs must be put AFTER --cvs).

The usage would be something like:
1. Create and run FSFAST analysis in each space
Expand All @@ -324,7 +366,7 @@ vlrmerge --o vlr.nii.gz \
--subcortmask analysis.mni305/subcort.mask.nii.gz

View with
tkmedit fsaverage orig.mgz -aparc+aseg -ov vlr.mgh
tkmeditfv fsaverage orig.mgz -aparc+aseg -ov vlr.mgh

If you do corrections for multiple comparisons for each space, you
can combine the cluster-corrected images into the volume and
Expand Down

0 comments on commit 83582e0

Please sign in to comment.