ME-ICA / tedana

TE-dependent analysis of multi-echo fMRI
https://tedana.readthedocs.io
GNU Lesser General Public License v2.1
158 stars 94 forks source link

Display of IC components has a grey outline in report #1095

Closed dc307 closed 1 month ago

dc307 commented 1 month ago

Summary

Following on from a post in neurostars. I used fmriprep, and then tedana with my own mask. The IC components in the output figures have a grey, brainshaped outline. The adaptive mask plot looks fine. It was suggested on neurostars that this may be minor bug in Nilearn’s plot_stat_map function. The issues is not present in 23.0.2, but is present in 24.0.1. Components are also different between versions, but that may be down to something else. tedana_difference

adaptive_mask

Additional Detail

Next Steps

tsalo commented 1 month ago

I think this is more a concern for nilearn than tedana.

EDIT: Of course that assumes that we're calling the Nilearn plotting function properly. There may be ways for us to improve things on our end. I just think that the gray area is probably a bug on Nilearn's side.

handwerkerd commented 1 month ago

I'm bump discussion from https://neurostars.org/t/ica-components-have-grey-shadow-around-each-brain-after-upgrade-and-different-components/29396/5 to this issue.

Particularly if the images in desc-ICA_components.nii.gz look fine in fsleyes, I agree with @tsalo that we're giving nilearn exactly what we're supposed to give it. Can you open an anatomical underlay and those component maps in fsleyes to confirm the image is fine and this is just a display issue?

I looked through the nilearn code a bit. As far as I've gotten, it consistently passes bg_img=None through functions and adds an overlay without an underlay (here: https://github.com/nilearn/nilearn/blob/d2ddfb9a2d1fbf641574d42f3fb3fd7f8375f733/nilearn/plotting/img_plotting.py#L275 ). My best guess is that something unindented can happen when it displays an overlay without specifying any underlay.

@dc307 Could you share a single dataset with this problem (and the command you used to run tedana) so that we can try to replicate the issue? If it is a nilearn issue, it would be useful to confirm and let them know. @tsalo any nilearn developers you know who are worth tagging in this thread?

tsalo commented 1 month ago

@tsalo any nilearn developers you know who are worth tagging in this thread?

We can ping @remi-gau, but I think we should just cobble together a minimal, reproducible script (preferably using Nilearn built-in data) and open an issue.

Remi-Gau commented 1 month ago

What nilearn version is there in 24.0.1?

Remi-Gau commented 1 month ago

Ok just checked and 24.0.1 restricted to the very latest versions of nilearn.

Any difference between using nilearn 0.10.3 and 0.10.4 because the latter fixed a whole bunch of bugs.

A minimal reproducible example would definitely help in case so we could git bisect this to see where the regression happened.

handwerkerd commented 1 month ago

OK. The next step is definitely to get a minimal reproduction. It sounds like both @tsalo and @dc307 have seen this issue. What version of nilearn are you both using? I think we originally added in nilearn visualizations using v0.10.3 and I have 0.10.3 in my environment. I'm wondering if this is coming up now because of some change in 0.10.4.

@dc307, the nilearn version you ran tedana with is listed in the Info section near the bottom of the report and it's also in the saved dataset_description.json file.

dc307 commented 1 month ago

I am not sure of the best way to share the dataset (its almost 4GB). If there is a way just give me a heads up and I will share it. In any case, here is the info - looks like nilearn 0.10.3.

The command I used was: tedana -d sub-p1_task-1_echo-1_desc-preproc_bold.nii.gz sub-p1_task-1_echo-2_desc-preproc_bold.nii.gz sub-p1_task-1_echo-3_desc-preproc_bold.nii.gz sub-p1_task-1_echo-4_desc-preproc_bold.nii.gz sub-p1_task-1_echo-5_desc-preproc_bold.nii.gz -e 15 36.02 57.04 78.06 99.08 --prefix sub-p1-task-1 --mask sub-p1_task-1_desc-brain_mask.nii.gz

System: Darwin
Node: psy019942.psych.susx.ac.uk
Release: 22.6.0
System version: Darwin Kernel Version 22.6.0: Mon Apr 22 20:54:28 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_X86_64
Machine: x86_64
Processor: i386
Python: 3.8.18 (default, Sep 11 2023, 08:17:33) [Clang 14.0.6 ]
Tedana version: 24.0.1
Other library versions: {'bokeh': '3.1.1', 'mapca': '0.0.5', 'matplotlib': '3.7.5', 'nibabel': '5.2.1', 'nilearn': '0.10.3', 'numpy': '1.24.3', 'pandas': '2.0.3', 'scikit-learn': '1.3.0', 'scipy': '1.10.1', 'threadpoolctl': '2.2.0'}
dc307 commented 1 month ago

UPDATES: upgrading to 0.10.4 does not solve the issue. It does make the font size of the coordinates and the right and left indicators bigger, but the grey background is still present. Running tedana 24 but with with the old static_figures.py generates images without the grey background (of course does not generate the adaptive mask plot etc). Running tedana without supplying my own mask does not solve the problem. So, it is likely an issue with nilearn, and not the mask.

tsalo commented 1 month ago

You'll want to try to reproduce the problem using nilearn's data so that the nilearn devs can check it on their own systems. If they can't reproduce it, they won't be able to fix it. If you can't reproduce it with the data in nilearn.datasets, then you could index a single volume from the 4D component maps file from tedana and share it on Box, Drive, etc. before opening the Nilearn issue.

handwerkerd commented 1 month ago

I'm realizing that you just need to share desc-ICA_components.nii.gz or even a single volume from that file so that other's here can try to replicate. That might still be a big file, but hopefully it's small enough that you have a practical way to share.

dc307 commented 1 month ago

https://sussex.box.com/s/lyf64spon4sdp9ndewjsnxvusgnqls2y

Ok, this link should take you to the des-ICA_components.nii.gz file. Just let me know if there are problems downloading and I will look for another way.

handwerkerd commented 1 month ago

I replicated the issue @dc307 saw with a snippet of code outside of tedana and opened an issue with https://github.com/nilearn/nilearn/issues/4417

tsalo commented 1 month ago

Based on Bertrand's response, can someone try setting resampling_interpolation='nearest' in the plot_stat_map call? I wonder if that would fix it.