Skip to content

WIP, ENH: Be verbose if fitting ICA on rank-deficient data - #8313

Closed
hoechenberger wants to merge 1 commit into
mne-tools:masterfrom
hoechenberger:ica-rank
Closed

hoechenberger wants to merge 1 commit into
mne-tools:masterfrom
hoechenberger:ica-rank

Conversation

@hoechenberger

@hoechenberger hoechenberger commented Sep 28, 2020 •

Copy link
Copy Markdown
Member

@agramfort and I encountered a weird, seemingly inexplicable issue when using ICA for EOG and ECG artifact correction. Turned out – the only reason that lead us to "waste" several hours was simply that the input data was rank-deficient, because it had 3 SSP projection vectors in .info.

I have therefore opted to enhance ICA.fit() such that it would (hopefully) detect such cases in the future, and voice its concerns or even fail hard.

I have added a check_rank=True kwarg to ICA.fit(). If True (default), the user will get an extensive warning if the rank of the data is expected to be NOT full even after the PCA step. The error message contains concrete directions on what to do.

My idea is that this message, for now, remains a warning, and will change to an Exception with 0.23 the latest. In fact, I'd prefer if we immediately made it an exception, because I think we should fail hard in this case; but I assume other devs would be against this, therefore we should probably do a deprecation cycle.

If the user passes check_rank=False, we will still produce a warning, but it won't be as extensive. My reasoning behind this is that it helps ensure that one doesn't accidentally leave check_rank =False in the code after testing something and forgetting about it. Once check_rank=True raises an exception, the behavior difference between check_rank=True and check_rank=False will become more clear.

Todo:

  • Amend ICA tutorial
  • Amend changelog

@agramfort and I encountered a weird, seemingly inexplicable issue
when using ICA for EOG and ECG artifact correction. Turned out – the
only reason that lead us to "waste" several hours was simply that the
input data was rank-deficient, because it had 3 SSP projection vectors
in `.info`.

I have therefore opted to enhance `ICA.fit()` such that it would
(hopefully) detect such cases in the future, and voice its concerns
or even fail hard.

I have added a `check_rank=True` kwarg to `ICA.fit()`. If `True`
(default), the user will get an extensive warning if the rank of the
data is expected to be NOT full even after the PCA step. The error
message will contain concrete directions what to do.

My idea is that this message, for now, remains a warning, and will
change to an `Exception` with 0.23 the latest. In fact, I'd prefer if
we immediately made it an exception, because I think we should
fail hard in this case; but I assume other devs would be against this,
therefore we should probably do a deprecation cycle.

If the user passes `check_rank=False`, we will still produce a warning,
but it won't be as extensive. My idea was just such that one doesn't
accidentally leave `check_warn=False` in the code after testing
something and forgetting about it. Once `check_rank=True` raises an
exception, the behavior difference between `check_rank=True` and
`check_rank=False` will become more clear.
@hoechenberger hoechenberger changed the title ENH: Be verbose if fitting ICA on rank-deficient data WIP, ENH: Be verbose if fitting ICA on rank-deficient data Sep 28, 2020
@hoechenberger
hoechenberger requested a review from cbrnr September 28, 2020 15:03
@hoechenberger

Copy link
Copy Markdown
Member Author

Voice call with @agramfort:

  • don't introduce a new parameter to ICA.fit, but offer more options for ICA.max_pca_components, e.g. 'rank' or 'auto' instead
  • maybe deprecate max_pca_components=None

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.

1 participant