Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mne/preprocessing/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,7 @@ def plot_sources(
picks=None,
start=None,
stop=None,
n_channels=None,
title=None,
show=True,
block=False,
Expand All @@ -2600,6 +2601,7 @@ def plot_sources(
picks=picks,
start=start,
stop=stop,
n_channels=n_channels,
title=title,
show=show,
block=block,
Expand Down
12 changes: 10 additions & 2 deletions mne/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,10 +2058,12 @@ def _add_ica_components(self, *, ica, picks, image_format, section, tags, replac
)

def _add_ica_sources(
self, *, ica, inst, picks, image_format, section, tags, replace
self, *, ica, inst, picks, n_channels, image_format, section, tags, replace
):
with use_browser_backend("matplotlib"):
fig = ica.plot_sources(inst=inst, picks=picks, show=False)
fig = ica.plot_sources(
inst=inst, picks=picks, n_channels=n_channels, show=False
)
self._add_figure(
fig=fig,
title="Sources",
Expand All @@ -2079,6 +2081,7 @@ def _add_ica(
ica,
inst,
picks,
n_channels,
ecg_evoked,
eog_evoked,
ecg_scores,
Expand Down Expand Up @@ -2234,6 +2237,7 @@ def _add_ica(
ica=ica,
inst=inst,
picks=picks,
n_channels=n_channels,
image_format=image_format,
section=section,
tags=tags,
Expand All @@ -2248,6 +2252,7 @@ def add_ica(
*,
inst,
picks=None,
n_channels=None,
ecg_evoked=None,
eog_evoked=None,
ecg_scores=None,
Expand All @@ -2271,6 +2276,8 @@ def add_ica(
``None``.
%(picks_ica)s This only affects the behavior of the component
topography and properties plots.
n_channels : int | None
The number of ICA components to plot. If None, defaults to 20.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this too, etc.

ecg_evoked, eog_evoked : path-line | mne.Evoked | None
Evoked signal based on ECG and EOG epochs, respectively. If passed,
will be used to visualize the effects of artifact rejection.
Expand Down Expand Up @@ -2298,6 +2305,7 @@ def add_ica(
ica=ica,
inst=inst,
picks=picks,
n_channels=n_channels,
ecg_evoked=ecg_evoked,
eog_evoked=eog_evoked,
ecg_scores=ecg_scores,
Expand Down
10 changes: 9 additions & 1 deletion mne/viz/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def plot_ica_sources(
picks=None,
start=None,
stop=None,
n_channels=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
n_channels=None,
n_components=20,

title=None,
show=True,
block=False,
Expand Down Expand Up @@ -70,6 +71,7 @@ def plot_ica_sources(
inst : instance of Raw, Epochs or Evoked
The object to plot the sources from.
%(picks_ica)s
: int | None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cruft?

start, stop : float | int | None
If ``inst`` is a `~mne.io.Raw` or an `~mne.Evoked` object, the first and
last time point (in seconds) of the data to plot. If ``inst`` is a
Expand All @@ -78,6 +80,8 @@ def plot_ica_sources(
`~mne.Evoked`, ``None`` refers to the beginning and end of the evoked
signal. If ``inst`` is an `~mne.Epochs` object, specifies the index of
the first and last epoch to show.
n_channels : int | None
The number of ICA components to plot. If None, defaults to 20.
Comment on lines +83 to +84

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think n_components might be a better name... they are stored as channels in the object but users will think in terms of components. Also needs versionadded.

Suggested change
n_channels : int | None
The number of ICA components to plot. If None, defaults to 20.
n_components : int
Maximum number of ICA components to plot. Defaults to 20.
.. versionadded:: 1.13

title : str | None
The window title. If None a default is provided.
show : bool
Expand Down Expand Up @@ -142,6 +146,7 @@ def plot_ica_sources(
exclude,
start=start,
stop=stop,
n_channels=n_channels,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'd update this everywhere

Suggested change
n_channels=n_channels,
n_components=n_components,

show=show,
title=title,
block=block,
Expand Down Expand Up @@ -1292,6 +1297,7 @@ def _plot_sources(
psd_args,
theme=None,
overview_mode=None,
n_channels=20,
splash=True,
):
"""Plot the ICA components as a RawArray or EpochsArray."""
Expand Down Expand Up @@ -1348,7 +1354,9 @@ def _plot_sources(
data = np.append(data, eog_ecg_data, axis=0)
picks = np.concatenate((picks, ica.n_components_ + np.arange(len(extra_picks))))
ch_order = np.arange(len(picks))
n_channels = min([20, len(picks)])
if n_channels is None:
n_channels = 20
n_channels = min([n_channels, len(picks)])
ch_names_picked = [ch_names[x] for x in picks]

# create info
Expand Down