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

ica.plot_properties ignores reject dict #5815

Closed
agramfort opened this issue Jan 4, 2019 · 26 comments
Closed

ica.plot_properties ignores reject dict #5815

agramfort opened this issue Jan 4, 2019 · 26 comments

Comments

@agramfort
Copy link
Member

when you plot component properties you can specific the reject param used in fit.

reject should be set as attribute of ica object and be used with ica.plot_properties

cc @pierreablin @Okamille @jona-sassenhagen

@jona-sassenhagen
Copy link
Contributor

@mmagnuski

@mmagnuski
Copy link
Member

Ok, so we should add ica.reject (or something more verbose?) and then use this parameter automatically in plot_properties, right? Some questions then:

  • Would you prefer that the data segments be rejected without any sign automatically or should the blanks be visible (nans in epoch's image)?
  • Would it be useful to add a parameter to plot_properties that allows to ignore the ica.reject? In some cases you may want to investigate whether some epochs are worth rejecting (not included in further analyses) although they were not used in ica fitting.
  • Or should it not be automatic and rather a reject kwarg should be added to plot_properties? It would be explicit to do ica.plot_properties(..., reject=True).
  • Should something similar be done in the ica sources plotter? For example 'ignore' annotations showing which data segments were not used to fit ica.

@jona-sassenhagen
Copy link
Contributor

Would you prefer that the data segments be rejected without any sign automatically or should the blanks be visible (nans in epoch's image)?

Yes, maybe reject could default to None or False and the image could then not show the dropped epochs at all? And reject=True means it pulls reject from the ICA object.

I'm not sure how well NaNs play with the smoothing.

Would it be useful to add a parameter to plot_properties that allows to ignore the ica.reject? In some cases you may want to investigate whether some epochs are worth rejecting (not included in further analyses) although they were not used in ica fitting.

ica.plot_properties(..., reject=False, ...)?

@mmagnuski
Copy link
Member

Yes, maybe reject could default to None or False and the image could then not show the dropped epochs at all? And reject=True means it pulls reject from the ICA object.

with False it would not drop anything as I imagine, so the question about showing which data parts were rejected concerns reject=True.

I'm not sure how well NaNs play with the smoothing.

Right, that won't be good, the NaNs would spread like a disease. It would be possible to reject the segments, then smooth and then add rows with nans to the matrix. I think it might be useful to see what was rejected, but then some people would surely prefer not to, so that might require additional kwarg, so maybe we should think about it later?

ica.plot_properties(..., reject=False, ...)?

Yes, that's what I suggested in the next point (but didn't go back to the previous one to edit for clarity :) ).

@jasmainak
Copy link
Member

If you want to have a parameter, I would suggest not changing the semantics. The param reject has always been a dictionary, so to me changing to be boolean in some parts of the code base is going to be confusing for many users. Why not simply use a rejection dictionary without saving it as an attribute in ica.reject? Is there a strong argument for believing that the rejection dictionary used during the fit is going to be valid for any other epochs for which you do ica.plot_properties ?

@mmagnuski
Copy link
Member

@jasmainak Yes, that would be simpler. A middle-ground is to to have ica save reject dict and reject in .plot_properties() accepting a boolean or a dict.

@mmagnuski
Copy link
Member

But I'd give my vote to just .plot_properties(..., reject=some_dict).

@agramfort
Copy link
Member Author

agramfort commented Jan 5, 2019 via email

@mmagnuski
Copy link
Member

if reject was used during fit it must be used by default in
plot_poperties

@agramfort This is the point I am not sure of: at least when the dropping of segments/epochs would be silent (nothing in the visual output suggesting that something was removed). That might be surprising, especially for users accustomed to how things used to work in mne. Using ica.plot_properties(..., reject=ica.reject) or ica.plot_properties(..., reject=True) would be more explicit.

@jona-sassenhagen
Copy link
Contributor

My main point is, I'd consider it very dangerous if plot_properties displays activity as if it had no artefacts. I.e., if you end up dropping all high-variance/high-amplitude epochs, the EOG ICs will look flat. So you will misidentify them.

I.e., I am very skeptical of dropping by default.

@mmagnuski
Copy link
Member

good point, I agree with Jona.

@agramfort
Copy link
Member Author

agramfort commented Jan 5, 2019 via email

@mmagnuski
Copy link
Member

Yes, I am less against making this the default when it is clearly visible that something was dropped.

@agramfort
Copy link
Member Author

agramfort commented Jan 6, 2019 via email

@Okamille
Copy link
Contributor

Okamille commented Jan 6, 2019

Yep, I'll work on it tommorow 😄

@Okamille
Copy link
Contributor

Okamille commented Jan 8, 2019

Maybe we should consider using a reject_args instead of a reject, and include inside 'decim', 'reject', 'flat', 'tstep' and maybe 'picks' i.e channels to be used ?
That is what is used in the ICA object to perform the rejection, and they are not stored as members of the class afterward, so either we store these to perform the 'auto' rejection, or we ask the user to supply these parameters everytime.

@agramfort
Copy link
Member Author

@Okamille keep is simple and stupid (KISS) and think about YAGNI (https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it). In other words let's add an option when it appears necessary as it is with the reject values for your experiment. I would address the comments you have now ASAP show how it addresses the issue to convince us and move on !

@Okamille
Copy link
Contributor

epochs_dropped
What do you think about this way of conveying the info ?

@agramfort
Copy link
Member Author

I would change the texts. ylabel should be:

Variance (AU)
and title
Dropped segments: 7.4%

I would have left the red dot at their original values as like this it's hard to know if the reject threshold is conservative or not. @dengemann or @jona-sassenhagen or @mmagnuski any option?

@mmagnuski
Copy link
Member

I agree, having red dots at zero doesn't tell me much - it may almost suggest that these epochs/segments were flat.
Also - if we are showing rejected segments with red dots in variance plot I would also mark them in the epochs/segments image. The best option to do it is in my opinion:

  • first calculate the image as previously
  • then add rows filled with np.nan where removed epochs were originally

so it shouldn't be much of a problem, because you perform similar inserting for scatter. In case you you wanted to plot image nan elements in a different color than the default here is a nice example.

@Okamille
Copy link
Contributor

Okamille commented Jan 10, 2019

bugfixed

So what do you think of this proposal ? Rejected epochs in image are white by default, I can use your tip @mmagnuski if you want another color :)

@jona-sassenhagen
Copy link
Contributor

jona-sassenhagen commented Jan 10, 2019 via email

@Okamille
Copy link
Contributor

No, it is computed from the "clean" epochs

@mmagnuski
Copy link
Member

All looks good. I have only one question:
the variance plot suggests that we have altogether more than 50 segments, and the last segment is rejected. This can't be seen in the image plot: it suggests that there are not more than 50 segments and only 3 are removed (4 in variance plot).

@Okamille
Copy link
Contributor

Oh yes, it's weird, I may have made some mistakes when adding the NaNs, I'll look into it

@jasmainak
Copy link
Member

I would also suggest having consistent color between the subplots (red?) for bad epochs. Maybe work with facecolor and edgecolor to make it work?

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

No branches or pull requests

5 participants