Update HippUnfold HCP processing - #410
orenpoliva wants to merge 6 commits into
Conversation
| if [[ "$RunLocal" == "FALSE" ]] | ||
| then | ||
| # Separate cache and conda directory for each subject to avoid crash due to parallel use | ||
| JobCache="${HIPPUNFOLD_CACHE_DIR}/job-cache/${JOB_ID:-local}_${Subject}" |
There was a problem hiding this comment.
Maybe I should implement support for folders in tempfiles.shlib, so we wouldn't need this hack just to avoid collision on something we presumably don't need to preserve.
| #!/bin/bash | ||
|
|
There was a problem hiding this comment.
Please always include the shabang.
glasserm
left a comment
There was a problem hiding this comment.
Given the really extensive PostHippUnfold changes, I would like to review at test dataset.
|
HippUnfold
Added the --latency-wait 60 and --rerun-incomplete flags to the HippUnfold command to improve robustness against common causes of failed or interrupted runs.
Potentially fixed a bug in the transformation of hippocampal surfaces from T1w/physical space to MNI space. The wb_command -surface-apply-warpfield command supplied an MRI image (T1w_restore.nii.gz) as the argument to -fnirt, rather than the corresponding FNIRT transformation field.
The original command contained: Questions:
|
No. Different pipelines are (somewhat) expected to use different queues because they have different levels of internal parallelism and memory requirements. |
| 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}" | ||
| echo "$Subject" | ||
|
|
||
| LogDir="${StudyFolder}/${Subject}/T1w/HippUnfold/logs/HippUnfoldHCP" | ||
| mkdir -p "$LogDir" | ||
| cd "$LogDir" | ||
|
|
||
| if [[ "${command_line_specified_run_local}" == "TRUE" || "$QUEUE" == "" ]] ; then | ||
|
|
||
| echo "About to locally run ${HCPPIPEDIR}/HippUnfoldHCP/HippUnfoldHCP.sh" | ||
|
|
||
| if ! "$HCPPIPEDIR"/global/scripts/captureoutput.sh \ | ||
| "$HCPPIPEDIR"/HippUnfoldHCP/HippUnfoldHCP.sh \ | ||
| --study-folder="$StudyFolder" \ | ||
| --subject="$Subject" | ||
| then | ||
| echo "ERROR: HippUnfold failed for subject: $Subject" | ||
| exit 1 | ||
| fi | ||
|
|
There was a problem hiding this comment.
I'm not sure we want local runs to stop at the first failed subject, as it doesn't necessarily indicate that later subjects will also fail. I'd suggest changing all this back to the normal queueing_command pattern.
| for Subject in $Subjlist ; do | ||
| HippLogDir="${StudyFolder}/${Subject}/T1w/HippUnfold/logs/HippUnfoldHCP" | ||
| LatestLog=$(ls -t "${HippLogDir}"/*.o* 2>/dev/null | head -1) | ||
|
|
||
| if [[ -n "$LatestLog" ]] && grep -qF "HippUnfold pipeline completed successfully for subject: ${Subject}" "$LatestLog" ; then | ||
| SuccessfulSubjects+=" ${Subject}" | ||
| else | ||
| FailedSubjects+=" ${Subject}" | ||
| fi | ||
| done |
There was a problem hiding this comment.
I don't think we want to use log files to decide whether to try to run the Post pipeline, particularly not by checking for a highly specific and otherwise cosmetic message (that any developer might edit or remove without much thought). We could test for the existence of an important data file, but only if we really need the launcher to not even attempt some subjects. I think it is rare that we have a launcher try to do this at all, rather than simply trying every subject in the user-provided list.
There was a problem hiding this comment.
Launcher code like that is typically something the users add after the fact for convenience.
| LogDir="${StudyFolder}/${Subject}/T1w/HippUnfold/logs/HippUnfoldHCP" | ||
| mkdir -p "$LogDir" | ||
| cd "$LogDir" |
There was a problem hiding this comment.
Putting the job logs into subject-specific folders is not how we usually do things, and makes it harder to grep all the logs from a batch at once.
There was a problem hiding this comment.
If we don’t put the log files in the subject-specific directories, would it be a good idea to include the subject ID in the log filename?
There was a problem hiding this comment.
I'm not sure that we can set the name of the logfile. The queuing system typically generates it from the name of the executable and the job number (a counter that never resets, even through reboots).
There was a problem hiding this comment.
Let's treat logs as other pipelines do.
| Subjlist="103818 105923 111312 114823 115320 122317 125525 130518 135528 | ||
| 137128 139839 143325 144226 146129 149337 149741 151526 158035 | ||
| 169343 172332 175439 177746 185442 187547 192439 194140 195041 | ||
| 200109 200614 204521 250427 287248 341834 433839 562345 599671 | ||
| 601127 627549 660951 662551 783462 859671 861456 877168 917255" |
There was a problem hiding this comment.
Please make a copy with a different name or path (for instance, appending your initials, or somewhere outside the repo entirely) and don't commit it, rather than committing your testing paths and subject list to the example.
There was a problem hiding this comment.
After noticing I did this, I committed the scripts again with empty paths. Did you not receive the updated commit?
There was a problem hiding this comment.
See my comment on line 113, you appear to have tried to replace the contents of the file, but left the entire old version on the end of it.
| fi | ||
| } | ||
|
|
||
| trap cleanup EXIT |
There was a problem hiding this comment.
If anyone tries to use tempfiles.shlib, this trap ... EXIT will prevent it from working. We can probably leave this as a "remove if completed successfully" rather than worrying about it. Or, I can add folder support to tempfiles.shlib, to also handle the collision avoidance without expecting JOB_ID to be a robust indicator.
|
I uploaded a new version that addresses Tim’s comments. It also includes several additions that I thought would improve the scripts:
The pipeline output can be inspected for subject 103818 at: /media/myelin/oren/HippUnfo |
Please not |
| if [[ "$RunLocal" == "TRUE" || -z "$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" -l "$LogFolder") | ||
|
|
||
| fi | ||
|
|
||
| "${queuing_command[@]}" \ |
There was a problem hiding this comment.
This is in a loop, it should be indented.
I agree. |
|
|
I would pair 8k and 18k with 164k meshes, since they are of more similar sampling density. Otherwise things looked good for my review of the test dataset. |
|
The PostHippUnfold diff is still full of non-changes. Can you clean it up so that I can see only the stuff that actually changed? |
Main changes for RunHippUnfold, HippUnfold, PostHippUnfold, RunPostHippUnfold:
-Updated the HippUnfold command to use the Maguire T2w model, including --force-nnunet-model maguire_T2w and inner/outer registration settings of 0.
-Changed the output/file structure from supporting separate T1w, T2w, and T1wT2w models to using the Maguire T2w model. Because only one model is now used, the model-specific T1w, T2w, and T1wT2w subdirectories were removed.
-Log files are now written to a dedicated logging directory within each subject's T1w/HippUnfold directory.
-In HippUnfoldHCP.sh, imported runlocal from RunHippUnfoldHCP, and added separate per-job cache and Conda directories when runlocal=FALSE. This prevents simultaneous subjects from sharing these directories, which had caused failures when multiple HippUnfold jobs were run in parallel. These temporary per-job directories are removed after successful completion.
-In PostHippUnfoldHCP.sh, one use of ${Scalar} in the dentate-label generation section was replaced with an explicit thickness.shape.gii input. ${Scalar} is likely a leftover from the preceding scalar-processing loop. The metric is used as the template for generating the constant-valued dentate label; the thickness values themselves are not used in the calculation.
-Updated RunHippUnfoldHCP.sh and RunPostHippUnfoldHCP.sh for generic study-folder, subject-list, environment-script.