Skip to content

NHP DiffusionPreprocessing#388

Open
TakJim wants to merge 5 commits intoWashington-University:masterfrom
RIKEN-BCIL:NHP_DiffusionPreprocessing
Open

NHP DiffusionPreprocessing#388
TakJim wants to merge 5 commits intoWashington-University:masterfrom
RIKEN-BCIL:NHP_DiffusionPreprocessing

Conversation

@TakJim
Copy link
Copy Markdown
Contributor

@TakJim TakJim commented Mar 16, 2026

This PR adds NHP-adapted versions of the DiffusionPreprocessing pipeline scripts.

These scripts are the current working versions.

  • Integration with the existing HCP DiffusionPreprocessing scripts has not yet been done and will be addressed in subsequent commits.

Files Added

  • DiffusionPreprocessing/DiffPreprocPipelineNHP.sh
  • DiffusionPreprocessing/DiffPreprocPipeline_EddyNHP.sh
  • DiffusionPreprocessing/DiffPreprocPipeline_PostEddyNHP.sh
  • DiffusionPreprocessing/DiffPreprocPipeline_PreEddyNHP.sh

TakJim added 2 commits March 16, 2026 18:19
Add NHP-adapted versions of the four DiffusionPreprocessing pipeline scripts:
- DiffPreprocPipelineNHP.sh
- DiffPreprocPipeline_EddyNHP.sh
- DiffPreprocPipeline_PostEddyNHP.sh
- DiffPreprocPipeline_PreEddyNHP.sh
- Replace --specieslabel (numeric) with --species (string, default "Human")
  matching PreFreeSurfer PR Washington-University#350 pattern
- Add SPECIES to SpeciesLabel case mapping for NHP sub-scripts
- Branch on SPECIES=="Human" vs !="Human" for PreEddy, Eddy, PostEddy:
  Human path calls original .sh with all HCP params (100% backward compat)
  NHP path calls *NHP.sh with NHP-specific params
- validate_scripts(): retain all Human checks incl run_eddy.sh,
  add NHP script checks conditionally
- Add --usephasezero pass-through to PreEddyNHP.sh
- glibc workaround scoped to NHP path only
"--select-best-b0=${SelectBestB0}"
"--ensure-even-slices=${EnsureEvenSlices}"
"--combine-data-flag=${CombineDataFlag}")
if [[ "$SPECIES" == "Human" ]]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a DiffPreprocPipelineNHP.sh, why does the human version have SPECIES conditionals?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DiffPreprocPipelineNHP.sh is a legacy file from before integration — it will be removed once the scripts are unified into the HCP versions.

Comment on lines +479 to +483
## TH Dev 2019 to avoid glibc causing segmentation error in gradient_unwarp.py
if [[ "$SPECIES" != "Human" ]] && [[ "${LD_LIBRARY_PATH:-}" =~ /opt/glibc-2.14/lib ]]; then
export LD_LIBRARY_PATH=$(echo "$LD_LIBRARY_PATH" | sed -e 's@/opt/glibc-2.14/lib:@@g' | sed -e 's@:/opt/glibc-2.14/lib@@g')
log_Msg "Removed /opt/glibc-2.14/lib from LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
fi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't have been in LD_LIBRARY_PATH in the first place, it is empty by default. This workaround is something you should add to your edited copy of SetUpHCPPipeline.sh (or your edited copy of an Examples batch), not hack into a pipeline script.

Comment on lines +535 to +540
## TH Dev 2019 to avoid glibc causing segmentation error in gradient_unwarp.py
if [[ $LD_LIBRARY_PATH =~ /opt/glibc-2.14/lib ]] ; then
export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | sed -e 's@/opt/glibc-2.14/lib:@@g' | sed -e 's@:/opt/glibc-2.14/lib@@g')
fi
log_Msg "LD_LIBRARY_PATH:$LD_LIBRARY_PATH"
##
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this doesn't belong in a pipeline, this is something weird in your specific environment you should fix in something that is intended to be edited by users.

TakJim added 3 commits March 24, 2026 06:52
…ddy.sh

- Add NHP options: --species, --specieslabel, --truepatientposition,
  --scannerpatientposition, --usephasezero
- Add SPECIES branching for input data reorient (CorrectVolumeOrientation
  + Rotate_bvecs.sh for NHP, simple imcp for Human)
- Add SPECIES branching for basic_preproc (NHP uses basic_preproc.sh,
  Human uses norm_intensity + best_b0/sequence)
- Add SPECIES branching for topup (NHP: optional T2w phase-zero insertion
  + run_topupNHP.sh, Human: run_topup.sh)
- Update main DiffPreprocPipeline.sh to call unified PreEddy for both
  Human and NHP, removing the PreEddyNHP.sh dispatch
- Add --species option to select Human or NHP eddy path
- Human: run_eddy.sh with full GPU/CUDA support (unchanged)
- NHP: run_eddyNHP.sh with -g flag and JacobianResampling marker
- Update main DiffPreprocPipeline.sh to call unified Eddy for both
  Human and NHP, removing the EddyNHP.sh dispatch
…tEddy.sh

- Add NHP options: --species, --specieslabel, --wmprojabs
- SPECIES branching for eddy_postproc (Human: eddy_postproc.sh,
  NHP: eddy_postprocNHP.sh with SpeciesLabel)
- SPECIES branching for DiffusionToStructural (Human: DiffusionToStructural.sh,
  NHP: DiffusionToStructuralNHP.sh with --fsbbrdiff and --wmprojabs)
- SPECIES branching for eddy log copy and cnr_maps handling
- Update main DiffPreprocPipeline.sh to call unified PostEddy for both
  Human and NHP, removing the PostEddyNHP.sh dispatch
- All four Diffusion sub-scripts are now unified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants