<div dir="ltr"><div><div style="">Dear Julia,</div><div style=""><br></div><div style="">The filtering not being applied might be related to the data samples you're providing the bandpass filtering. Several things:</div><div style=""><br></div><div style="">Keep in mind:</div><div style="">You're creating a bandpass butterworth filter [1-3hz] with filter order 2. This means you'll need enough data to filter so low frequencies. Briefly, the butterworth filter is an infinite impulse response filter (IIR) that filters the data recursively (not by convolution) and the filter order means the amount of samples from input and output the filter will use (please go <a href="http://www.dspguide.com/CH14.PDF">http://www.dspguide.com/CH14.PDF</a> if this is not clear). The higher the filter order, the sharper the frequency response, the stronger the "ringing". The finite impulse response (FIR) filters, by the contrary, are implemented by convolution and the filter order means the length of the filter-kernel. The higher the filter order, the higher the frequency resolution, the lower the temporal resolution, the longer the filter kernel.</div><div style=""><br></div><div style="">Then you'll have to make sure your filter order is appropriate given the length of your data, which is not intuitive for IIR filters. I'm not an expert on filtering and I find the Widmann, Schröger & Maess recent paper an excellent guide:</div><div style=""><a href="http://www.ncbi.nlm.nih.gov/pubmed/25128257">http://www.ncbi.nlm.nih.gov/pubmed/25128257</a><br></div><div style=""><br></div><div style="">To dig into this issue, you can apply the very same filter settings with ft_preprocessing separately and check what's happening before and after. Then you can discard if the filtering is what is creating the problem.<br></div><div style=""><br></div><div style="">Check: </div><div style="">- Make sure the epoching you're using in cfg.trl = temptrl; is not too short for your filtering. My hunch is that the NaNs might be related to this</div><div style="">- I don't know what kind of artifacts are you chasing filtering so low (drifts?) but the artifact padding you're using might be too short (artpadding  = 0.1;)</div><div style=""><br></div><div style="">Regarding the very large effects in those two trials, I'd be pragmatic and I would delete them or I'd cut the edges that are problematic for you...</div><div style=""><br></div><div style="">I hope that helps!</div><div style=""><br></div><div style="">Diego</div></div><div style=""><br></div><div style=""><br></div><div style=""><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 2 May 2016 at 16:31, Brehm, J. (Julia) <span dir="ltr"><<a href="mailto:j.brehm@uu.nl" target="_blank">j.brehm@uu.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Dear Diego,
<div><br>
</div>
<div>yes, thank you, I've seen that already. Unfortunately this does not really help me.</div>
<div><br>
</div>
<div>Apparently filtering is not even applied in my case (as the warning says). It seems that the NaNs are introduced in ft_fetch_data, shouldn't these be replaced by zeros where it's not filled by actual data when applying filterpadding? I assume it does that
 at some other point I couldn't find!?</div>
<div><br>
</div>
<div>Furthermore, in the interactive mode one can see that the z-values mimic the data in the first and last trial of the dataset. This leads to the detection of artifacts which are none and missing real artifacts (due to very large effects in those two trials).
 I have attached a screenshot to illustrate what I mean.</div>
