mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

MNE IO RAW Decimate

Open umair-hassan opened this issue 3 years ago • 11 comments

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

umair-hassan avatar Jun 20 '22 19:06 umair-hassan

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

welcome[bot] avatar Jun 20 '22 19:06 welcome[bot]

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

close the issue if it fixes your issue

agramfort avatar Jun 21 '22 07:06 agramfort

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.

umair-hassan avatar Jun 21 '22 10:06 umair-hassan

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.

cbrnr avatar Jun 21 '22 10:06 cbrnr

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.

umair-hassan avatar Jun 21 '22 10:06 umair-hassan

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

cbrnr avatar Jun 21 '22 10:06 cbrnr

Yes in principle.

umair-hassan avatar Jun 21 '22 11:06 umair-hassan

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.

cbrnr avatar Jun 21 '22 11:06 cbrnr

Thanks!

umair-hassan avatar Jun 21 '22 11:06 umair-hassan

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.

larsoner avatar Jun 21 '22 11:06 larsoner

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

cbrnr avatar Jun 21 '22 11:06 cbrnr

Ping, just checking for an update here.

umair-hassan avatar Dec 26 '22 21:12 umair-hassan

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

jasmainak avatar Dec 26 '22 23:12 jasmainak