Skip to content

Added proper handling of nifti RGB formats#46

Open
baishi wants to merge 2 commits intoHumanBrainProject:masterfrom
Neuroinflab:master
Open

Added proper handling of nifti RGB formats#46
baishi wants to merge 2 commits intoHumanBrainProject:masterfrom
Neuroinflab:master

Conversation

@baishi
Copy link

@baishi baishi commented Feb 18, 2026

Two formats of NIfTI are properly supported

  1. The format of (x, y, z, t, (uint8, uint8, uint8)) is supported and mmap works out of the box
  2. The format of (x, y, z, t, [('R', 'u1'), ('G', 'u1'), ('B', 'u1')]) structured rgb format is also supported. However, due to limitation of nibabel, the full dataset need to be loaded into memory.
    A warning is printed for this case

Shi Bai added 2 commits February 19, 2026 05:05
1. The format of (x, y, z, t, (uint8, uint8, uint8)) is supported and
   mmap works out of the box
2. The format of (x, y, z, t, [('R', 'u1'), ('G', 'u1'), ('B', 'u1')])
   structured rgb format is also supported. However, due to limitation
   of nibabel, the full dataset need to be loaded into memory.
   A warning is printed for this case
@xgui3783
Copy link
Collaborator

@baishi thanks for the PR.

Is there a sample nifti where we can write test to prevent regression in the future?

@baishi
Copy link
Author

baishi commented Feb 28, 2026

@baishi thanks for the PR.

Is there a sample nifti where we can write test to prevent regression in the future?

sample_tuple.nii.gz

sample_structure.nii.gz

I have attached two sample image to test against.
sample_tuple uses 3 tuple of 8 bits (datatype 2) on 5th dimension (dim[5] a.k.a x, y, z, t, rgb) to store the value
and
sample_structure uses 1 value of 24-bit (datatype 128) on 5th dimension to store the structured rgb value.

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.

2 participants