Skip to content

Improve mne.Report.add_ica with ica.plot_sources #13265

Closed

Description

@sappelhoff

Describe the new feature or enhancement

Adding an ICA object to a report is a versatile and convenient method to screen data quality.

One aspect that I often find missing from the overview is a plot of the source timecourses, which can be visualized via:

I propose that we add an option to add an option to .add_ica to also plot the sources.

Describe your proposed implementation

In practice, my proposal would add a subsection to the ICA section called "sources".

It would consist of a "standard timecourses plot" like in the screenshot below:


Image


This plot would be interactive, and the arrow keys would allow to scroll

  • left / right (in time)
  • up / down (through sources)

The parameter that controls whether or not sources are plotted would allow to control:

  • how much overall time to show (defaults to not too much)
  • from when to when to show data (interacting with how much time overall to show)
  • how many sources to show per "scroll through"
  • how much time to show per "scroll through"
  • which sources to show (defaults to all, but can take indices)

Describe possible alternatives

The sources could be added to the Report in a non-interactive way.

Additional context

No response

Activity

  1. drammock commented on May 27, 2025

    @drammock
    Member

    +1, I've missed having this feature recently

  2. Aniketsy commented on Feb 21, 2026

    @Aniketsy
    Contributor

    @drammock hi, if there hasn’t been any progress on this yet, would it be okay if I take a look and work on it?

  3. sappelhoff commented on Apr 7, 2026

    @sappelhoff
    MemberAuthor

    cc @Randomidous looks like this has now landed in mne :)

    thanks @Aniketsy

  4. LeonardoMelloni commented on May 7, 2026

    @LeonardoMelloni

    Hello!
    I'm trying the feature.

    Is it only non-interactive?

    This is the code I'm using

    report.add_ica(
                    ica = ica, 
                    title = f"ICA object (concatenated runs)", 
                    inst = mne.io.read_raw_fif(preproc_path / f"{subject_id}_ses-{session_id}_task-rest_run-concatraw_meg_filt.fif", preload=True), 
                    # # # # # inst = None,
                    picks= range(min(50, ica.n_components_)),
                    ecg_evoked=None, eog_evoked=None, ecg_scores=None, eog_scores=None, 
                    n_jobs=njobs,
                    tags=('ica', 'run-concat', now, script_name), 
                    replace=False, 
                    plot_sources=True
                    )
    
  5. drammock commented on May 7, 2026

    @drammock
    Member

    I'm trying the feature. Is it only non-interactive?

    Reports are static (not interactive). In some cases we simulate interactivity by automatically take several snapshots of plotted data along a time dimension, and add a slider so you can "scroll" through them, but in such cases we don't include all time points; it's just meant to give an idea if the data look OK.

  6. LeonardoMelloni commented on May 7, 2026

    @LeonardoMelloni

    Thanks for the reply and the explanation.

    My issue here is that I have more than 20 Independent Components, but for the moment I can just have a look to the first 20s of the first 20 ICs. This is why for the moment I have to use a .ipynb in parallel to the html report.

    For making batch processing faster, it would be great to be able to scroll through all ICs (and maybe use the same logic as in butterfly in mne.Report.add_raw() to select how many 20s windows to plot).

    I imagine different 20 ICs subplots to span all the ICs present, or having the desired number of 20s snapshots of each IC timecourse piled under its corresponding ica.plot_properties() plot.

    Just some ideas for improvement, as I am intensively using reports and this is the only feature I am missing (as proposed by @sappelhoff in the opening).

    Thanks guys!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions