Skip to content

Use MifImage class instead of mrconvert#43

Merged
tsalo merged 20 commits into
mainfrom
mif-io
Apr 24, 2026
Merged

Use MifImage class instead of mrconvert#43
tsalo merged 20 commits into
mainfrom
mif-io

Conversation

@tsalo

@tsalo tsalo commented Mar 27, 2026

Copy link
Copy Markdown
Member

Closes #15. Closes #17.

Keeping as a draft for now.

I've opened nipy/nibabel#1489 to add the MifImage class to nibabel. Depending on how quickly that PR progresses, we might want to keep copies of the class in ModelArrayIO for a release or two.

NOTE: Since HBCD does not include fixel data, this is a low priority item.

@codecov-commenter

codecov-commenter commented Mar 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.70115% with 95 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.39%. Comparing base (cc9b983) to head (bb5bcd3).

Files with missing lines Patch % Lines
src/modelarrayio/utils/mif_image.py 71.91% 43 Missing and 23 partials ⚠️
src/modelarrayio/utils/_mif_format.py 73.17% 13 Missing and 9 partials ⚠️
src/modelarrayio/cli/h5_to_mif.py 72.22% 4 Missing and 1 partial ⚠️
src/modelarrayio/utils/mif.py 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #43      +/-   ##
==========================================
+ Coverage   70.35%   75.39%   +5.04%     
==========================================
  Files          19       21       +2     
  Lines        1167     1463     +296     
  Branches      228      304      +76     
==========================================
+ Hits          821     1103     +282     
+ Misses        284      266      -18     
- Partials       62       94      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tsalo tsalo added the enhancement New feature or request label Mar 28, 2026
@tsalo tsalo marked this pull request as ready for review April 22, 2026 14:11
Comment thread src/modelarrayio/cli/h5_to_mif.py Outdated
)
nifti2_to_mif(temp_nifti2, out_mif)
result_header = template_img.header.copy()
result_header.set_data_shape(result_data.shape)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

will the template ever be scaled? Codex review said this, not sure if accurate: scaled template MIFs will produce numerically wrong outputs. src/modelarrayio/cli/h5_to_mif.py (line 68) copies the template header verbatim, while src/modelarrayio/utils/mif.py (line 582) has already applied header scaling to the in-memory data and the writer (line 395) writes the same scaling metadata back out. Any non-default scaling in example_mif will be applied twice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I know very little about the MIF format. @mattcieslak do you know the answer to this?

Comment thread src/modelarrayio/utils/mif.py Outdated

@tien-tong tien-tong left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

src/modelarrayio/utils/mif.py is now doing three jobs at once: format parsing, nibabel image behavior, and cohort/fixel helpers. Splitting that module would make future review and testing much easier. The duplicated result-writing blocks in h5_to_mif.py (line 62) could also be factored into one helper.

Documentation: docs are stale. docs/installation.rst (line 17) still says MRtrix mrconvert is required, and docs/examples/plot_fixel_workflow.py (line 133) still says existing files are not overwritten.

@tsalo

tsalo commented Apr 24, 2026

Copy link
Copy Markdown
Member Author

@tien-tong I think I've addressed all of your comments except for the one on scaling.

@tien-tong

Copy link
Copy Markdown

Looks good to me!

@mattcieslak mattcieslak 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.

We should actually test this with some real fixel data, but I think it's pretty solid

@tsalo tsalo merged commit b6d366d into main Apr 24, 2026
8 checks passed
@tsalo tsalo deleted the mif-io branch April 24, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixel ids got flipped Bypass NIfTI conversion

4 participants