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

Florian Gerard-Mercier florian at brain.riken.jp
Sat Oct 15 09:25:38 CEST 2016


Dear all,

I am wondering, was my question unclear, or maybe no one is using Neuralynx data?
I can think of ways to avoid these two problems, but I would prefer to find a proper solution if possible. 

Thanks in advance,

Florian Gerard-Mercier



> On 14 Oct, 2016, at 3:08 PM, Florian Gerard-Mercier <florian at brain.riken.jp> wrote:
> 
> 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
> <data_lite.jpeg>
> 
> into that
> 
> <filtDat.jpeg>
> 
> {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
> <RawData.jpeg>
> 
> into that
> 
> <RawData_after_filter.jpeg>
> 
> 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
> 
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161015/7863d11a/attachment-0002.html>


More information about the fieldtrip mailing list