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

plot_average plots all channels, not only indicated ones #156

Open
skjerns opened this issue Feb 1, 2024 · 3 comments
Open

plot_average plots all channels, not only indicated ones #156

skjerns opened this issue Feb 1, 2024 · 3 comments
Assignees
Labels
question 🙋 Further information is requested

Comments

@skjerns
Copy link

skjerns commented Feb 1, 2024

I'm running the following code

raw = mne.io.read_raw(edf_file, preload=True)
hypno = sleep_utils.read_hypno(hypno_file, verbose=False)
hypno_upsampled = yasa.hypno_upsample_to_data(hypno, sf_hypno=1/30, data=raw)
assert len(raw)//raw.info['sfreq']//30==len(hypno)
chs = ['Fz'] 

sp = yasa.spindles_detect(raw, hypno=hypno_upsampled, ch_names=chs, include=[2,3])
ax = sp.plot_average()

I would expect that in the resulting figure only the channel indicated in chs is plotted. However, all the channels of the raw are plotted. Is that the indention?

PS Once again thanks for the library! Amazing for quickly analyzing a dataset

@raphaelvallat raphaelvallat added the question 🙋 Further information is requested label Feb 3, 2024
@raphaelvallat raphaelvallat self-assigned this Feb 3, 2024
@raphaelvallat
Copy link
Owner

Hi Simon,

ch_names only indicates the channel names, not the channels that should be included in the analysis. Furthermore, ch_names is actually discarded if the input data is a mne.Raw instance, since the channel names can be extracted automatically from the Raw object:

ch_names = data.ch_names # Extract channel names

Therefore, you need to update your code to:

raw.pick(["Fz"])
sp = yasa.spindles_detect(raw, hypno=hypno_upsampled, include=[2,3])
ax = sp.plot_average()

I think that the current documentation of ch_names is somewhat misleading and should be clarified.

Hope this helps!
Raphael

@skjerns
Copy link
Author

skjerns commented Feb 7, 2024

Hi Simon,

ch_names only indicates the channel names, not the channels that should be included in the analysis. Furthermore, ch_names is actually discarded if the input data is a mne.Raw instance, since the channel names can be extracted automatically from the Raw object:

ch_names = data.ch_names # Extract channel names

Therefore, you need to update your code to:

raw.pick(["Fz"])
sp = yasa.spindles_detect(raw, hypno=hypno_upsampled, include=[2,3])
ax = sp.plot_average()

I think that the current documentation of ch_names is somewhat misleading and should be clarified.

Hope this helps! Raphael

Right! Now I understand. Would it be an idea to give a warning/assertion if ch_names is indicated and a raw object is provided?

@raphaelvallat
Copy link
Owner

Yes we probably should — the current implementation is confusing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🙋 Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants