feat(libcommon): Add NIfTI neuroimaging file support#3273
Open
The-Obstacle-Is-The-Way wants to merge 3 commits intohuggingface:mainfrom
Open
feat(libcommon): Add NIfTI neuroimaging file support#3273The-Obstacle-Is-The-Way wants to merge 3 commits intohuggingface:mainfrom
The-Obstacle-Is-The-Way wants to merge 3 commits intohuggingface:mainfrom
Conversation
103e62c to
258d0cd
Compare
Add support for NIfTI (.nii, .nii.gz) neuroimaging files in the Dataset Viewer. This enables viewing of brain imaging datasets such as BIDS-formatted neuroimaging studies. Changes: - Bump datasets dependency from 4.1.1 to ^4.4.1 (includes Nifti type) - Add nibabel ^5.0.0 dependency for NIfTI file handling - Add NiftiSource TypedDict and create_nifti_file() in asset.py - Add nifti() handler and dispatch in features.py - Handle both encoded (bytes/dict) and decoded (nibabel) Nifti cells - Update url_preparator.py for Nifti URL signing - Update rows.py to prevent truncation of Nifti columns - Update rows_utils.py for multithreaded Nifti uploads - Add test fixtures with minimal 2x2x2 NIfTI test file Closes #1 (Nifti Support for Neuroimaging Datasets)
- Use hasattr(value, 'to_bytes') instead of isinstance check to support Nifti1Image, Nifti2Image, and other nibabel types - Preserve original file extension (.nii vs .nii.gz) - Remove unused nibabel import
Regenerate all service and job lockfiles to pull in datasets 4.4.1 which includes the Nifti feature type. This fixes the CI failures where services couldn't import Nifti from datasets. Updated lockfiles: - libs/libapi/poetry.lock - services/admin/poetry.lock - services/api/poetry.lock - services/rows/poetry.lock - services/search/poetry.lock - services/sse-api/poetry.lock - services/webhook/poetry.lock - services/worker/poetry.lock - jobs/cache_maintenance/poetry.lock - jobs/mongodb_migration/poetry.lock
258d0cd to
e292190
Compare
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.
Summary
This PR adds support for NIfTI (.nii, .nii.gz) neuroimaging files in the Dataset Viewer, enabling viewing of brain imaging datasets such as BIDS-formatted neuroimaging studies.
Changes:
datasetsdependency from 4.1.1 to ^4.4.1 (includes native Nifti type)nibabel ^5.0.0dependency for NIfTI file handlingFiles Modified
libs/libcommon/pyproject.tomllibs/libcommon/src/libcommon/viewer_utils/features.pylibs/libcommon/src/libcommon/viewer_utils/asset.pylibs/libcommon/src/libcommon/url_preparator.pylibs/libcommon/src/libcommon/viewer_utils/rows.pylibs/libapi/src/libapi/rows_utils.pylibs/libcommon/tests/Test Plan
test_get_cell_value_value[nifti-True/False],test_to_features_list[nifti])Affected Dataset
This fixes the Dataset Viewer for: https://huggingface.co/datasets/hugging-science/arc-aphasia-bids
Closes #3272