pegasus-isi / freesurfer-osg-workflow

A Pegasus workflow for running FreeSurfer on the Open Science Grid
2 stars 3 forks source link

How to specify path for t2? #6

Open soichih opened 4 years ago

soichih commented 4 years ago

I am trying to figure out how to set -hippocampal-subfields-T1T2 option for autorecon-options in run.yml. This option requires path to the T2 file if specified.

Currently, I have the following script to customize the command line option based on user input.

cmd="-i $t1 -subject output -all -parallel -openmp $OMP_NUM_THREADS"
if [ -f $t2 ]; then
    cmd="$cmd -T2 $t2 -T2pial"
    #https://surfer.nmr.mgh.harvard.edu/fswiki/HippocampalSubfields
    #https://surfer.nmr.mgh.harvard.edu/fswiki/HippocampalSubfieldsAndNucleiOfAmygdala
    if [ $hippocampal == "true" ]; then
        cmd="$cmd -hippocampal-subfields-T1T2 $t2 t1t2"
    fi
else
    if [ $hippocampal == "true" ]; then
        cmd="$cmd -hippocampal-subfields-T1"
    fi
fi

Since I can't just use the local path for T2 in autorecon-options (right?) I am not sure how to go about specifying this option. Is it possible to set this option?

soichih commented 4 years ago

By the way, I have something like this in the run.yml

subject:
    input: ../5ea9b9004623da2e63eddf98/5e73d1040b1be19b0f341eec/t1.nii.gz
    T2: ../5ea9b9004623da2e63eddf98/5e73d1040b1be19b0f341eec/t2.nii.gz
    autorecon-options: -notal-check -cw256

I just don't know how to specify -hippocampal-subfields-T1T2 option for the autorecon-options.

soichih commented 4 years ago

Actually, I just learned that hippocampal-subfields options are replaced by completely separate scripts that I have to run after recon-all is completed (for freesurfer v7)

segmentHA_T1.sh  (if user only has t1)
segmentHA_T2.sh  (if user has both t1 and t2)

Is it possible to add a step after recon-all to run one of these commands? I think this actually make it easier to handle hoppocampal-subfields option as I don't have to worry about T2 path anymore.

rynge commented 4 years ago

Sure - how would you like to specify that option? How about:

subject:
    input: ../5ea9b9004623da2e63eddf98/5e73d1040b1be19b0f341eec/t1.nii.gz
    T2: ../5ea9b9004623da2e63eddf98/5e73d1040b1be19b0f341eec/t2.nii.gz
    autorecon-options: -notal-check -cw256
    hippocampal-subfields: True
soichih commented 4 years ago

Yes, something like that would work nicely!

Here is a bit more information about the usage of these scripts

https://surfer.nmr.mgh.harvard.edu/fswiki/HippocampalSubfieldsAndNucleiOfAmygdala

For segmentHA_T1.sh, I think it's pretty straightforward. For segmentHA_T2.sh, it takes a few extra options.

$ segmentHA_T2.sh  bert  FILE_ADDITIONAL_SCAN   ANALYSIS_ID  USE_T1  [SUBJECTS_DIR]

FILE_ADDITIONAL_SCAN is the additional scan to use in the segmentation, in Nifty (.nii/.nii.gz) or FreeSurfer format (.mgh/.mgz). ANALAYSIS_ID is a user defined identifier that makes it possible to run different analysis with different types of additional scans. For example, you can run the command with a T2-weighted volume and use the identifier "T2", and then run it again with a PD-weighted volume and use the identifier "PD", such that both results will coexist in the subject's mri directory (see naming convention for the generated output below). For a certain modality of additional scan, make sure that you use the same ID for all the subjects within a study. Also please note that it is not possible to run two instances of segmentHA_T2.sh in parallel (one with USE_T1=0 and another with USE_T1=1) on the same subject with the same additional scan (segmentHA_T1.sh or segmentHA_T2 with a different additional scan are fine). USE_T1 is a flag that indicates whether the intensities of the main T1 scan should be used (multispectral segmentation). The words USE_T1 must be replaced with a 0 or 1 on the command line. SUBJECTS_DIR is optional, and overrides the FreeSurfer subject directory when provided.

I think ANALYSIS_ID can set it to any ID (or you can make it configurable?) I think USE_T1 should always be "1".. but I am not sure if someone actually just want to use T2 only.

Also, these scripts uses MATLAB runtime, so you will need to have MATLAB runtime installed inside the container for it to work. I have something like this in my Docker container for freesurfer.

RUN cd /usr/local/freesurfer && curl "https://surfer.nmr.mgh.harvard.edu/fswiki/MatlabRuntime?action=AttachFile&do=get&target=runtime2014bLinux.tar.gz" -o "runtime2014b.tar.gz" && tar xvf runtime2014b.tar.gz && rm runtime2014b.tar.gz