Skip to content

Improve orientation robustness in SH/DTI scripts - #1360

Merged
arnaudbore merged 8 commits into
scilus:dev_3.0.xfrom
frheault:split_branch_6_shdti
Nov 3, 2026
Merged

arnaudbore merged 8 commits into
scilus:dev_3.0.xfrom
frheault:split_branch_6_shdti

Conversation

@frheault

@frheault frheault commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Quick description

Depends on PR 1 (split_branch_1_core), included here so this PR's tests pass on their own.

Updates 5 scripts (scil_dti_convert_tensors, scil_sh_convert, scil_sh_fusion, scil_sh_to_aodf, scil_sh_to_rish) to scilpy's newer image-loading code. None of these are known to have produced wrong results before: their math doesn't depend on which orientation the file is stored in, so this is a consistency/robustness update, not a bug fix. As a bonus, scil_sh_fusion now checks that all files being merged share a compatible header, not just the first two.

I validated the before/after behavior using this data/code.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

pytest src/scilpy/cli/tests/test_dti_convert_tensors.py src/scilpy/cli/tests/test_sh_convert.py src/scilpy/cli/tests/test_sh_fusion.py src/scilpy/cli/tests/test_sh_to_aodf.py src/scilpy/cli/tests/test_sh_to_rish.py src/scilpy/io/tests/test_stateful_image.py -v
56 passed.

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

🤖 Generated with Claude Code

…cripts to StatefulImage, requires the sh_basis/is_legacy overrides on create_from

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

A moderate metadata-preservation issue remains, along with a minor fusion test coverage gap.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates five SH/DTI CLI scripts to use StatefulImage for orientation-aware processing, metadata handling, and stronger fusion validation.

Changes:

  • Preserves source orientation during processing and output.
  • Adds metadata, dtype, and header handling.
  • Adds LAS/RAS regression coverage.
  • Validates compatibility across fused inputs.
File Summary Review note
src/​scilpy/​io/​tests/​test_stateful_image.py Tests metadata, dtype, header, and file-map behavior. —
src/​scilpy/​io/​stateful_image.py Enhances orientation-aware image and metadata handling. Moderate (2 votes): preserve extra and file_map after reorientation.
src/​scilpy/​cli/​tests/​test_sh_to_rish.py Adds LAS RISH coverage. —
src/​scilpy/​cli/​tests/​test_sh_to_aodf.py Adds LAS aODF coverage. —
src/​scilpy/​cli/​tests/​test_sh_fusion.py Adds LAS fusion and header validation coverage. Nit (1 vote): add a third incompatible input.
src/​scilpy/​cli/​tests/​test_sh_convert.py Adds LAS SH conversion coverage. —
src/​scilpy/​cli/​tests/​test_dti_convert_tensors.py Adds LAS tensor conversion coverage. —
src/​scilpy/​cli/​scil_sh_to_rish.py Uses orientation-aware RISH processing and masks. —
src/​scilpy/​cli/​scil_sh_to_aodf.py Uses orientation-aware aODF processing. —
src/​scilpy/​cli/​scil_sh_fusion.py Reorients inputs and validates fusion headers. —
src/​scilpy/​cli/​scil_sh_convert.py Uses orientation-aware SH conversion. —
src/​scilpy/​cli/​scil_dti_convert_tensors.py Uses orientation-aware tensor conversion. —

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/scilpy/io/stateful_image.py Resolved
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.94%. Comparing base (26a224e) to head (b6410fe).

Additional details and impacted files
@@              Coverage Diff              @@
##           dev_3.0.x    #1360      +/-   ##
=============================================
- Coverage      72.95%   72.94%   -0.01%     
=============================================
  Files            304      304              
  Lines          27053    27059       +6     
  Branches        3839     3840       +1     
=============================================
+ Hits           19737    19739       +2     
- Misses          5707     5710       +3     
- Partials        1609     1610       +1     
Flag Coverage Δ
smoketests 69.88% <82.35%> (-0.01%) ⬇️
unittests 15.43% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Scripts 75.59% <82.35%> (-0.02%) ⬇️
Library 69.87% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frheault
frheault requested a review from arnaudbore October 13, 2026 20:30
@frheault frheault changed the title (WIP) Improve orientation robustness in SH/DTI scripts Improve orientation robustness in SH/DTI scripts Oct 13, 2026
@arnaudbore
arnaudbore requested a review from CHrlS98 October 19, 2026 16:08

@arnaudbore arnaudbore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@CHrlS98 CHrlS98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One small question for my understanding.

@arnaudbore
arnaudbore merged commit 6ec8b68 into scilus:dev_3.0.x Nov 3, 2026
2 checks passed
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.

4 participants