Skip to content

Add --scalar-columns parameter to NIfTI and MIF CLIs#34

Merged
mattcieslak merged 21 commits into
mainfrom
scalar-columns
Apr 1, 2026
Merged

Add --scalar-columns parameter to NIfTI and MIF CLIs#34
mattcieslak merged 21 commits into
mainfrom
scalar-columns

Conversation

@tsalo

@tsalo tsalo commented Mar 26, 2026

Copy link
Copy Markdown
Member

Closes #32. Closes #33.

@tsalo tsalo added the enhancement New feature or request label Mar 26, 2026
@codecov-commenter

codecov-commenter commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.78431% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.14%. Comparing base (7502f6e) to head (ae0ddb6).

Files with missing lines Patch % Lines
src/modelarrayio/utils/mif.py 12.90% 26 Missing and 1 partial ⚠️
src/modelarrayio/cli/mif_to_h5.py 45.71% 15 Missing and 4 partials ⚠️
src/modelarrayio/cli/nifti_to_h5.py 58.33% 12 Missing and 3 partials ⚠️
src/modelarrayio/storage/tiledb_storage.py 0.00% 9 Missing ⚠️
src/modelarrayio/cli/utils.py 60.00% 3 Missing and 1 partial ⚠️
src/modelarrayio/utils/misc.py 90.47% 2 Missing and 2 partials ⚠️
src/modelarrayio/cli/cifti_to_h5.py 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
- Coverage   61.19%   61.14%   -0.06%     
==========================================
  Files          16       17       +1     
  Lines         951     1045      +94     
  Branches      137      170      +33     
==========================================
+ Hits          582      639      +57     
- Misses        332      360      +28     
- Partials       37       46       +9     

☔ 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.

@mattcieslak

Copy link
Copy Markdown
Contributor

I think the way to go here is to make multiple h5 files, since using that is supported in ModelArray now. This won't make a difference for tiledb, since the scalars all go into different files in its root directory anyways. Separate h5's let users mix and match when modeling and also the reshaping from long to wide during the ModelArray runs adds up

@tsalo
tsalo requested a review from mattcieslak April 1, 2026 15:25
@tsalo

tsalo commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

When providing a wide-form cohort tsv and --scalar-columns, it will now write out separate H5 files (e.g., with --output test.h5 --scalar-columns alpha beta we get alpha_test.h5 and beta_test.h5.

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

This is great! Only minor non-blocking comments. Thank you!!

Comment thread docs/outputs.rst

- ``*-to-h5`` commands: convert input neuroimaging data into either:
- one or more HDF5 files (``--backend hdf5``), or
- one or more TileDB directories (``--backend tiledb``).

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.

I believe it will write data blobs with different names to the tiledb directory. Haven't tested this though

Comment thread docs/outputs.rst Outdated
Comment thread src/modelarrayio/cli/mif_to_h5.py Outdated
Comment thread src/modelarrayio/storage/h5_storage.py
Comment thread src/modelarrayio/storage/h5_storage.py Outdated
Comment thread test/test_fixels_utils.py

def test_nifti2_to_mif_raises_when_mrconvert_missing(tmp_path, monkeypatch) -> None:
monkeypatch.setattr(fixels, 'find_mrconvert', lambda: None)
monkeypatch.setattr(mif, 'find_mrconvert', lambda: None)

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.

this is really clever

tsalo and others added 5 commits April 1, 2026 12:39
Co-authored-by: Matt Cieslak <mattcieslak@gmail.com>
num_subjects --> n_files
num_items --> n_elements
num_elements --> n_elements
num_voxels --> n_voxels
@tsalo

tsalo commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

@mattcieslak do you want to take another look or should I merge?

@mattcieslak
mattcieslak merged commit 5fc9a3f into main Apr 1, 2026
8 checks passed
@mattcieslak
mattcieslak deleted the scalar-columns branch April 1, 2026 17:17
@tsalo tsalo mentioned this pull request Apr 1, 2026
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.

Leverage workers and s3-workers in all to-h5 CLIs Support --scalar-columns in nifti-to-h5 and mif-to-h5

3 participants