brainhack-boston / brainhack-boston.github.io

Brainhack Boston
https://brainhack-boston.github.io
Apache License 2.0
1 stars 22 forks source link

Add support for NIfTI-Zarr file type in neuroglancer #50

Open MikeSchutzman opened 4 months ago

MikeSchutzman commented 4 months ago

See specs here https://github.com/lincbrain/linc-docs/pull/6/commits/dd3411c15643df2662a26dee752a394dfc282872?short_path=4006ba0#diff-4006ba03245d22f869fb9a211dd809ff3a8c0a627e3a66e2c0791478371fe4cc

balbasty commented 4 months ago

Thanks Michael, I am adding a small description here.

Nifti is the standard format for MRI data in neuroimaging research. It is a simple binary format made of a short binary header followed by the raster data stored in Fortran order (that is, "x" is the fastest dimension). Importantly, it stores a spatial transform that allows the data to be displayed in a well defined coordinte space where:

The binary file is generally further gzipped for lossless compression. As a single file format, nifti is not adapted to very large volumes, nor does it allow efficient random access to its voxels.

On the other hand, Zarr, and it microscopy-specific child OME-Zarr split very large arrays across many small chunks that are individually compressed. OME-Zarr further support storing the same volume at multiple dimensions, thereby enabling fast multi-resolution visualization. However, the current specification does not support spatial coordinate transforms, appart from canonical scales and translations.

We've proposed Nifti-Zarr as a lightwait addition to OME-Zarr that stores the binary nifti header within an OME-Zarr directory, thereby supporting the same kind of spatial transforms widely embraced by the neuroimaging community.

Neuroglancer is a web-based viewer for large remote files that supports both OME-Zarr and nifti files. This project aims to add support for the Nifti-Zarr format. This new reader will reuse routines from the Nifti and Zarr readers already present in neuroglancer and apply the correct nifti transform to the zarr array.

balbasty commented 4 months ago

I have uploaded two nifti-zarr files to dandi. They can be accessed and loaded into neuroglancer with these URLs:

  1. This is a link to a neuroglancer visualization that does not know about the nifti metadata
  2. This is a link to a neuroglancer visualization that does know about the nifti metadata

You can see in the second link that:

The second visualization is currently achieved by modifying the layer's transform in the neuroglancer state, but we would like to achieve this natively by loading the file with a niftizarr:// protocol.

@MikeSchutzman