-
Notifications
You must be signed in to change notification settings - Fork 272
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
Structural longitudinal pipelines #295
Merged
Merged
Changes from 85 commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
90e527b
Initial implementation of the Longitudinal FreeSurfer pipeline
demsarjure 1e86a5f
Added extra args for both the Base template preparation and the Long …
demsarjure ff5fadb
Removed final folder relinking as it is already done by recon all.
demsarjure 1ecdcd7
Creation of additional symlinks.
demsarjure d59f81c
Removed the link creation.
demsarjure f1891ba
Fixed template naming.
demsarjure 5670466
Removed a bug in template naming.
demsarjure b8306e0
Additional cleanup of symlinks
demsarjure 0901fcd
The symlink cleanup was too agressive.
demsarjure 1b0617a
Renamed subject-dir into study-folder and template into template-id.
demsarjure ae2ddc0
Fixed the folder organization for longitudinal FS so it matches HCP s…
demsarjure 7886eea
Initial implementation of the Longitudinal FreeSurfer pipeline
demsarjure 834deb0
Added extra args for both the Base template preparation and the Long …
demsarjure 327d86a
Removed final folder relinking as it is already done by recon all.
demsarjure 9e14bba
Creation of additional symlinks.
demsarjure 882d15e
Removed the link creation.
demsarjure a5ac2ac
Fixed template naming.
demsarjure e3d5c4f
Removed a bug in template naming.
demsarjure 465d2c5
Additional cleanup of symlinks
demsarjure bf8ddf3
The symlink cleanup was too agressive.
demsarjure 1b3a8b7
Renamed subject-dir into study-folder and template into template-id.
demsarjure 94d31f4
Fixed the folder organization for longitudinal FS so it matches HCP s…
demsarjure 962f917
Merge branch 'feature/longitudinal_fs' of github.com:Washington-Unive…
demsarjure 7fb7a24
chore: longitudinal FS refactor to new IO
demsarjure 0396247
Fixed an unbound variable issue.
demsarjure b7dfb97
Fixed use of extra recon all args.
demsarjure 06291ef
FIxed extra recon all args parsing.
demsarjure 31812f7
Merge branch 'feature/longitudinal_fs' of github.com:Washington-Unive…
demsarjure a88c059
Fixed a bug with extra args parsing.
demsarjure 20eda9d
+post freesurfer timepoint update script
eddc629
+Changes to correctly apply base template and longitudinal pipelines …
7b4ecf6
+convert the Affine transform from timepoint to template, from
7955af4
+permissions
59d05f4
+experimental script to transform timepoint T1w to template.
1e06dcd
Merge branch 'master' into feature/longitudinal_fs
coalsont 276bac5
+scripts to create HCP average template based on longitudinal Freesur…
5d00c31
+ script to resample acpc_dc space to template space (longitudinal)
15a556a
+PrePostFreesurfer pipeline, initial commit.
3c0a74b
+diagrams documenting PrePostFreesurferPipeline-long
17c1c7d
+completed the first pass of the PrePostFreesurferPipeline-long docum…
mmilch01 1f41415
+alterations per discussion with Matt Glasser 02/27/2024
138bfd8
+ppFS-long.sh work in progress
coalsont a0594cc
edits included with "+added .gitignore which was deleted by the previ…
coalsont 3f0744a
Finished ppFS-long rewrite that:
9131b39
Change separator between input timepoints for consistency
7a45da6
Fix typos/misspelling; tested to work on TP
76508fb
+source libraries before calling log_check
1eed6dd
+change target image from longitudinal (non-existent yet) to cross-se…
ccc4716
Fix the issue with wrong LTA header at the initial transform conversi…
mmilch01 0bdc5a2
+Fix the issue with wrong LTA header at the initial transform convers…
mmilch01 bcea028
Merge branch 'feature/longitudinal_fs' of https://github.com/Washingt…
mmilch01 717ab38
+Fixed misspellings/typos in template processing code, up to registra…
mmilch01 0898ae0
+copy warp jacobians from template to timepoints
6312b72
+copy acpc_dc_restore to acpc_dc
95208d0
PostFreeSurferPipeline.sh:
920cd98
+this version is tested in batch mode up to PostFreesurfer
d7144fb
+Added clarification to longitudinal arguments in PostFreeSurfer
798c3ed
+fix long-l mode conditions
bced737
+inflatescale argument fix to remove 'developer error'
7c9fd62
+properly set IsLongitudinal flag
96541ec
+batch PostFreesurferPipeline batch script for longitudinal mode
2d2f890
Merge remote-tracking branch 'origin/master' into feature/longitudina…
mmilch01 8b59a56
+Have MSMSulc.sh only run in template mode, precluded by surface aver…
mmilch01 38888e6
fix typos
mmilch01 e967a9c
+Two-stage mode for longitudinal timepoint processing, to accomodate …
097d4c5
+added two timepoint stages to run MSMSulc.
85feec4
+typo/syntax fixes for staged longitudinal processing
a6ba6fb
+syntax fixes. This version of longitudinal pipelines is verified to …
a84445e
merge PostFreeSurferPipelineLongPrepBatch code into PostFreeSurferPip…
mmilch01 f717f3b
+Updated documentation diagrams.
f992acb
+Harmonize example batch scripts
8fca79c
1. Timepoint naming in batch files changed to more general scheme
a95002f
1. Updated timepoint naming resolution function to work correctly
907a572
+added legacy --subject synonym to --session
a463491
+Fixes needed to correctly run PreFreeSurferPipeline, FreeSurferPipel…
3db2368
+mostly syntax fixes for calls/parameter names to run the full pipeline.
9963457
NONE option for parallel mode
demsarjure 802c203
+Added 'NONE' parallel mode
7e374fc
+update longitudinal Freesurfer and Post-Freesurfer pipelines and bach
cc355d5
+Renamed 'template', 'template-id' options to 'longitudinal-template'…
d82592e
+fixes for parallel modes
9edf66f
+Fixed variable names in PostFreeSurferPipelineLongLauncher directory…
f4fa563
1. Styling changes suggested by reviewers
717e912
+address current pull request review comments.
7b08242
+Addressing more comments from reviewers.
33371fc
+more reviewer requested changes
mmilch01 fde843a
Missing ; in one of if sentences.
demsarjure 0b152b1
Update PostFreeSurfer/scripts/FreeSurfer2CaretConvertAndRegisterNonli…
mmilch01 fca6e56
+Addressing more reviewer comments
mmilch01 b80fccf
Added a missing ;.
demsarjure 46154cf
Fixed capitalization at several locations: PostFreesurfer -> PostFree…
demsarjure 4b52e2b
Merge branch 'feature/longitudinal_fs' of https://github.com/Washingt…
mmilch01 06e2004
+Fix TimepointProcessing variable name
mmilch01 1f5f73d
+Fix timepoints unbound variable issue
mmilch01 24c9a7b
+An option to specify logfile location in parallel.shlib
e4fd418
+Append FreeSurfer BBR refinement to T2w-T1w transform in the final T…
66f61fc
+addressed reviewer comments
47f474c
+sanity check for mode name in par_addjob_stdin()
31a6842
Set correct default for the starting stage.
fa9a7a2
Path fix.
demsarjure 1c70499
+Fix the bug with incorrectly linked longitudinal Freesurfer folders …
ae32e8c
Merge branch 'feature/longitudinal_fs' of https://github.com/Washingt…
e374d8d
+reverse the previous 'path fix' commit.
f675b43
+link atlas transforms to timepoint xfms directory
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
Empty file.
This file contains 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,147 @@ | ||
#!/bin/bash | ||
|
||
get_usage_and_exit(){ | ||
echo "usage: " | ||
echo "FreeSurferPipelineBatch-long.sh [options]" | ||
echo "options:" | ||
echo " --runlocal run locally [FALSE]" | ||
exit -1 | ||
} | ||
|
||
command_line_specified_run_local=FALSE | ||
while [ -n "$1" ]; do | ||
case "$1" in | ||
--runlocal) shift; command_line_specified_run_local=TRUE ;; | ||
*) shift ;; | ||
esac | ||
done | ||
|
||
################################################################################################# | ||
# General input variables | ||
################################################################################################## | ||
#Location of Subject folders (named by subjectID) | ||
StudyFolder="/my/study/path" | ||
#The list of subject labels, space separated | ||
Subjects=(HCA6002236 HCA6002237 HCA6002238) | ||
#The list of possible visits (aka timepoints, sessions) that each subject may have. Timepoint directories should be named <Subject>_<Visit>. | ||
PossibleVisits=(V1_MR V2_MR V3_MR) | ||
#The list of possible visits that each subject may have. Timepoint (visit) is expected to be named <Subject>_<Visit>. | ||
#Actual visits (timepoints) are determined based on existing directories that match the visit name pattern. | ||
#ExcludeVisits=(HCA6002237_V1_MR HCA6002238_V1_MR) | ||
ExcludeVisits=() | ||
#Longitudinal template labels, one per each subject. | ||
Templates=(HCA6002236_V1_V2 HCA6002237_V1_V2 HCA6002238_V1_V2) | ||
|
||
EnvironmentScript="<HCPInstallDir>/scripts/SetUpHCPPipeline.sh" #Pipeline environment script | ||
|
||
# Requirements for this script | ||
# installed versions of: FSL, FreeSurfer, Connectome Workbench (wb_command), gradunwarp (HCP version) | ||
# environment: HCPPIPEDIR, FSLDIR, FREESURFER_HOME, CARET7DIR, PATH for gradient_unwarp.py | ||
|
||
# If you want to use FreeSurfer 5.3, change the ${queuing_command} line below to use | ||
# ${HCPPIPEDIR}/FreeSurfer/FreeSurferPipeline-v5.3.0-HCP.sh | ||
|
||
#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="long.q" | ||
#QUEUE="hcp_priority.q" | ||
|
||
#parallel options | ||
parallel_mode=BUILTIN | ||
|
||
# This setting is for BUILTIN mode. Set to -1 to auto-detect the # of CPU cores on the node where each per-subject job is run. | ||
# Note that in case when multiple subject jobs are run on the same node and are submitted | ||
# in parallel by e.g. fsl_sub, max_jobs should be set manually to not significantly exceed | ||
# (number of available cores)/(number of subjects) in the batch. | ||
max_jobs=-1 | ||
#max_jobs=4 | ||
|
||
#TEMPLATE stage must be run before TIMEPOINTS stage | ||
start_stage=TEMPLATE | ||
end_stage=TIMEPOINTS | ||
|
||
#Processing goes here. | ||
function identify_timepoints | ||
{ | ||
local subject=$1 | ||
local tplist="" | ||
local tp visit n | ||
|
||
#build the list of timepoints (sessions) | ||
n=0 | ||
for session in ${PossibleVisits[*]}; do | ||
tp="${subject}_${session}" | ||
if [ -d "$StudyFolder/$tp" ] && ! [[ " ${ExcludeVisits[*]+${ExcludeVisits[*]}} " =~ [[:space:]]"$tp"[[:space:]] ]]; then | ||
if (( n==0 )); then | ||
tplist="$tp" | ||
else | ||
tplist="$tplist@$tp" | ||
fi | ||
fi | ||
((n++)) | ||
done | ||
echo $tplist | ||
} | ||
|
||
########################################## INPUTS ########################################## | ||
#Scripts called by this script do assume they run on the outputs of the PreFreeSurfer Pipeline | ||
######################################### DO WORK ########################################## | ||
|
||
for i in ${!Subjects[@]}; do | ||
Subject=${Subjects[i]} | ||
#Subject's time point list, @ separated. | ||
TPlist=(`identify_timepoints $Subject`) | ||
#Array with timepoints | ||
IFS=@ read -ra Timepoints <<< "$TPlist" | ||
#Freesurfer longitudinal average template label | ||
LongitudinalTemplate=${Templates[i]} | ||
|
||
#Longitudinal FreeSurfer Input Variables | ||
SubjectID="$Subject" #FreeSurfer Subject ID Name | ||
SubjectDIR="${StudyFolder}/${Subject}/T1w" #Location to Put FreeSurfer Subject's Folder | ||
T1wImage="${StudyFolder}/${Subject}/T1w/T1w_acpc_dc_restore.nii.gz" #T1w FreeSurfer Input (Full Resolution) | ||
T1wImageBrain="${StudyFolder}/${Subject}/T1w/T1w_acpc_dc_restore_brain.nii.gz" #T1w FreeSurfer Input (Full Resolution) | ||
T2wImage="${StudyFolder}/${Subject}/T1w/T2w_acpc_dc_restore.nii.gz" #T2w FreeSurfer Input (Full Resolution) | ||
|
||
if [ "$parallel_mode" != FSLSUB ]; then #fsl_sub does not allow nested submissions | ||
if [[ "${command_line_specified_run_local}" == "TRUE" || "$QUEUE" == "" ]] ; then | ||
echo "About to locally run ${HCPPIPEDIR}/FreeSurfer/LongitudinalFreeSurferPipeline.sh" | ||
#NOTE: fsl_sub without -q runs locally and captures output in files | ||
queuing_command=("$FSLDIR/bin/fsl_sub") | ||
else | ||
echo "About to use fsl_sub to queue ${HCPPIPEDIR}/FreeSurfer/LongitudinalFreeSurferPipeline.sh" | ||
queuing_command=("$FSLDIR/bin/fsl_sub" -q "$QUEUE") | ||
fi | ||
else | ||
queuing_command=() | ||
fi | ||
|
||
#DO NOT PUT timepoint-specific options here!!! | ||
cmd=(${queuing_command[@]+"${queuing_command[@]}"} "$HCPPIPEDIR"/FreeSurfer/LongitudinalFreeSurferPipeline.sh \ | ||
--subject="$Subject" \ | ||
--path="$StudyFolder" \ | ||
--sessions="$TPlist" \ | ||
--fslsub-queue="$QUEUE" \ | ||
--longitudinal-template="$LongitudinalTemplate" \ | ||
--parallel-mode="$parallel_mode" \ | ||
--max-jobs="$max_jobs" \ | ||
--start-stage="$start_stage" \ | ||
--end-stage="$end_stage" \ | ||
) | ||
|
||
#--extra-reconall-arg-base=-conf2hires Freesurfer reports this is unneeded. | ||
echo "Running command: ${cmd[*]}" | ||
"${cmd[@]}" | ||
|
||
# The following lines are used for interactive debugging to set the positional parameters: $1 $2 $3 ... | ||
# echo set --subject=$Subject --subjectDIR=$SubjectDIR --t1=$T1wImage --t1brain=$T1wImageBrain --t2=$T2wImage --extra-reconall-arg-long="-i \"$SubjectDIR\"/T1w/T1w_acpc_dc_restore.nii.gz -emregmask \"$SubjectDIR\"/T1w/T1w_acpc_dc_restore_brain.nii.gz -T2 $SubjectDIR\"/T1w/T2w_acpc_dc_restore.nii.gz -T2pial" | ||
#echo ". ${EnvironmentScript}" | ||
|
||
done |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't get used. Batch scripts generally don't really need a usage statement in my opinion, it is intended for the user to edit them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed