Repository navigation
[MRG] small ICA bug fixes for #5967 - 2nd try - #6246
Conversation
…in ascending order).
…ore_sources to filter sources and targets) to use the raw sfreq rather than the one used for fitting the ica.
…ing to list first.
…e default values to yield the same compos as before
Codecov Report
@@ Coverage Diff @@
## master #6246 +/- ##
=========================================
Coverage ? 89.24%
=========================================
Files ? 416
Lines ? 75418
Branches ? 12597
=========================================
Hits ? 67305
Misses ? 5218
Partials ? 2895 |
|
Did you also check why the unit tests were falling? |
|
Very good, you only have a pep failure:
Fix that and set the title from FIX to MRG please. |
|
|
hm... and why? How to fix this? Is it important? run_ica is not part of the ICA class but in the same file. So how to link to this? Why it does not find the attribute I cannot see. |
You need to link to things where they are documented (implicitly or explicitly) in
The way it is now, we will have broken links in our |
|
Thanks for the explanation. The first one was obvious, sorry ... |
|
@mmagnuski if you use these functions can you take a look? |
| ecg_criterion=0.1, eog_ch=None, | ||
| eog_score_func='pearsonr', | ||
| eog_criterion=0.1, skew_criterion=-1, | ||
| kurt_criterion=-1, var_criterion=0, |
There was a problem hiding this comment.
Why do we change the default criteria here? This would change the behavior of detect_artifacts between versions without any warning.
There was a problem hiding this comment.
Well, my reasoning was that this way we at least actually keep the effect of the default values, because before this PR, [0] would index the lowest score and [-1] the highest, and know it is inverted (i.e. now it is as it is (and used to be) documented).
But you are right, it would be probably good to introduce a warning. Could you point me to a template for a warning about changing the behavior of a function? After all the bug is only in the incompatibility between documentation and code, so someone who knew the code and did not care about the docstring could be surprised ...
There was a problem hiding this comment.
The least surprise from a user perspective would be to keep the old behavior and old defaults, and update the docstring to say what this does.
If our old defaults made no sense, we can have a deprecation cycle where we set them to None for a cycle in the signature, and in 0.18 None does what was done in 0.17 (with a warning that not setting it explicitly will change in 0.19) and then in 0.19 we change the default to something sane.
There was a problem hiding this comment.
I agree with @larsoner, BTW @jeythekey - you should better ask Eric about how to implement deprecations, I never did this so I would have to look around in our codebase, but Eric knows all this off the top of his head.
There was a problem hiding this comment.
So, in principle we would revert this PR and replace it with a warning, that in the next release the function will do what it used to say it would do in the docstring?
Is this really necessary in this case, where the docstring clearly states "Note. This is still experimental and will most likely change over the next releases."?
As it is now, at least the defaults will do the same as before (they were only changed, because of the bug-fix in the code), only when the criteria args used to be set contrary to what would be sensible given the docstring by a user, the behavior will change. So, this should only negatively affect those who dug through the code before, identified the bug and decided to silently adapt their usage instead of reporting the bug.
So, please, one last word by @larsoner: Should I really revert the fix for sorting the compos in descending order and replace the fix by a warning about a future fix?
There was a problem hiding this comment.
No, descending is good, it should be descending, so this is a bug fix. Then:
- change the what's new to state that ascending was changed into descending. I read the "Fix descending sorting" as if it was descending and was changed.
- I am ok with changing the criteria now, otherwise it would be nonsense. I somehow didn't before get that these "criteria" are indices. What do you think @larsoner? In case someone actually uses these we could set these to None and issue a warning.
There was a problem hiding this comment.
In case someone actually uses these we could set these to None and issue a warning.
Even in this case if someone had previously passed values, now the behavior will be changed. I guess since the behavior is wrong and this is a bugfix, we can change the behavior like you say and make it clear in the BUG section that this has been fixed.
@agramfort are you okay with this?
There was a problem hiding this comment.
Even in this case if someone had previously passed values ...
Actually, only in this case ... (because the default values were inverted to retain the old behavior - and they make sense now, I guess, as they did before)
And what do you think about this warning (at the end) I tried to implement (with the wrong warning class, apparently)?
There was a problem hiding this comment.
@larsoner and @mmagnuski should I then just remove the warning? I changed the bug section as you suggested. Because then we should be good to go, or is there anything else, @agramfort ?
There was a problem hiding this comment.
Yes let's remove the warning if it's a bug. Then wait for @agramfort to comment next week to make sure it's reasonable
… in the docstrings of run_ica and detect_artifacts
|
OK, I implemented your suggestion, thanks @mmagnuski. I also made the docstring a little more explicit. To make the |
|
OK, apparently, |
agramfort
left a comment
There was a problem hiding this comment.
@dengemann wrote this I guess. I have no strong feeling. I discover this function :(
It's not present in any example or tutorial so I doubt this is very much used ...
| def _apply_raw(self, raw, include, exclude, n_pca_components, start, stop): | ||
| """Aux method.""" | ||
| _check_preload(raw, "ica.apply") | ||
| exclude = self._check_exclude(exclude) |
There was a problem hiding this comment.
why removing all these calls to _check_exclude?
There was a problem hiding this comment.
... because this function is called in _pick_sources, which is called by all the apply_... funcs. Since _pick_sources does the exclude-relevant work I found it more consistent and future-proof to call _check_exclude there.
|
@mmagnuski or @larsoner merge if you're happy. Travis error is unrelated |
|
I'll let you take a last look and merge if you're happy @mmagnuski |
|
I'm happy, thanks @jeythekey! |
|
@jeythekey we don't have your name to update the mailing for the release. Can you provide us your full name and desired email to amend that? thx. |
|
@GuillaumeFavelier : Johannes Kasper, [email protected] |
Continues/replaces #5968