How can I get the respiratory event in the different sleep stage?

Hi everyone,
My data is from the sleep test(PSG), so there are many other physiological signals except eeg. Now, I want to calculate the respiratory event in each sleep stage. In my data, the onset and duration of respiratory events and sleep stages are both provided. I first created the epoch by setting the annotations of sleep stage and transform it into events. However, I don’t know what to do next. Any advice would be helpful. :slight_smile:

What do you mean by “the respiratory event”? Is this some kind of measure that not everybody is aware of?

You mention that you do have onsets and durations of each respiratory event, so I don’t understand what you mean by “the respiratory event”

Do you mean you created epochs, centered on some particular event type (like respiratory events such as “onset of breathing in”)?

As far as I know, sleep stages may last a long time (at least several seconds, up to many minutes). What exactly are you trying to compute or analyze?

1 Like

Thanks for reply!

  1. Respiratory events contain hypopnea, obstructive apnea, central apnea and other types. I want to do some eeg analysis before and after a specific respiratory event.
  2. I created epochs by setting annotation. According to the sleep stage scoring rule(AASM 2.6), each epoch to score lasts 30s. My code is as below:
annotation = {}
annotation['onset'] = [0,30,60,90,....]
annotation['duration'] = [30,30,30,30,....]
annotation['description'] = ['W','N1','N1',...]

annot = mne.Annotations(onset=annotation['onset'], duration=annotation['duration'],description=annotation['description'])

annot_2_event = {'W':0, 'N1':1, 'N2':2, 'N3':3, 'R':4}
events, _ = mne.events_from_annotations(
    raw, event_id=annot_2_event, chunk_duration=30)
epochs = mne.Epochs(
  1. For example, I want to estimate eeg connectivity before and after a obstructive apnea event in stage N1. What should I do? I find that I cannot create epochs by both sleeping stage and respiratory events.

An epoch in your scenario may have two “defining features” at the same time:

  1. a sleep stage (1, 2, …)
  2. a type of respiratory event (apnea, hypopnea, …)

This can be represented in MNE-Python, using event codes like: N1/apnea for an event, for example. This would mean sleep stage 1, and apnea as an event. The / as a separator for the event code is important.

You can read more about this syntax in the docstring of this API documentation part:

please scroll down to “Notes”. Furthermore, these two tutorials might be helpful for you:


Thanks for your help!

1 Like