Skip to content

Add option to display brain images in neurological orientation #43

@surchs

Description

@surchs

Human brain MRI volumes are generally organized in the R-A-S orientation in voxel space, i.e. moving along the volume axes moves through the "real world" image in Right-Left, Anterior-Posterior, Superior-Inferior directions respectively. And if the data were not oriented as expected, nilearn offers a way to try to get them there.

To display slices from these volumes in the expected display conventions (that differ somewhat between radiologists and neurologists): , we need to flip them by 90 degrees. Here is a short example to show this:

import numpy as np
from nilearn import datasets, plotting
import nibabel as nib
import matplotlib.pyplot as plt

# Get the commonly used MNI152 brain template
mni152 = datasets.fetch_icbm152_2009()
print(mni152.description.decode())

# Load the Nibabel image object
# And the volume as a numpy array
mni152_t1_img = nib.load(mni152.t1)
mni152_t1 = mni152_t1_img.get_fdata()

# Check that the data are in RAS orientation
nib.aff2axcodes(mni152_t1_img.affine)

# Display a slice
a_slice = mni152_t1[:, :, 90]
fig, axes = plt.subplots(1, 2)
axes[0].imshow(a_slice, cmap="gray")
axes[1].imshow(np.rot90(a_slice), cmap="gray")

This looks like so:
image

This "flip the slice by 90 degrees before displaying" is also what nilearn does in it's plotting tools:

# Note that nilearn displays slice indices in MNI/real-world coordinates
plotting.plot_anat(mni152_t1_img)

image

Since we aren't displaying static images of single slices, I think it'd be best to allow the user to ask us to flip the slices before displaying on the dash-slicer side of things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions