Skip to content

Conversation

@larsoner
Copy link
Member

Closes #5928.

@britta-wstnr can you see if the fix looks reasonable and it fixes your problem?

@larsoner larsoner added this to the 0.18 milestone Feb 13, 2019
@larsoner
Copy link
Member Author

Failures are unrelated and will be fixed by #5932

Copy link
Member

@britta-wstnr britta-wstnr left a comment

Choose a reason for hiding this comment

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

Thanks @larsoner for getting at this so quickly!
Apart from my comments regarding the rank > len(Cm) case it looks good to me.
@MadsJensen , would you mind to have a quick look whether this fixes your problems?

# first eigenvalue that falls outside the signal subspace or the
# loading factor used during regularization, whichever is largest.
if rank >= len(Cm):
if rank > len(Cm):
Copy link
Member

Choose a reason for hiding this comment

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

This would now only come in play if the user manually specified a rank higher than the cov matrix dimensions. Can we see such a thing happening / being useful?

Copy link
Member

Choose a reason for hiding this comment

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

thoughts, @sarangnemo?

Copy link
Contributor

@wmvanvliet wmvanvliet Feb 14, 2019

Choose a reason for hiding this comment

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

indeed, I'm confused. What does a rank higher than the data dimensionality mean?

if rank > len(Cm):
# Covariance matrix is full rank, no noise subspace!
# Use the loading factor as noise ceiling.
if loading_factor == 0:
Copy link
Member

Choose a reason for hiding this comment

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

The error message should be changed. First, it suggests that it is not possible to compute a noise level with full-rank cov matrix (also see comment in code above). Second, now this would only be reached if the user was specifying the rank manually already, telling them to do the same thing.
If we want to keep this case I suggest something like:
'Cannot compute noise level for NAI computation since specified rank (%s) is higher than covariance matrix dimensions (%s) and no regularization is specified. Try changing rank to equal the covariance matrix dimensions.' % (rank, len(Cm))

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems reasonable to me. @wmvanvliet this is your code I think, thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

It works on the data now.

Copy link
Contributor

Choose a reason for hiding this comment

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

how can the rank of the data be higher than the number of dimensions of the data?

Copy link
Member

Choose a reason for hiding this comment

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

Well, good question. I think it is now a remainder of the code how it was before ( if rank >= len(Cm) ). As I mentioned above, I do not see an immediate use case for it - except the user specifying a rank manually, maybe in a combination with dropping channels during the filter computation.
Do we all agree then that the if statement can go and we go back to how the noise was computed before for any case? In our experience that worked fine, and is in accordance with what Fieldtrip does, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay with me

@agramfort
Copy link
Member

errors are unrelated. Merging now.

thanks @larsoner
and @MadsJensen @britta-wstnr for reporting the issue and testing

@agramfort agramfort merged commit fd99e1b into mne-tools:master Feb 14, 2019
@britta-wstnr
Copy link
Member

Did we want to make the error message more informative (see suggestion in review)?

@agramfort
Copy link
Member

agramfort commented Feb 14, 2019 via email

@britta-wstnr
Copy link
Member

Thinking about it a bit more, I wonder whether this actually should be an error: if the user specifies a rank, but the actual cov matrix dimensions are smaller than the specified rank, shouldn't that just be corrected, maybe throwing a warning?

@agramfort
Copy link
Member

agramfort commented Feb 14, 2019 via email

@britta-wstnr
Copy link
Member

Not if we would correct the rank to equal the dimensions, i.e., correct it down (and inform the user), no?

@agramfort
Copy link
Member

agramfort commented Feb 14, 2019 via email

@larsoner larsoner deleted the nai-noproj branch February 14, 2019 12:31
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.

[BUG] Computation of noise in NAI beamformer

5 participants