How to stitch epoched data back into continuous raw data ?

Hello,

I am analyzing a continuous eeg data, I am not looking for a particular event based response (e.g. ERP stimulus), but rather something ike sleep analysis.

I have followed the following steps till now :

  1. Import the raw signal
  2. Apply a bandpass filter
  3. Using the interactive plot of mne library, manually annotate bad portions of the signal by labelling them ‘bad_signals’
  4. Create an events array to epoch the continuous signal into equal length epochs
  5. Compute ICA on the epoched data
  6. Reject the unwanted components and then apply the ica object to the raw data to clean artifacts

I wish to calculate the PSD of the cleaned data. However, I am confused if I should stitch the epoched signal back into continuous signal to compute the PSD.

I tried to use the mne.concatenate_epochs() method and stored the result into a raw object. But when I plot it, I can still see the epochs. How do I get a continuous signal without any annotations now ?

Any help regarding this will be very useful! Thanks!

If you apply your ica object (fit on epochs - ica.fit(epo) ) to the raw data (ica.apply(raw)) - this will give you your continuous data back.

If you try to stitch back together epochs, you will have jump discontinuities. The “bad_signals” annotations will be dropped from your epochs - so you will have a jump at the borders of the missing epoch. Also when creating epochs, there is a default prestim DC offset - which will cause jump discontinuities in your stitched back together data. The timing may also be off if you reject one or more epochs.

-Jeff

1 Like

Also - there is a way to get a PSD from epochs: The Spectrum and EpochsSpectrum classes: frequency-domain data — MNE 1.6.1 documentation

Hi Jeff,

Thanks for the suggestion! My raw data has some very large amplitude artefacts caused due to head movements, which I have decided to ignore in my analysis. Hence I annotated those portions and proceeded ahead with the ICA.

If I apply ica object (fit on epochs - ica.fit(epo) ) to the raw data (ica.apply(raw)) , I am unable to remove those large head movement artefacts. However, if I pass the annotated signal into ica.apply(annotated), will it automatically reject the bad signal parts ?

Could you suggest a suitable approach ?

Great! Shall check this out! Thanks!

In order to create a good ICA decomposition, I used ‘reject_by_annotation = True’ while fitting the epoched raw data that has the bad-signal annotations.