Skip to content

feat: support rgb nifti - #15

Merged
xgui3783 merged 1 commit into
masterfrom
feat_supportRgbNifti
Oct 18, 2021
Merged

xgui3783 merged 1 commit into
masterfrom
feat_supportRgbNifti

Conversation

@xgui3783

Copy link
Copy Markdown
Collaborator

partial fixes #13

nibabel reading rgb nifti does not read the dataarray as [x, y, z, 3] numpy array, but instead as [x, y, z] numpy array, with datatype as [(R, dtype), (G, dtype), (B, dtype)].

This breaks the built in datatype check of neuroglancer-scripts.

This PR checks for this datatype, and patches the necessary parameters:

  • when writing info_fullres.json, adds an additional dimension, so num_channel is correctly set to 3
  • when reading nifti & writing chunks, it reshape the data from [x,y,z] to [x,y,z,3] (not via the native .reshape method, but with .view -> slice manually, which seems to be faster)

Admittedly, the second approach is very naive. I would welcome any feedbacks on doing it more efficiently.

@ylep ylep left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @xgui3783, first I apologize for the delay, I did not see the GitHub notification of review request.
Your implementation looks good to me, also thanks for adding the tests 🙂

@xgui3783
xgui3783 merged commit 16df9c4 into master Oct 18, 2021
@xgui3783
xgui3783 deleted the feat_supportRgbNifti branch October 18, 2021 14:46
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.

[feature request] support RGB24 in nifti and multichanneled tiff (RGB)

2 participants