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

Florian Gerard-Mercier florian at brain.riken.jp
Sun Oct 16 10:02:12 CEST 2016


Dear Per,

Thank you for your reply.

Well if I don’t know how much trust I can have in it, it is because the sampling frequency inputted on my side (in the settings of the Cheetah DAS) is indeed 32kHz, that was the default. Now it is an old system so maybe it is doing something differently, who knows.
However, when I filter the raw data with ft_preprocbandstopfilter I get the desired result for a sampling frequency of 16k. So Fieldtrip is probably right about this, and is self-consistent up till then.
The problem for me is that within the data outputted by ft_preprocessing you get two different Fsample values: data.hdr.fs = 16k vs data.fsample = 8k. This sounds strange to me, however you look at it.
Also, that 8kHz comes out of nowhere, there is no warning and no rationale for it. So, it seems like an intempestive division by two of the sampling rate that happens during the correction fieldtrip does when it reads the data.

Also, the second problem is that for which I am most interested in the answer: whether it is possible - and if so, how - to filter the 50Hz line noise before feeding the data into ft_preprocessing.

All the best,

Florian

> On 15 Oct, 2016, at 9:18 PM, Per Knutsen <knutsenpm at gmail.com> wrote:
> 
> Dear Florian,
> You are not clear about your actual sample rate:
> 
> > 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.
> 
> Clearly, you should know your own sampling rate from the Neurolynx acquisition software.
> 
> It would seem this is the primary thing you need to resolve.
> 
> 
> Regards,
> Per
> 
>  
> 
> 
> Per M Knutsen
> University of Oslo
> Dept. of Molecular Medicine, Physiology Sect.
> PB 1103 Blindern, NO-0317 Oslo
> +47.45103762 <tel:%2B47.45103762>
> 
> On Sat, Oct 15, 2016 at 9:25 AM, Florian Gerard-Mercier <florian at brain.riken.jp <mailto:florian at brain.riken.jp>> wrote:
> 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 <mailto: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 <mailto:fieldtrip at donders.ru.nl>
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
> 
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl <mailto:fieldtrip at donders.ru.nl>
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
> 
> _______________________________________________
> 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/20161016/5e56ea77/attachment-0002.html>


More information about the fieldtrip mailing list