/niftiview

View volumetric images in Python 🧠

Primary LanguagePythonMIT LicenseMIT

niftiview_logo_transparent_small

The easiest way to view volumetric images in Python 👩‍💻 Install it via pip install niftiview!

niftiview stands behind

  • NiftiView, the viewer app with the cutest desktop icon 🧠 Download it here!
  • NiftiWidget, a widget for interactive viewing in Jupyter 👩‍💻🧠 Install it via pip install niftiwidget!

Usage 💡

Single images can be shown via NiftiImage

from niftiview import TEMPLATES, NiftiImage

nii = NiftiImage(TEMPLATES['ch2'])
# nii = NiftiImage('/path/to/your/nifti.nii.gz')
im = nii.get_image()
im.show()

niftiimage

NiftiImageGrid can display multiple images in a nice grid layout

from niftiview import TEMPLATES, NiftiImageGrid

niigrid = NiftiImageGrid([TEMPLATES['ch2'], TEMPLATES['T1']])
# niigrid = NiftiImageGrid(['/path/to/your/nifti1.nii.gz', 
#                           '/path/to/your/nifti2.nii.gz'])
im = niigrid.get_image(layout='sagittal++', nrows=1)
im.show()

niftigrid

Behind the scenes, niftiview uses three main classes that build on each other

  • NiftiCore: Puts image slices of the 3D image in a 2D numpy.ndarray...
  • NiftiImage: ...applies a colormap to the array, converts it to a PIL.Image and adds overlays...
  • NiftiImageGrid: ...puts the images in a grid

To fully understand how to use niftiview, study the example notebooks 🧑‍🏫

niftiview-cli 🖥️

pip install niftiview also installs the command line utility that given filepath(s) or a filepattern...

niftiview-cli -i /path/to/niftis/*.nii.gz -o /path/to/output/folder --gif

...saves PNGs or GIFs. To showcase its versatility, here is a compilation of created GIFs

niceviews

Explore all the available options by running niftiview-cli --help

P.S. If you're interested in creating 🧠 tissue maps like the ones shown at the end of the GIF, check out deepmriprep!