Hi MNE team,
I am new to MNE package and just started playing with the code in Tutorial
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import mne
from mne.datasets.sleep_physionet.age import fetch_data
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import FunctionTransformer
ALICE, BOB = 0, 1
[alice_files, bob_files] = fetch_data(subjects=[ALICE, BOB], recording=[1])
raw_train = mne.io.read_raw_edf(
alice_files[0], stim_channel="Event marker", infer_types=True
)
annot_train = mne.read_annotations(alice_files[1])
raw_train.set_annotations(annot_train, emit_warning=False)
# plot some data
# scalings were chosen manually to allow for simultaneous visualization of
# different channel types in this specific dataset
raw_train.plot(
start=60,
duration=60,
scalings=dict(eeg=1e-4, resp=1e3, eog=1e-4, emg=1e-7, misc=1e-1),
)
(1) My First question related to this plot as it has extra content than in the tutorial slide.
-
Question 1 - What does this bar do? More specifically, why all the vertical line are located between 30000 and 50000, what does the different color represent? I tried to play with the plot start and duration parameter and this bar does not change. ( I did not see this in official tutorial)
-
Question 2 - What does this bar do? especially the area highlighted in red ( did not see this in the official tutorial)
-
Question 3 - I am trying to understand the event marker here. I see it changes very fast within 5 secs the event marker changes drastically. However, if I print out the annotation, the event duration is much longer. Did i miss anything here? Is there a better way to see the annotation raw data?
annot_train[0]
>> OrderedDict([('onset', 0.0),
('duration', 30630.0),
('description', 'Sleep stage W'),
('orig_time', None)]
annot_train[1]
>> OrderedDict([('onset', 30630.0),
('duration', 120.0),
('description', 'Sleep stage 1'),
('orig_time', None)])
annot_train[2]
>> OrderedDict([('onset', 30750.0),
('duration', 390.0),
('description', 'Sleep stage 2'),
('orig_time', None)])
- Question 4 - How does the name to be “Sleep stage W” while there are so many more event from event marker?
(2) Then I tried to plot the 2nd recording using the following script ( only changed recording = [1] to [2])
ALICE, BOB = 0, 1
[alice_files, bob_files] = fetch_data(subjects=[ALICE, BOB], recording=[2])
raw_train = mne.io.read_raw_edf(
alice_files[0], stim_channel="Event marker", infer_types=True
)
annot_train = mne.read_annotations(alice_files[1])
raw_train.set_annotations(annot_train, emit_warning=False)
# plot some data
# scalings were chosen manually to allow for simultaneous visualization of
# different channel types in this specific dataset
raw_train.plot(
start=60,
duration=60,
scalings=dict(eeg=1e-4, resp=1e3, eog=1e-4, emg=1e-7, misc=1e-1),
)
Basically i will see an overshoot see the annotation, i tried to change the scale on rectal but does not change anything.
Also, if i were to plot both recording 1st and 2nd by changing recording=[2]
to recording=[1,2]
per function definition, it will return error.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/var/folders/2_/tzj313wj1bx90zrbzj1wjjqw0000gn/T/ipykernel_71666/800765249.py in <module>
1 ALICE, BOB = 0, 1
2
----> 3 [alice_files, bob_files] = fetch_data(subjects=[ALICE, BOB], recording=[1,2])
4
5 raw_train = mne.io.read_raw_edf(
ValueError: too many values to unpack (expected 2)
Could you please shine some light on this or pointed me to the right thread?
Thank you.