mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.67k stars 1.31k forks source link

MNE IO RAW Decimate #10791

Open umair-hassan opened 2 years ago

umair-hassan commented 2 years ago

Dear MNE Maintainers,

I am trying to decimate the raw data (loaded using raw.io), I do not care about the antialiasing and filters. I just need the decimated date (downsampled ratio basically). I am not sure if I can create epoch easily for the whole data and then downsample it, therefore I think inside resample (there could be an option to switch off the filters) or there could be a generic decimate method for raw io object as well.

Happy to help implementing it though.

Best, Umair

welcome[bot] commented 2 years ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

agramfort commented 2 years ago

@umair-hassan look at the decim parameter in mne.Epochs class

close the issue if it fixes your issue

umair-hassan commented 2 years ago

I understand that there exist a decim param in Epochs, but I do not want to Epoch the data at the continous raw stage when I am planning to decimate. Basically just loading the data using mne.io.raw method and just directly apply decimation. I also understand that it will impact my events, but I do not care about that at this stage of processing.

cbrnr commented 2 years ago

Why do you want to decimate raw (continuous) data without an anti-alias filter? Do you take care of that yourself? You can resample with raw.resample(), which does apply a suitable anti-aliasing filter though.

umair-hassan commented 2 years ago

I need it for a concurrent EEG fMRI artefact correction step. I cannot just apply antialiasing in the presence of huge gradient artefacts. The data was sampled at exceptionally high Fs therefore downsampling it to a reasonable Fs is also necessary. I will take care of anti-aliasing myself.

I think generally speaking for all brain stimulation, neuromodulation, TMS-EEG analysis too, this would be quite desirable.

cbrnr commented 2 years ago

You can always grab the continuous data with raw.get_data() and then decimate the NumPy array yourself. Would that work?

umair-hassan commented 2 years ago

Yes in principle.

cbrnr commented 2 years ago

We might consider adding a new parameter antialias=True to Raw.resample(), but I'd rather not unless it would be helpful for a larger group of users. So if you can live with the proposed workaround LMK, otherwise we'll wait for other devs to chime in.

umair-hassan commented 2 years ago

Thanks!

larsoner commented 2 years ago

People do ask for this from time to time. Because this keeps coming up (and since we have a non-antialiased .decimate for epochs+evoked), I'm okay with adding one that just takes every Nth sample as long as we state clearly that bad things can happen when you do this.

cbrnr commented 2 years ago

OK! Then instead of adding a parameter to resample(), it is better to add a new decimate() method as you suggested.

umair-hassan commented 1 year ago

Ping, just checking for an update here.

jasmainak commented 1 year ago

see related issue: https://github.com/mne-tools/mne-python/issues/10447