fMRI visualization in python IDE

Dear community,

we are currently working with fMRI data using python code for the analysis. For this reason, we would like to display the data within the python environment during intermediary analysis-steps (ideally displayed with the three classic orientations as well as scrubbing through time with a slider). Although packages like MRIcoGL and fsleyes make this possible, I have not found an elegant way to call these programs directly from the IDE (spyder, pycharm or jupyter). Thus, I would like to ask you whether there is an elegant way to directly load data (numpy or nilearn or nibabel) into these image viewers or whether there is a nice python package for viewing imaging data. Until now, I have just found the package vini, but vini was dependent on old versions of pyqt5 etc…

Thank you very much for your help!
Best,
Christian

1 Like

fsleyes is a Python application, so it should work very smoothly with nibabel. I haven’t tried to use it much, myself, so I can’t be more specific…

1 Like

you might be interested in mrivis: GitHub - raamana/mrivis: medical image visualization library and development toolkit

1 Like

In case it helps, you can get interactive viewers with Nilearn in jupyter.
Best,
Bertrand

Thank you very much for the suggestions. Unfortunately, I have to work with Windows so fsleyes does not work without WSL.
@bthirion: Thanks! Until now, I haven’t found any Nilearn solution for interactively depicting 4d fMRI data. Is there a good solution?

Not for 4D data, sorry !
Bertrand

The NiiVue and nilearn teams are working together to create ipyniivue that will allow you to have interactive visualization in your jupyter notebooks. It may not be quite ready for prime time, but if you want to beta test it, I am sure they will appreciate any feedback. It does allow you to look at 4D fMRI timeseries (click for a web demo). Indeed, OpenNeuro uses it to visualize 4D time series.

It’s very simple, but nibabel does have a built-in viewer that builds on matplotlib.

img = nb.load(...)
img.orthoview().show()