sappelhoff / pyprep

A Python implementation of the Preprocessing Pipeline (PREP) for EEG data
https://pyprep.readthedocs.io/en/latest/
MIT License
128 stars 30 forks source link

How to include the prep output in my preprocessing pipeline? #135

Closed m4sp3 closed 8 months ago

m4sp3 commented 9 months ago

Dear all, I'm very happy to discover your implementation on Python of the PREP routines. I have been trying it for a while, and it looks great. However, I have a (I think, silly) confusion regarding how to use the output of the PrepPipeline class, and I have failed finding a solution by reading the documentation.

In short, I use the following line to implement the preprocessing steps:

prep = pyprep.PrepPipeline(raw, prep_params, montage)
prep.fit()

which gives me a prep object that has a lot of useful things, like the EEG_new field. It also seems to include a copy of the raw data, as I can obtain it with prep.raw.get_data(), but I can't find the right way to include the output on my preprocessing flow.

My main questions:

  1. The EEG_new field has the EEG data with channels interpolated and re-references to the robust average? If not, where can I find the fields with this data? Or, alternatively, the data with interpolated channels, so I can subtract the robust average reference?
  2. How do I include the PrepPipeline output in my working raw object? After the PREP steps, I should call to raw.set_eeg_reference(), then raw.filter(), etc., but I cannot figure out how to do this as the raw objects seem to be unaltered.

All the best!

sappelhoff commented 9 months ago

Hi @m4sp3 -- sorry for the late reply. Have you had a look at the API documentation? --> https://pyprep.readthedocs.io/en/latest/generated/pyprep.PrepPipeline.html#pyprep.PrepPipeline

you can find the fully processed data in prep.raw ... so you could do something like raw_prep = prep.raw.copy() if you want to have just the raw object resulting from the PREP pipeline.

image