Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for biomedical image formats NIFTI #139

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ktsitsi
Copy link
Collaborator

@ktsitsi ktsitsi commented Oct 7, 2024

This draft PR:

  • Adds support for NIFTI images in TileDB-Bioimaging
  • Roundtrip has been tested and is working using the from_bioimg, to_bioimg API calls and the respective Converter.Nifti
  • The original & exported images are renderable by Slicer
  • Unit-tests (in-progress)
  • Other sample images apart from visiblehuman
  • Differences between Nifti1Images and Nifti2Images (Will split it into a different ticket)
from tiledb.bioimg import from_bioimg, to_bioimg 
from tiledb.bioimg import Converters
from_bioimg('./tests/data/nifti/visiblehuman.nii', './tests/data/nifti/tiledb_out/nifti_sample.tdb', converter=Converters.NIFTI)
Ingesting level 0: 100%|██████████| 256/256 [00:05<00:00, 46.45tiles/s]
Out[4]: tiledb.bioimg.converters.nifti.NiftiConverter
to_bioimg('./tests/data/nifti/tiledb_out/nifti_sample.tdb', './tests/data/nifti/nifti_roundtrip.nii', converter=Converters.NIFTI)
Out[5]: tiledb.bioimg.converters.nifti.NiftiConverter

Source of the sample test images are from nibabel https://github.com/nipy/nibabel/tree/master/nibabel/tests/data

@ktsitsi ktsitsi marked this pull request as ready for review October 10, 2024 13:38
@ktsitsi ktsitsi force-pushed the kt/sc-47489/support-for-biomedical-image-formats-nifti-and-dicom branch from f0f7e0f to 3745388 Compare October 10, 2024 13:40
@ktsitsi ktsitsi force-pushed the kt/sc-47489/support-for-biomedical-image-formats-nifti-and-dicom branch from 8e53e4f to b7d54af Compare October 11, 2024 12:54
@ihnorton ihnorton self-assigned this Oct 11, 2024
@ktsitsi ktsitsi force-pushed the kt/sc-47489/support-for-biomedical-image-formats-nifti-and-dicom branch from a3f0b2c to ba3eab4 Compare October 11, 2024 13:53
@ktsitsi ktsitsi force-pushed the kt/sc-47489/support-for-biomedical-image-formats-nifti-and-dicom branch from ba3eab4 to fa4279d Compare October 11, 2024 13:55

@property
def group_metadata(self) -> Dict[str, Any]:
writer_kwargs = dict(
Copy link
Contributor

Choose a reason for hiding this comment

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

Some properties get their value set as NaN which is not a valid JSON type and should be set to null

dims_number = header_dict["dim"][0]
if dims_number == 4:
# According to standard the 4th dimension corresponds to 'T' time
# but in special cases can be degnerate into channels
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT

Suggested change
# but in special cases can be degnerate into channels
# but in special cases can be degenerate into channels

)
numerical_data = numerical_data.reshape(self.level_shape())

# Bug! data might have slope and inter and header not contain them.
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you detect such case? May be useful to log some warning message.

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.

3 participants