Repository navigation
feat: read uncompressed .nii inputs, not only .nii.gz - #79
Merged
Merged
Conversation
Plain `.nii` is what dcm2niix writes without `-z y` and what a good share of public datasets ship, and SPINEPS could not read it: the CLI appended `.nii.gz` to whatever it was given, `BIDS_FILE.file` is keyed by extension so the three `file["nii.gz"]` lookups raised KeyError, and the dataset query filtered on that single extension. Users had to gzip their whole dataset first. A shared `input_image_path()` resolves either extension, the dataset query accepts both, and `--input` / `spineps.segment()` take both. Outputs are still always written as `.nii.gz`; a genuinely unreadable extension still gets the clear error. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Keeps this change off the paragraph the non-BIDS-filename PR also adds to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
One source of truth, and it keeps the top of entrypoint.py free so this does not overlap the CT-default change that also adds code there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
Author
|
No CI here on purpose: the |
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.
Problem
Plain
.niiis whatdcm2niixwrites without-z y, and what a good share of public datasets ship.SPINEPS could not read it at all:
.nii.gzto whatever it was given, turningscan.niiintoscan.nii.nii.gz,BIDS_FILE.fileis keyed by extension, so the threeimg_ref.file["nii.gz"]lookups raisedKeyErrorfor a
.niiinput, andprocess_dataset's query filtered onfilter_filetype("nii.gz"), so.niiscans were invisible todataset mode.
A user with a
.niidataset had to gzip all of it first.Fix
input_image_path(img_ref)inseg_utilsresolvesnii.gzornii, used at all threelookups, with
NIFTI_FILE_TYPESas the single source of truth.process_datasetpasses both extensions tofilter_filetype.--inputandspineps.segment()accept both; the extension is still appended when--inputis givenwithout one. A genuinely unreadable extension (
scan.mha) still gets the clear error from fix: make CLI messages name flags that exist and causes users can act on #77, andthat PR's test is retargeted accordingly.
.nii.gz, sinceget_changed_path(file_type="nii.gz")sets them.Tests
unit_tests/test_plain_nii_input.py:input_image_pathon both extensions, the compatibility check on a.nii, a fullsegment_imagerun onsub-01_T2w.niithat asserts all four outputs land on disk as.nii.gz, andrun_samplenot rejecting a.nii. The file does not even import on the base branch.Full suite: 233 passed, ruff clean.
🤖 Generated with Claude Code