#
# dmrirc.long.example
#
# This example sets up a TRACULA analysis for a longitudinal study where
# there is a single diffusion scan per visit. 
# - If you have multiple diffusion scans per session, see *.multiscan.*example
# - If you have only one cross-sectional scan per subject, see dmrirc.example
#
# This file contains commands that will be run by trac-all before an analysis.
# It is used to set all parameters needed for the analysis.
#
# Remove a parameter from your dmrirc file if you want use the default value.
# Parameters that don't have default values must be specified.
#
# Any other commands that you might want to run before an analysis can be added
# to this file.
#
# Original Author: Anastasia Yendiki
#
# 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
#
#

# FreeSurfer SUBJECTS_DIR
# T1 images and FreeSurfer segmentations are expected to be found here
# 
setenv SUBJECTS_DIR /gpfs/home/ekaplan7/data/ekaplan7

# Output directory where trac-all results will be saved
# Default: Same as SUBJECTS_DIR
#
##set dtroot = /path/to/tracts/of/ducks

# Subject IDs (one per time point per subject)
#
set subjlist = ( AG007_0425_T1_LAZAR \
                 AG007_0425_T2_LAZAR \
                 AG008_1007_T1_LAZAR \
                 AG008_1007_T2_LAZAR\
                 AG009_1802_T1_LAZAR \
                 AG009_1802_T2_LAZAR )

# Longitudinal base template subject IDs (one for each time point above)
#
set baselist = ( AG007_0425 \
                 AG007_0425 \
                 AG008_1007 \
                 AG008_1007 \
                 AG009_1802 \
                 AG009_1802 )

# In case you want to analyze only Huey and Louie
# Default: Run analysis on all time points and subjects
#
#set runlist = (1 2 5 6)

# Input diffusion DICOMs (file names relative to dcmroot)
# If original DICOMs don't exist, these can be in other image format
# but then the gradient table and b-value table must be specified (see below)
#
set dcmroot = /gpfs/home/ekaplan7/data/ekaplan7
set dcmlist = ( AG007_0425_T1_LAZAR/DTI/dti_two.nii \
                AG007_0425_T2_LAZAR/DTI/dti_two.nii \
                AG008_1007_T1_LAZAR/DTI/dti_two.nii \
                AG008_1007_T2_LAZAR/DTI/dti_two.nii \
                AG009_1802_T1_LAZAR/DTI/dti_two.nii \
                AG009_1802_T2_LAZAR/DTI/dti_two.nii )

# Diffusion gradient tables (file names can be relative to dcmroot)
# Must be specified only if they cannot be read from the DICOM headers
# The tables must have either three columns, where each row is a gradient vector
# or three rows, where each column is a gradient vector
# There must be as many gradient vectors as volumes in the diffusion data set
# Default: Read from DICOM header
#
set bveclist = ( AG007_0425_T1_LAZAR/DTI/dti_two.voxel_space.bvecs \
                 AG007_0425_T1_LAZAR/DTI/dti_two.voxel_space.txt \
                 AG008_1007_T1_LAZAR/DTI/dti_two.voxel_space.txt \
                 AG008_1007_T2_LAZAR/DTI/dti_two.voxel_space.bvecs \
                 AG009_1802_T1_LAZAR/DTI/dti_two.voxel_space.bvecs \
                 AG009_1802_T2_LAZAR/DTI/dti_two.voxel_space.bvecs )

# Diffusion b-value tables (file names can be relative to dcmroot)
# Must be specified only if they cannot be read from the DICOM headers
# There must be as many b-values as volumes in the diffusion data set
# Default: Read from DICOM header
#
set bvallist = ( AG007_0425_T1_LAZAR/DTI/dti_two.bvals \
                 AG007_0425_T1_LAZAR/DTI/dti_two.txt \
                 AG008_1007_T1_LAZAR/DTI/dti_two.txt \
                 AG008_1007_T1_LAZAR/DTI/dti_two.bvals \
                 AG009_1802_T1_LAZAR/DTI/dti_two.bvals \
                 AG009_1802_T1_LAZAR/DTI/dti_two.bvals )

# Perform correction for B0 inhomogeneity distortions?
# 0: No correction (default)
# 1: Perform correction based on a field map
#    Requires additional inputs (see below): b0mlist, b0plist, echospacing, dTE
# 2: Perform correction based on reverse-polarity images
#    Requires additional inputs (see below): echospacing, pedir, epifactor
#
set dob0 = 1

# Input B0 field map magnitude DICOMs (file names can be relative to dcmroot)
# Only used if dob0 = 1
# Default: None
#
set b0mlist = ( AG007_0425_T1_LAZAR/DTI_field/017/dti_field.nii \
                AG007_0425_T2_LAZAR/DTI_field/017/dti_field.nii \
                AG008_1007_T1_LAZAR/DTI_field/023/dti_field.nii \
                AG008_1007_T2_LAZAR/DTI_field/017/dti_field.nii \
                AG009_1802_T1_LAZAR/DTI_field/022/dti_field.nii \
                AG009_1802_T2_LAZAR/DTI_field/017/dti_field.nii  )