<div> </div>
<div>As far as I understand filterpadding uses zero-padding, meaning I can use it on segmented (not continuous) data, correct? So why does this have such a large effect on my whole data instead of simply getting rid of edge effects?</div>
<div><br>
</div>
<div>Sorry if I am missing something obvious.</div>
<div><br>
</div>
<div>Best,</div>
<div>Julia</div>
<div><br>
</div>
<div><br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>From:</b> <a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a> [<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>] on behalf of Diego Lozano-Soldevilla [<a href="mailto:dlozanosoldevilla@gmail.com" target="_blank">dlozanosoldevilla@gmail.com</a>]<br>
<b>Sent:</b> Monday, May 02, 2016 3:24 PM<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Subject:</b> Re: [FieldTrip] What exactly does filterpadding do?<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">Dear Julia,
<div><br>
</div>
<div>From the FAQ section:</div>
<div><br>
</div>
<div><a href="http://redir.aspx?REF=0gkAGAqPbCJ2dB292COe_fT8oQ4uUuB0lAE5ZjlGPIMMbbmbkXLTCAFodHRwOi8vd3d3LmZpZWxkdHJpcHRvb2xib3gub3JnL2ZhcS9ob3dfZG9lc190aGVfZmlsdGVyX3BhZGRpbmdfaW5fcHJlcHJvY2Vzc2luZ193b3Jr" target="_blank">http://www.fieldtriptoolbox.org/faq/how_does_the_filter_padding_in_preprocessing_work</a><br>
</div>
<div><a href="http://redir.aspx?REF=JxY36va1p9AZr0dc60zsrQZfgm_me-O_jx77ehMz3x4MbbmbkXLTCAFodHRwOi8vd3d3LmZpZWxkdHJpcHRvb2xib3gub3JnL2ZhcS9ob3dfY2FuX2lfaW50ZXJwcmV0X3RoZV9kaWZmZXJlbnRfdHlwZXNfb2ZfcGFkZGluZ190aGF0X2lfZmluZF93aGVuX2RlYWxpbmdfd2l0aF9hcnRpZmFjdHM." target="_blank">http://www.fieldtriptoolbox.org/faq/how_can_i_interpret_the_different_types_of_padding_that_i_find_when_dealing_with_artifacts</a><br>
</div>
<div><br>
</div>
<div>I hope that helps,</div>
<div><br>
</div>
<div>Diego</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 2 May 2016 at 15:08, Brehm, J. (Julia) <span dir="ltr">
<<a href="http://redir.aspx?REF=bbm3PKzTSZZ7WAp2IZa3r2IscZbmOgYQdLrtX5WQsp0MbbmbkXLTCAFtYWlsdG86ai5icmVobUB1dS5ubA.." target="_blank">j.brehm@uu.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Dear list,
<div><br>
</div>
<div>I am having problems applying filterpadding when using ft_artifact_zvalue. </div>
<div><br>
</div>
<div>Could someone please explain what exactly the effect of filterpadding is, and in which cases I can apply it and in which not?</div>
<div><br>
</div>
<div>I intended to use it to avoid edge effects in the artifact detection. However, I get the following warning (only when applying fltpadding, my data does not actually contain NaNs):</div>
<div><br>
</div>
<div>
<div>Warning: data contains NaNs, no filtering or preprocessing applied </div>
<div>> In ft_warning (line 181)</div>
<div>  In preproc (line 282)</div>
<div>  In ft_artifact_zvalue (line 292)</div>
</div>
<div><br>
</div>
<div>These are my settings:</div>
<div>
<div>
<div>cfg            = [];</div>
<div>cfg.trl        = temptrl; % all trials</div>
</div>
<div><br>
</div>
<div>cfg.artfctdef.zvalue.channel     = channel{ch};  % single channel</div>
<div>cfg.artfctdef.zvalue.cutoff      = 3;</div>
<div>cfg.artfctdef.zvalue.fltpadding  = 0.1;</div>
<div>                    </div>
<div>cfg.artfctdef.zvalue.bpfilter   = 'yes';</div>
<div>cfg.artfctdef.zvalue.bpfilttype = 'but';</div>
<div>cfg.artfctdef.zvalue.bpfreq     = [1 3];</div>
<div>cfg.artfctdef.zvalue.bpfiltord  = 2;</div>
<div>cfg.artfctdef.zvalue.hilbert    = 'yes';</div>
</div>
<div><br>
</div>
<div>Thanks!</div>
<div><br>
</div>
<div>Best,</div>
<div>Julia</div>
</div>
</div>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="http://redir.aspx?REF=G8XJ7tCtpbYE8RHR4kVgxIqdcT0l_J9AFDcMhGt9sDcMbbmbkXLTCAFtYWlsdG86ZmllbGR0cmlwQGRvbmRlcnMucnUubmw." target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://redir.aspx?REF=BpGfhXBN8ygpF5iDmBXoUMkjlLaKCCmwRMHwC-J7PnsMbbmbkXLTCAFodHRwOi8vbWFpbG1hbi5zY2llbmNlLnJ1Lm5sL21haWxtYW4vbGlzdGluZm8vZmllbGR0cmlw" rel="noreferrer" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>
</div>
</div>

<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>