-
Notifications
You must be signed in to change notification settings - Fork 291
HCP HippUnfold and Post HippUnfold Implementations #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glasserm
wants to merge
15
commits into
master
Choose a base branch
from
hippunfold
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a50375f
*Initial Commit of HippUnfoldHCP and PostHippUnfoldHCP, tested but pr…
glasserm 8d8c3ca
*Add Apptainer/Singularity Cache control
glasserm b279be6
*Make vertex areas specific to the volume space they are located in
glasserm 30356e7
*Combine hipp and dentate in CIFTI files
glasserm 6a3f00b
*Remove matlab hack code
glasserm 10238bf
*Add inner and outer surfaces
glasserm 3d320b7
*Remove absolute paths
glasserm 03a4bc6
*math doesn't require the Var to be used
glasserm 8b1c465
*math allows Var to be used without modification.
glasserm 544d4ba
remove functionalization of single loop body
coalsont 9e5c46f
*Support (depend) on HippUnfold v2.0.0 (not backwards compatible)
glasserm c3dcc39
*Symlink instead of copying T1w and T2w
glasserm 464648e
if HIPPUNFOLDPATH is not set hippunfold will be used, else the contai…
demsarjure c3a93fa
refactor non-container support, fix long line and comment silliness
coalsont f95239a
*Enable setting HippUnfold cache location in the setup script
glasserm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/bin/bash | ||
|
|
||
| get_batch_options() { | ||
| local arguments=("$@") | ||
|
|
||
| command_line_specified_study_folder="" | ||
| command_line_specified_subject="" | ||
| command_line_specified_run_local="FALSE" | ||
|
|
||
| local index=0 | ||
| local numArgs=${#arguments[@]} | ||
| local argument | ||
|
|
||
| while [ ${index} -lt ${numArgs} ]; do | ||
| argument=${arguments[index]} | ||
|
|
||
| case ${argument} in | ||
| --StudyFolder=*) | ||
| command_line_specified_study_folder=${argument#*=} | ||
| index=$(( index + 1 )) | ||
| ;; | ||
| --Subject=*) | ||
| command_line_specified_subject=${argument#*=} | ||
| index=$(( index + 1 )) | ||
| ;; | ||
| --runlocal) | ||
| command_line_specified_run_local="TRUE" | ||
| index=$(( index + 1 )) | ||
| ;; | ||
| *) | ||
| echo "" | ||
| echo "ERROR: Unrecognized Option: ${argument}" | ||
| echo "" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| get_batch_options "$@" | ||
|
|
||
| StudyFolder="${HOME}/projects/Pipelines_ExampleData" #Location of Subject folders (named by SubjectID) | ||
| Subjlist="100307 100610" #Space delimited list of subject IDs | ||
| EnvironmentScript="${HOME}/projects/Pipelines/Examples/Scripts/SetUpHCPPipeline.sh" #Pipeline environment script | ||
|
|
||
| if [ -n "${command_line_specified_study_folder}" ]; then | ||
| StudyFolder="${command_line_specified_study_folder}" | ||
| fi | ||
|
|
||
| if [ -n "${command_line_specified_subject}" ]; then | ||
| Subjlist="${command_line_specified_subject}" | ||
| fi | ||
|
|
||
| #Set up pipeline environment variables and software | ||
| source "$EnvironmentScript" | ||
|
|
||
| # Log the originating call | ||
| echo "$@" | ||
|
|
||
| #NOTE: syntax for QUEUE has changed compared to earlier pipeline releases, | ||
| #DO NOT include "-q " at the beginning | ||
| #default to no queue, implying run local | ||
| QUEUE="" | ||
| #QUEUE="hcp_priority.q" | ||
|
|
||
| ########################################## INPUTS ########################################## | ||
|
|
||
| #Scripts called by this script do assume they run on the outputs of the PostFreeSurfer Pipeline | ||
|
|
||
| ######################################### DO WORK ########################################## | ||
|
|
||
| for Subject in $Subjlist ; do | ||
| echo $Subject | ||
|
|
||
| if [[ "${command_line_specified_run_local}" == "TRUE" || "$QUEUE" == "" ]] ; then | ||
| echo "About to locally run ${HCPPIPEDIR}/HippUnfoldHCP/HippUnfoldHCP.sh" | ||
| queuing_command=("$HCPPIPEDIR"/global/scripts/captureoutput.sh) | ||
| else | ||
| echo "About to use fsl_sub to queue ${HCPPIPEDIR}/HippUnfoldHCP/HippUnfoldHCP.sh" | ||
| queuing_command=("$FSLDIR/bin/fsl_sub" -q "$QUEUE") | ||
| fi | ||
|
|
||
| "${queuing_command[@]}" "$HCPPIPEDIR"/HippUnfoldHCP/HippUnfoldHCP.sh \ | ||
| --study-folder="$StudyFolder" \ | ||
| --subject="$Subject" \ | ||
|
|
||
| # The following lines are used for interactive debugging to set the positional parameters: $1 $2 $3 ... | ||
|
|
||
| echo "set -- --study-folder=$StudyFolder \ | ||
| --subject=$Subject" \ | ||
|
|
||
| echo ". ${EnvironmentScript}" | ||
|
|
||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/bin/bash | ||
|
|
||
| get_batch_options() { | ||
| local arguments=("$@") | ||
|
|
||
| command_line_specified_study_folder="" | ||
| command_line_specified_subject="" | ||
| command_line_specified_run_local="FALSE" | ||
|
|
||
| local index=0 | ||
| local numArgs=${#arguments[@]} | ||
| local argument | ||
|
|
||
| while [ ${index} -lt ${numArgs} ]; do | ||
| argument=${arguments[index]} | ||
|
|
||
| case ${argument} in | ||
| --StudyFolder=*) | ||
| command_line_specified_study_folder=${argument#*=} | ||
| index=$(( index + 1 )) | ||
| ;; | ||
| --Subject=*) | ||
| command_line_specified_subject=${argument#*=} | ||
| index=$(( index + 1 )) | ||
| ;; | ||
| --runlocal) | ||
| command_line_specified_run_local="TRUE" | ||
| index=$(( index + 1 )) | ||
| ;; | ||
| *) | ||
| echo "" | ||
| echo "ERROR: Unrecognized Option: ${argument}" | ||
| echo "" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| get_batch_options "$@" | ||
|
|
||
| StudyFolder="${HOME}/projects/Pipelines_ExampleData" #Location of Subject folders (named by SubjectID) | ||
| Subjlist="100307 100610" #Space delimited list of subject IDs | ||
| EnvironmentScript="${HOME}/projects/Pipelines/Examples/Scripts/SetUpHCPPipeline.sh" #Pipeline environment script | ||
|
|
||
| if [ -n "${command_line_specified_study_folder}" ]; then | ||
| StudyFolder="${command_line_specified_study_folder}" | ||
| fi | ||
|
|
||
| if [ -n "${command_line_specified_subject}" ]; then | ||
| Subjlist="${command_line_specified_subject}" | ||
| fi | ||
|
|
||
| #Set up pipeline environment variables and software | ||
| source "$EnvironmentScript" | ||
|
|
||
| # Log the originating call | ||
| echo "$@" | ||
|
|
||
| #NOTE: syntax for QUEUE has changed compared to earlier pipeline releases, | ||
| #DO NOT include "-q " at the beginning | ||
| #default to no queue, implying run local | ||
| QUEUE="" | ||
| #QUEUE="hcp_priority.q" | ||
|
|
||
| ########################################## INPUTS ########################################## | ||
|
|
||
| #Scripts called by this script do assume they run on the outputs of the PostFreeSurfer Pipeline | ||
|
|
||
| ######################################### DO WORK ########################################## | ||
|
|
||
| for Subject in $Subjlist ; do | ||
| echo $Subject | ||
|
|
||
| if [[ "${command_line_specified_run_local}" == "TRUE" || "$QUEUE" == "" ]] ; then | ||
| echo "About to locally run ${HCPPIPEDIR}/HippUnfoldHCP/PostHippUnfoldHCP.sh" | ||
| queuing_command=("$HCPPIPEDIR"/global/scripts/captureoutput.sh) | ||
| else | ||
| echo "About to use fsl_sub to queue ${HCPPIPEDIR}/HippUnfoldHCP/PostHippUnfoldHCP.sh" | ||
| queuing_command=("$FSLDIR/bin/fsl_sub" -q "$QUEUE") | ||
| fi | ||
|
|
||
| "${queuing_command[@]}" "$HCPPIPEDIR"/HippUnfoldHCP/PostHippUnfoldHCP.sh \ | ||
| --study-folder="$StudyFolder" \ | ||
| --subject="$Subject" \ | ||
|
|
||
| # The following lines are used for interactive debugging to set the positional parameters: $1 $2 $3 ... | ||
|
|
||
| echo "set -- --study-folder=$StudyFolder \ | ||
| --subject=$Subject" \ | ||
|
|
||
| echo ". ${EnvironmentScript}" | ||
|
|
||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| #!/bin/bash | ||
| set -eu | ||
| pipedirguessed=0 | ||
| if [[ "${HCPPIPEDIR:-}" == "" ]] | ||
| then | ||
| # pipedirguessed=1 | ||
| #fix this if the script is more than one level below HCPPIPEDIR | ||
| export HCPPIPEDIR="$(dirname -- "$0")/.." | ||
| fi | ||
|
|
||
| source "$HCPPIPEDIR/global/scripts/newopts.shlib" "$@" | ||
| source "$HCPPIPEDIR/global/scripts/debug.shlib" "$@" | ||
|
|
||
|
|
||
| opts_SetScriptDescription "Make some BIDS structures and run HippUnfold" | ||
|
|
||
| opts_AddMandatory '--study-folder' 'StudyFolder' 'path' "folder containing all subjects" | ||
| opts_AddMandatory '--subject' 'Subject' 'subject ID' "" | ||
|
glasserm marked this conversation as resolved.
|
||
| opts_AddOptional '--hippunfold-dir' 'HippUnfoldDIR' 'path' "location of HippUnfold outputs" | ||
|
|
||
| opts_ParseArguments "$@" | ||
|
|
||
| if ((pipedirguessed)) | ||
| then | ||
| log_Err_Abort "HCPPIPEDIR is not set, you must first source your edited copy of Examples/Scripts/SetUpHCPPipeline.sh" | ||
| fi | ||
|
|
||
| opts_ShowValues | ||
|
|
||
| T1wFolder="$StudyFolder/$Subject/T1w" # input data | ||
|
|
||
| if [ -z ${HippUnfoldDIR} ] ; then | ||
| HippUnfoldDIR="${T1wFolder}/HippUnfold" | ||
| fi | ||
|
|
||
| #Couldn't get non-BIDS to work (wouldn't do anything) | ||
| #HippUnfoldT1wFolder="$HippUnfoldDIR/T1w" | ||
| #HippUnfoldT2wFolder="$HippUnfoldDIR/T2w" | ||
| #HippUnfoldT2wFolder="$HippUnfoldDIR/T1wT2w" | ||
|
|
||
| HippUnfoldT1wFolder="$HippUnfoldDIR/T1w/sub-${Subject}/anat" | ||
| HippUnfoldT2wFolder="$HippUnfoldDIR/T2w/sub-${Subject}/anat" | ||
| HippUnfoldT1wT2wFolder="$HippUnfoldDIR/T1wT2w/sub-${Subject}/anat" | ||
|
|
||
| HippUnfoldT1wFolderOut="$HippUnfoldDIR/T1w_hippunfold" | ||
| HippUnfoldT2wFolderOut="$HippUnfoldDIR/T2w_hippunfold" | ||
| HippUnfoldT1wT2wFolderOut="$HippUnfoldDIR/T1wT2w_hippunfold" | ||
|
|
||
|
|
||
| T1wImage="$T1wFolder/T1w_acpc_dc_restore.nii.gz" | ||
| T2wImage="$T1wFolder/T2w_acpc_dc_restore.nii.gz" | ||
|
|
||
|
|
||
| if [ ! -f "$T1wImage" ]; then | ||
| echo "Error: T1w image not found at $T1wImage" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "$T2wImage" ]; then | ||
| echo "Error: T2w image not found at $T2wImage" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
||
| mkdir -p "$HippUnfoldT1wFolder" "$HippUnfoldT2wFolder" "$HippUnfoldT1wT2wFolder" | ||
|
|
||
| #Couldn't get non-BIDS to work (wouldn't do anything) | ||
| #cp "$T1wImage" "$HippUnfoldT1wFolder/${Subject}_T1w_acpc_dc_restore.nii.gz" | ||
| #cp "$T2wImage" "$HippUnfoldT1wFolder/${Subject}_T2w_acpc_dc_restore.nii.gz" | ||
| #cp "$T1wImage" "$HippUnfoldT2wFolder/${Subject}_T1w_acpc_dc_restore.nii.gz" | ||
| #cp "$T2wImage" "$HippUnfoldT2wFolder/${Subject}_T2w_acpc_dc_restore.nii.gz" | ||
| #cp "$T1wImage" "$HippUnfoldT1wT2wFolder/${Subject}_T1w_acpc_dc_restore.nii.gz" | ||
| #cp "$T2wImage" "$HippUnfoldT1wT2wFolder/${Subject}_T2w_acpc_dc_restore.nii.gz" | ||
|
|
||
| cp "$T1wImage" "$HippUnfoldT1wFolder/sub-${Subject}_T1w.nii.gz" | ||
| cp "$T2wImage" "$HippUnfoldT1wFolder/sub-${Subject}_T2w.nii.gz" | ||
| cp "$T1wImage" "$HippUnfoldT2wFolder/sub-${Subject}_T1w.nii.gz" | ||
| cp "$T2wImage" "$HippUnfoldT2wFolder/sub-${Subject}_T2w.nii.gz" | ||
| cp "$T1wImage" "$HippUnfoldT1wT2wFolder/sub-${Subject}_T1w.nii.gz" | ||
| cp "$T2wImage" "$HippUnfoldT1wT2wFolder/sub-${Subject}_T2w.nii.gz" | ||
|
glasserm marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| log_Msg "Created folder structure under $HippUnfoldDIR and copied T1w and T2w images" | ||
| log_Msg "Starting HippUnfold pipeline for subject: $Subject" | ||
|
|
||
| #Couldn't get non-BIDS to work (wouldn't do anything) #Seriously: don't put a $ here... | ||
| #apptainer run --bind $StudyFolder -e $HIPPUNFOLDPATH $HippUnfoldT1wFolder $HippUnfoldT1wFolder participant --modality T1w --path-T1w $HippUnfoldT1wFolder/{Subject}_T1w_acpc_dc_restore.nii.gz --cores all --force-output --generate_myelin_map | ||
| #apptainer run --bind $StudyFolder -e $HIPPUNFOLDPATH $HippUnfoldT2wFolder $HippUnfoldT2wFolder participant --modality T2w --path-T2w $HippUnfoldT2wFolder/{Subject}_T2w_acpc_dc_restore.nii.gz --cores all --force-output --generate_myelin_map | ||
| #apptainer run --bind $StudyFolder -e $HIPPUNFOLDPATH $HippUnfoldT2wFolder $HippUnfoldT2wFolder participant --modality T2w --path-T2w $HippUnfoldT2wFolder/{Subject}_T2w_acpc_dc_restore.nii.gz --cores all --force-output --generate_myelin_map --force-nnunet-model T1T2w | ||
|
|
||
| log_Msg "Running T1w HippUnfold for subject: $Subject" | ||
| apptainer run --bind $StudyFolder -e $HIPPUNFOLDPATH $HippUnfoldT1wFolder $HippUnfoldT1wFolderOut participant --modality T1w --cores all --force-output --generate_myelin_map --output-density 0p5mm 1mm 2mm | ||
| log_Msg "T1w HippUnfold completed." | ||
| log_Msg "Running T2w HippUnfold for subject: $Subject" | ||
| apptainer run --bind $StudyFolder -e $HIPPUNFOLDPATH $HippUnfoldT2wFolder $HippUnfoldT2wFolderOut participant --modality T2w --cores all --force-output --generate_myelin_map --output-density 0p5mm 1mm 2mm | ||
| log_Msg "T2w HippUnfold completed." | ||
| log_Msg "Running T1wT2w HippUnfold for subject: $Subject" | ||
| apptainer run --bind $StudyFolder -e $HIPPUNFOLDPATH $HippUnfoldT1wT2wFolder $HippUnfoldT1wT2wFolderOut participant --modality T1w --cores all --force-output --generate_myelin_map --output-density 0p5mm 1mm 2mm --force-nnunet-model T1T2w | ||
| log_Msg "T1wT2w HippUnfold completed." | ||
|
glasserm marked this conversation as resolved.
|
||
|
|
||
| log_Msg "HippUnfold pipeline completed successfully for subject: $Subject" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.