0

I have an MNE raw EEG object from which I would like to extract segments given by start time and end time points that are in a csv file that looks like this:

rem_df:

Sleep Stage     start    end
SLEEP-REM       4770.0   5280.0
SLEEP-REM       5310.0   5760.0
SLEEP-REM       10620.0  12270.0
SLEEP-REM       16440.0  17010.0
SLEEP-REM       17040.0  17670.0
SLEEP-REM       21390.0  21630.0

I just want the REM segments such that the times are preserved exactly as they are. I tried the following:

rem_raw = raw.copy().crop(tmin=rem_df.iloc[0,1], tmax=rem_df.iloc[0,2])     #first rem epoch
for i in range(1,len(rem_df)):      
    t_start = rem_df.iloc[i,1]       #iterating over start
    t_end = rem_df.iloc[i,2]           #iterating over end
    rem_raw.append(raw.copy().crop(tmin=t_start, tmax=t_end))

This does extract the REM stages for me, but the problem in appending this way is that it completely restarts the timepoints from t = 0 and has a continuous data structure, while I want a discontinuous structure.

Is there a way to store all of this in discontinuous epochs?

S C
  • 284
  • 2
  • 9

0 Answers0