# Input B0 field map phase DICOMs (file names can be relative to dcmroot)
# Only used if dob0 = 1
# Default: None
#
set b0plist = ( AG007_0425_T1_LAZAR/DTI_field/018/dti_field.nii \
                AG007_0425_T2_LAZAR/DTI_field/018/dti_field.nii \
                AG008_1007_T1_LAZAR/DTI_field/024/dti_field.nii \
                AG008_1007_T2_LAZAR/DTI_field/018/dti_field.nii \
                AG009_1802_T1_LAZAR/DTI_field/023/dti_field.nii \
                AG009_1802_T2_LAZAR/DTI_field/018/dti_field.nii)

# Field mapping TE difference (this is found in the scanner protocol printout)
# Only used if dob0 = 1
# Default: Read from field mapping phase DICOM
#
set dTE = 4.37

# Echo spacing (this is found in the scanner protocol printout)
# Only used if dob0 = 1 or 2
# Default: None
#
set echospacing = 0.51

# Perform correction for eddy-current distortions?
# 0: No correction
# 1: Perform registration-based correction with eddy_correct
# 2: Perform model-based correction with eddy (default)
#
set doeddy = 2

# Rotate diffusion gradient vectors to match eddy-current compensation?
# Only used if doeddy = 1 or 2
# Default: 1 (yes)
#
set dorotbvecs = 1

# Intra-subject (diffusion-to-T1) registration method
# 1: Affine with a correlation ratio cost
# 2: Affine with a mutual information cost
# 3: Affine with a boundary-based cost (default)
#
set intrareg = 3

# Degrees of freedom for intra-subject registration
# Can be 6 (rigid), 9 (rigid+scaling), or 12 (full affine)
# Default: 6 for infants, 9 otherwise
#
set intradof = 6

# Maximum rotation angle (degrees) for intra-subject registration
# Default: 3 for infants, 90 otherwise
#
set intrarot = 90

# Inter-subject registration method
# 1: Affine T1-to-T1 with a correlation ratio cost
# 2: Affine T1-to-T1 with a mutual information cost
# 3: Affine T1-to-T1 with a robust cost (default for infants)
# 4: Nonlinear T1-to-T1 with CVS
# 5: Nonlinear FA-to-FA with SyN (default)
#
set interreg = 5

# Target brain for inter-subject registration
# Default for affine T1-to-T1: 
#   $FSLDIR/data/standard/MNI152_T1_1mm_brain.nii.gz
# Default for nonlinear T1-to-T1: 
#   $FREESURFER_HOME/subjects/cvs_avg35/
# Default for nonlinear FA-to-FA: 
#   $FREESURFER_HOME/trctrain/hcp/MGH35_HCP_FA_template.nii.gz
#
#set intertrg = /path/to/a/duck/template.nii.gz

# Whole-brain segmentation used to extract the anatomical neighborhood priors
# of the pathways of interest
# Must exist in each subject's FreeSurfer recon directory, under:
#   $SUBJECTS_DIR/$subjid/mri/$segname.mgz
# Default: aparc+aseg
#
set segname = aparc+aseg

# Use the thalamic nuclei segmentation?
# This is highly recommended to use for any pathways that terminate in
# or neighbor the thalamus
# When used, it is merged with the whole-brain segmentation above
# Must exist in each subject's FreeSurfer recon directory, under:
#   $SUBJECTS_DIR/$subjid/mri/ThalamicNuclei.v12.T1.FSvoxelSpace.mgz
# Default: 1 (yes)
#
set usethalnuc = 1

# Use brain mask extracted from T1 image instead of low-b diffusion image?
# Has no effect if there is no T1 data
# Default: 1 (yes)
#
set usemaskanat = 1

# Fractional intensity threshold for BET mask extraction from low-b images
# This mask is used only if usemaskanat = 0
# Default: 0.3
#
set thrbet = 0.5

# Paths to reconstruct
# Default: All paths in $FREESURFER_HOME/trctrain/hcp/pathlist.txt
#
set pathlist = ( lh.uf rh.uf cc.rostrum )

# Number of path control points
# It can be a single number for all paths or a different number for each of the
# paths specified in pathlist (recommended, with more points for longer paths)
# Default: As in $FREESURFER_HOME/trctrain/hcp/pathlist.txt
#
set ncpts = ( 7 7 5 )

# List of training subjects
# This text file lists the locations of training subject directories
# Default: $FREESURFER_HOME/trctrain/hcp/trainlist.txt
#
set trainfile = $FREESURFER_HOME/trctrain/hcp/trainlist.txt

# Number of "sticks" (anisotropic diffusion compartments) in the bedpostx
# ball-and-stick model
# Default: 2
#
set nstick = 2

# Number of MCMC burn-in iterations
# (Path samples drawn initially by MCMC algorithm and discarded)
# Default: 200
#
set nburnin = 200

# Number of MCMC iterations
# (Path samples drawn by MCMC algorithm and used to estimate path distribution)
# Default: 7500
#
set nsample = 7500

# Frequency with which MCMC path samples are retained for path distribution
# Default: 5 (keep every 5th sample)
#
set nkeep = 5

# Reinitialize path reconstruction?
# This is an option of last resort, to be used only if one of the reconstructed
# pathway distributions looks like a single curve. This is a sign that the
# initial guess for the pathway was problematic, perhaps due to poor alignment
# between the individual and the atlas. Setting the reinit parameter to 1 and
# rerunning "trac-all -prior" and "trac-all -path", only for the specific
# subjects and pathways that had this problem, will attempt to reconstruct them
# with a different initial guess.
# Default: 0 (do not reinitialize)
#
set reinit = 0

