[FieldTrip] Sample discrepancy, and 50Hz line noise filtering

Florian Gerard-Mercier florian at brain.riken.jp
Fri Oct 14 08:08:09 CEST 2016


Dear community,


My name is Florian Gerard-Mercier and I work in Keiji Tanaka’s laboratory in Riken BSI, Japan.


I am new to Fieldtrip.
My goal is to do a simple analysis of ECoG data in response to electrical stimulation (all in monkey cortex). To this effect I followed the TMS-EEG tutorial (since the issues are almost identical).
The recording system is Neuralynx.

I have encountered 2 problems which I don’t believe are related.
I have basically followed the tutorials to the letter so except if I mention otherwise, the cfg, etc. are standard.

1) Fsample discrepancy between data and header.
When I load Neuralynx data, I get warnings that the sample rate is actually half that in the header, and is thus being corrected (note, 16129 instead of 32258Hz).
This is no problem, until I get the final results where I noticed that my 50Hz noise is now represented as lasting 40ms for each cycle (= twice longer than it actually is).
Navigating in the workspace, I noticed that even though cfg.Fs is 16129 as expected, somehow the data outputted by ft_preprocessing has a field fsample equal to half that number (8064.5).
This later gives many conflicts such as: if I force data.fsample to be 16129, I have the correct time axis in the end, but now my trial duration is only half that which I want…
Any idea on how to solve this issue? I haven’t found any previous ticket on this Fsample discrepancy issue.
I do not know either how much trust I have to put in that warning and correction of the sampling rate in the first place.

2) 50Hz line noise filtering
The previous point makes it so that if I filter 50Hz, of course nothing happens. But even if I filter 25Hz (or 50Hz with the Fsample corrected back to 16129), the attenuation is far too small (whether I use padding or not). I did look up the similar problems that had been submitted to this list in the past, but didn’t find any satisfactory fix.
To give an idea:
cfg = [];
cfg.Fsample   = 1000;  % I downsampled the data in the meantime as said in the tuto
cfg.bsfilter  = 'yes';
cfg.bsfiltord = 2;           % somehow I have an error that the filtering doesn’t work every time I try to run it with an order >2
cfg.bsfreq    = [49.9 50.1];
filtDat           = ft_preprocessing(cfg, data_lite);

cfgbrowse = []; cfgbrowse.viewmode = 'butterfly';
ft_databrowser(cfgbrowse, dat_lite /// filtDat); % screenshots of both below

changes this


into that



{Note also the issue with Fsample: here I have a time axis that corresponds to my 50Hz noise, but the duration of the trial is reduced from [-0.05, 0.45] by a factor of 2.}

This is in stark contrast to what happens if I use the bandstop filter directly on the raw data:
dat = ft_read_data(dataset_dir);
dat_filt = ft_preproc_bandstopfilter(dat, 16129, [49.9 50.1], 2);
changes this


into that



Which should be perfect for my simple purposes.  (Here I just did a simple Matlab plot, so the x axis numbering is not actual time)

Of course, I tried to feed that filtered data into the preprocessing pipeline by doing 
cfg = ft_rejectartifact(cfg_artifact);    %cfg_artifact is defined as in the tutorial, it is to reject the electrical stimulation artifacts. The problem should not stem from here.
data_artifact_rejected = ft_preprocessing(cfg, dat_filt);
But I get the error that dat_filt is not raw or comp data.

I have read that it is recommended to do the line noise filtering after the trial segmentation and stimulation artefact removal, but 1) it doesn’t seem to work well, 2) I don’t really understand why, given that my artefacts are nowhere near the 50Hz frequency.

So for this point:
- how to make the (recommended) 50Hz post processing work?
- or more simply, how could I feed prefiltered data to ft_preprocessing?




Thank you very much for your consideration and I look forward to your help.

All the best,


Florian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161014/a55fd280/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data_lite.jpeg
Type: image/jpeg
Size: 32603 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161014/a55fd280/attachment.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filtDat.jpeg
Type: image/jpeg
Size: 32794 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161014/a55fd280/attachment-0001.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RawData.jpeg
Type: image/jpeg
Size: 51182 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161014/a55fd280/attachment-0002.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RawData_after_filter.jpeg
Type: image/jpeg
Size: 46294 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161014/a55fd280/attachment-0003.jpeg>


More information about the fieldtrip mailing list