Add TORTOISE DIFFPREP as a head-motion-correction backend#1066
Draft
tsalo wants to merge 15 commits into
Draft
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Add diffprep_motion, diffprep_quadratic, diffprep_cubic to --hmc-model choices - Add --diffprep-config CLI argument mirroring --eddy-config - Add diffprep_config to execution._paths and workflow class in config.py - Add validate_diffprep_config() in utils/misc.py - Add default qsiprep/data/diffprep_params.json - Add TDD tests: parser choices + validate_diffprep_config unit tests Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Implements _TORTOISEProcessInputSpec, _TORTOISEProcessOutputSpec, and TORTOISEProcess (wrapping the TORTOISEProcess binary in DIFFPREP mode) in qsiprep/interfaces/tortoise.py. Adds test file qsiprep/tests/test_interfaces_diffprep.py with cmdline construction test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eview) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extracts the rigid 6-DOF (3 translations mm, 3 rotations rad) from the per-volume DIFFPREP transforms file produced by TORTOISEProcess, writing them to a plain-text motion file for downstream confound reporting. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…TORTOISE b-matrix Implements the inverse of make_bmat_file: reads a TORTOISE .bmtxt (6-column per-volume b-matrix) and recovers b-values via trace(B) and gradient directions via principal eigenvector of B. Adds round-trip test confirming b-value and direction recovery from hand-crafted b-matrix entries. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… 4 review) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…Task 5) Create qsiprep/workflows/dwi/diffprep.py with init_diffprep_hmc_wf: a bake-in HMC-only DIFFPREP workflow that is a drop-in peer of init_fsl_hmc_wf. Add generate_diffprep_boilerplate to tortoise.py and the workflow-construction test to test_interfaces_diffprep.py. Fixes the ExtractB0s bval_file gap noted in the brief by wiring bmat_to_fsl.bval_file -> extract_b0s.bval_file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… 5 review) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add import for init_diffprep_hmc_wf, module-level _diffprep_order() helper, and elif diffprep_ dispatch in init_dwi_preproc_wf HMC block. Add test_base_selects_diffprep pinning the helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…t (Task 6 review) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Document the three new --hmc-model values (diffprep_motion, diffprep_quadratic, diffprep_cubic) and --diffprep-config flag in the "Head motion correction model" section of docs/quickstart.rst, covering their use case for non-shelled / CS-DSI acquisitions where FSL eddy cannot be used and SHORELine does not correct eddy currents. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… review) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…y polarity, orientation, PATH guard (final review) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1066 +/- ##
==========================================
+ Coverage 47.37% 47.84% +0.46%
==========================================
Files 66 67 +1
Lines 9899 10045 +146
Branches 1099 1107 +8
==========================================
+ Hits 4690 4806 +116
- Misses 4978 5007 +29
- Partials 231 232 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds TORTOISE v4 DIFFPREP as a first-class
--hmc-modeloption, alongsideeddy,3dSHORE, andtensor. DIFFPREP fits a signal model over arbitrary q-space, so it corrects head motion and eddy currents on non-shelled data (e.g. compressed-sensing DSI) — the gap where FSL eddy can't run (no shells) and SHORELine corrects motion but not eddy currents.Three variants, selected by suffix:
--hmc-modeldiffprep_motiondiffprep_quadraticdiffprep_cubicScope
This backend is HMC-only (motion + eddy current). It follows the same "bake-in" model as eddy: TORTOISE's resampled DWI and rotated gradients become the workflow outputs, with identity per-volume affines.
It does not perform susceptibility distortion correction. If a fieldmap is present for a DWI series, the run fails fast with a clear
NotImplementedErrorrather than silently skipping SDC — use--hmc-model eddy/3dSHORE, or--ignore fieldmaps.Changes
--hmc-modelchoices:diffprep_motion,diffprep_quadratic,diffprep_cubic.--diffprep-configflag (mirrors--eddy-config), backed byconfig.workflow.diffprep_config,validate_diffprep_config, and a defaultqsiprep/data/diffprep_params.json.qsiprep/interfaces/tortoise.py)TORTOISEProcess— DIFFPREP runner.DIFFPREPMotionParams— per-volume rigid motion parameters for confounds / QC.BmatToFSLGradients— recovers FSL bval/bvec from the TORTOISE b-matrix.generate_diffprep_boilerplate— methods boilerplate.qsiprep/workflows/dwi/diffprep.py)init_diffprep_hmc_wf— a drop-in peer ofinit_fsl_hmc_wfwith an identical inputnode/outputnode contract, all in LPS+.ConformDwiso they stay consistent with the reoriented image.qsiprep/workflows/dwi/base.py)init_dwi_preproc_wfbranches to the new workflow whenhmc_model.startswith('diffprep_').--shoreline-itersguard are untouched (fully backward compatible).docs/quickstart.rst)Diff:
+688 / −3across 10 files (parser, config, misc, data, interfaces, workflow, base, docs, plus tests).Testing
10 new tests pass:
init_diffprep_hmc_wf.Tests are intentionally offline (the TORTOISE binaries aren't available in CI), so the interface tests assert command-line structure rather than exact flag strings.
Not yet validated against the real binary
These TORTOISE-binary-dependent details still need reconciling against
TORTOISEProcessinside the qsiprep container before a production run. They are deliberately isolated so they don't affect the public contract:TORTOISEProcessargument flag names and its output filenames.DIFFPREPMotionParamsreads the first 6 columns)..bmtxtcolumn order and b-value scale (BmatToFSLGradients— the round-trip test is internally consistent but not checked againstFSLBVecsToTORTOISEBmatrix).antsApplyTransformsaccepts the identity.matfiles emitted forto_dwi_ref_affines.The TORTOISE binaries themselves already ship in the qsiprep image (copied from
pennlinc/qsiprep-drbuddi), so no Dockerfile change is needed.