Skip to content

Conversation

CloseChoice
Copy link
Contributor

@CloseChoice CloseChoice commented Oct 13, 2025

Add support for NIfTI.

supports #7804

This PR follows #7325 very closely

I am a bit unsure what we need to add to the document_dataset.mdx and document_load.mdx. I should probably create a dataset on the hub first to create this guide instead of copy+pasting from PDF.

Open todos:

  • create nifti dataset on the hub
  • [ ] update document_dataset.mdx and document_load.mdx

EDIT:
I tested with two datasets I created on the hub:

for zipped (file extension .nii.gz and unzipped .nii) files and both seem to work fine. Also tested loading locally and that seems to work as well.
Here is the scriptsthat I ran against the hub:

from pathlib import Path

from datasets import load_dataset
import nibabel as nib


dataset = load_dataset(
        "TobiasPitters/test-nifti-unzipped",
        split="test"  # Load as single Dataset, not DatasetDict
)

print("length dataset unzipped:", len(dataset))
for item in dataset:
    isinstance(item["nifti"], nib.nifti1.Nifti1Image)

dataset = load_dataset(
        "TobiasPitters/test-nifti",
        split="train"  # Load as single Dataset, not DatasetDict
)
print("length dataset zipped:", len(dataset))
for item in dataset:
    isinstance(item["nifti"], nib.nifti1.Nifti1Image)

@CloseChoice CloseChoice marked this pull request as ready for review October 14, 2025 17:51
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.

1 participant