[FieldTrip] Difficulty using "plotfiltresp" --- trying to plot frequency response curve on my data

Andreas Widmann widmann at uni-leipzig.de
Mon May 4 15:32:23 CEST 2020


Hi Jonathon and Jan-Mathijs,

indeed this functionality appears to be missing for the Butterworth filters. To be honest I do not remember why this was omitted as it appears to be fully functional (but without in depth testing for now).

This can, however, be easily fixed. For lowpass filtering the code is already there but commented for unclear reasons, see ft_preproc_lowpassfilter.m, lines 154-156:
https://github.com/fieldtrip/fieldtrip/blob/master/preproc/ft_preproc_lowpassfilter.m

You just need to uncomment and copy these three lines to the corresponding location in ft_preproc_bandpassfilter.m in the preproc directory (and ft_preproc_bandstopfilter.m and ft_preproc_highpassfilter.m in case needed) and it should be working. If you file an issue at the Github fieldtrip page the problem can be fixed quickly, I assume.

Note that plotting is done *before* filter stability is checked. Thus, if you get a stability warning the plot does not reflect the actually applied filter. You have to re-run with order adjusted to what is reported in the stability warning message (as I would recommend anyway). Possibly this limitation was the reason for omission at that time?

Hope this helps! Best,
Andreas

> Am 02.05.2020 um 17:04 schrieb Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl>:
> 
> Hi Jonathon,
> 
> I don’t know what is going wrong. I have never used this functionality myself, so I would need to dig into it in order to check whether 1) I can reproduce your problem, and 2) to look for a solution.
> 
> Have you tried a different type of filter (e.g. ‘firws’) to check whether your issue is filter type dependent? As a background note, the ‘plotfiltresp’-option has been contributed by Andreas Widmann, who also contributed few advanced digital filters (which work much better than the default butterworth IIR filter), one of which being the ‘firws’. It could be that the plotfiltresp functionality has only been correctly implemented for the firws filter. If this happens to be the case, we can think about supporting this option for the other filters as well, provided the lower level code allows for this in principle. We look forward to any code improvement suggestions as PRs on github.
> 
> Besides, I’d recommend to use the matlab debugger, to investigate what’s going on. You can place a breakpoint somewhere in the code, and then step through it line by line. This way you can investigate whether cfg options are passed on correctly, and whether they are used to begin with. This is the strategy we would use to look into potential issues
> 
> 
> Best wishes,
> Jan-Mathijs
> 
> 
>> On 25 Apr 2020, at 01:18, Jonathon James Parker <parkerjo at stanford.edu> wrote:
>> 
>> Hi Jan:
>>  
>> Not sure of the proper etiquette
>>  
>> here if I should reply all to the thread. 
>> 
>> Sincerest apologies, that was a transcription typo in the e-mail. I triple checked my code, and re-ran a couple test cases, and I can still not get the filter response curve to plot.
>>  
>> Any thoughts?
>>  
>> Best,
>> Jonathon
>>  
>>  
>> From: "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
>> Date: Wednesday, April 22, 2020 at 11:29 AM
>> To: FieldTrip discussion list <fieldtrip at science.ru.nl>
>> Subject: Re: [FieldTrip] Difficulty using "plotfiltresp" --- trying to plot frequency response curve on my data
>>  
>> Hi Jonathon,
>> There’s a typo in the cfg specification: cfg.poltfiltresp should read: cfg.plotfiltresp.
>>  
>> Best wishes,
>> JM
>>  
>> 
>> 
>> On 22 Apr 2020, at 20:12, Jonathon James Parker <parkerjo at stanford.edu> wrote:
>>  
>> Hi Fieldtrippers:
>>  
>> I am interested in looking at the Frequency response curve after applying different filter types to extract high-gamma band (70-170Hz) in my dataset.
>>  
>> I have used the cfg.plotfiltresp = ‘yes’ flag in running preprocessing on a subset of my data. The call to ft_preprocessing runs without issue, but there is no plot of the filter response curve.
>>  
>> Here is an example of the cfg I am using for the call to ft_preprocessing
>>  
>>  cfgi = [];
>>     cfgi.bpfilter = 'yes';
>>     cfgi.bpfreq = [l70 170];
>>     cfgi.bpfilttype = 'but';
>>     cfgi.bpinstabilityfix = 'reduce';
>>     cfgi.bpfiltrord = 8;
>>     cfgi.poltfiltresp = ‘yes’;
>>  
>>  
>>  
>> I searched the code of ft_preprocessing and only see the “plotfiltresp” referenced in handling the cfg. flag, thus I am guessing this parameter is simply passed to a lower level pre_proc function depending on the filter type.
>>  
>> Has anyone else had this problem and can offer advice on how to get this functionality to work?
>>  
>> I am running Fieldtrip August 2019 build.
>>  
>> Hope everyone is staying healthy.
>>  
>> Kindest regards and thank you,
>>  
>> Jonathon
>>  
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Jonathon “JP" Parker MD, PhD
>> Resident in Neurosurgery | PGY5
>> Morgridge Endowed Postdoctoral Fellow 
>> Maternal & Child Health Research Institute
>> Department of Neurosurgery
>> Stanford University 
>> E: parkerjo at stanford.edu
>> 
>> 
>>  
>>  
>>  
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
> 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202




More information about the fieldtrip mailing list