Plotting RGB images in Nilearn

Hello! I was wondering if anyone knows how to plot an RGB image (like a direction-encoded color map from a dmri tensor fit) using nilearn. It would be great to be able to use the overlays, transparency and coordinate system utilities from nilearn plotting to plot these as foreground on a highres anatomical.

These images typically have vector type voxels with rgb values.

Thanks in advance!

1 Like

I don’t recall seeing any usage of this with Nilearn.

Maybe open a feature request on the Nilearn repo so the dev can see if it is within the Nilearn scope.

In any case it will probably need some example data to work with.

Indeed. But I guess that dipy may have this kind of feature.

you are probably right:

Unfortunately DIPY doesn’t have any ability to do coordinate-based plotting in python/matplotlib. DIPY users typically use matplotlib directly, which tends to be a lot of code and can introduce left/right flip issues easily. Pinging @arokem

I can confirm that DIPY does not currently have 2D visualization methods that focus on displaying maps of different outputs of diffusion analysis, and I usually roll my own directly with Matplotlib. It would be nice to be able to take advantage of the sophisticated methods that have been developed within nilearn to align different measurements of the same brain, and that include checks to avoid errors. I wonder how hard it would be to do what @mattcieslak is thinking about within nilearn, as I see that under the hood 2D viz methods are using MPL’s imshow, which automatically creates these RGB visualizations when provided 3D data with 3 or 4 components on the last dimension. But I am not an expert on the nilearn implementation, and only looked at cursorily just now. I think that an issue on the nilearn repo would be a great next step for a discussion on how/whether that could be a way forward.

1 Like

Opened! [ENH] Nilearn plotting of RGB-type images · Issue #4224 · nilearn/nilearn · GitHub