Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify ica.apply include and exclude params #10086

Merged
merged 2 commits into from
Dec 3, 2021

Conversation

sappelhoff
Copy link
Member

That's how I understand it (and the code looks like it in the source and when running it) ... so I thought I'd add this to the docstring to clear things up.

The relevant things happen here:

def _pick_sources(self, data, include, exclude, n_pca_components):
"""Aux function."""
if n_pca_components is None:
n_pca_components = self.n_pca_components
data = self._pre_whiten(data)
exclude = self._check_exclude(exclude)

where _check_exclude does this (either union of ica.exclude and exclude, or just ica.exclude, if exclude is "n/a"):

def _check_exclude(self, exclude):
if exclude is None:
return list(set(self.exclude))
else:
# Allow both self.exclude and exclude to be array-like:
return list(set(self.exclude).union(set(exclude)))

include is handled a few lines below in _pick_sources:

sel_keep = np.arange(self.n_components_)
if include not in (None, []):
sel_keep = np.unique(include)
elif exclude not in (None, []):
sel_keep = np.setdiff1d(np.arange(self.n_components_), exclude)

i.e., all are included if None ... else the specific selection specified ... and then idxs are removed from it using exclude as previously triaged

mne/preprocessing/ica.py Outdated Show resolved Hide resolved
mne/preprocessing/ica.py Outdated Show resolved Hide resolved
@drammock drammock merged commit d7202b4 into mne-tools:main Dec 3, 2021
@sappelhoff sappelhoff deleted the doc/ica/exclude branch December 3, 2021 21:12
larsoner added a commit to GuillaumeFavelier/mne-python that referenced this pull request Dec 6, 2021
* upstream/main:
  Use fixes._compare_version for version checks everywhere (mne-tools#10091)
  Fast annotation from mask (mne-tools#10089)
  fix trace offsets in butterfly mode (mne-tools#10087)
  fix plot_compare_evokeds topo legend axes placement (mne-tools#9927)
  doc: clarify ica.apply include and exclude params (mne-tools#10086)
  MRG: Make y a required parameter in CSP.fit_transform() (mne-tools#10084)
  Add scrollbar to report tag dropdown menu (mne-tools#10082)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants