<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Dear Jan-Mathijs,</p>
<p><br>
</p>
<p>you are absolutely correct with both; the peaks variable is not defined if there are no artifacts in the data due to a high cut-off threshold (no artifacts means no artifact peaks, makes sense ;). Additionally, I misunderstood the option
<font style="font-family: Calibri, Helvetica, sans-serif, serif, "EmojiFont";" size="3" face="Calibri,Helvetica,sans-serif" color="black">
<span style="font-size:12pt;" id="divtagdefaultwrapper">cfg.artfctdef.zvalue.artfctpeak  = 'yes', I dont really need that. A bit embarrassing how easy the solution was^^ But thank<font face="Calibri,Helvetica,sans-serif">s a lot!</font></span></font></p>
<p><font style="font-family: Calibri, Helvetica, sans-serif, serif, "EmojiFont";" size="3" face="Calibri,Helvetica,sans-serif" color="black"><span style="font-size:12pt;" id="divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif"><br>
</font></span></font></p>
<p><font style="font-family: Calibri, Helvetica, sans-serif, serif, "EmojiFont";" size="3" face="Calibri,Helvetica,sans-serif" color="black"><span style="font-size:12pt;" id="divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif">Kind egards</font></span></font></p>
<p><font style="font-family: Calibri, Helvetica, sans-serif, serif, "EmojiFont";" size="3" face="Calibri,Helvetica,sans-serif" color="black"><span style="font-size:12pt;" id="divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif">Erika</font></span></font><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> im Auftrag von Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen@donders.ru.nl><br>
<b>Gesendet:</b> Dienstag, 7. Mai 2019 13:23:17<br>
<b>An:</b> FieldTrip discussion list<br>
<b>Betreff:</b> Re: [FieldTrip] automatic artifact rejection: error with ft_artifact_zvalue</font>
<div> </div>
</div>
<div>Dear Erika,
<div class=""><br class="">
</div>
<div class="">I must confess that I am not familiar with that particular corner of the code, but reading your message (and the corresponding code), I get the impression that the cause of you ending up with an error (with the particular data you are using it
 with) is caused by the fact that the peak detection algorithm does not find a peak, leaving the ‘peaks’ variable undefined.</div>
<div class=""><br class="">
</div>
<div class="">This means that the code is not sufficiently robust. I don’t know what the intended behavior is, but I could imagine that defining ‘peaks’ and ‘dssartifct’ to be empty variables, before entering the for loop in line 572 would do the trick.</div>
<div class=""><br class="">
</div>
<div class="">This keeps unanswered my question why you want the arfctpeak to be defined in the first place… I agree that this is a poorly documented option, but I doubt whether you need it.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 7 May 2019, at 11:38, Erika Puiutta <<a href="mailto:erika.puiutta@uni-oldenburg.de" class="">erika.puiutta@uni-oldenburg.de</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p>
<div class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Hello!</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Short introduction as this is my first email to this mailing list: I am Erika, 28, master student of neurocognitive psychology in Germany. I am analyzing MEG data for my master thesis and would like
 to perform automatic artifact rejection using<span class="Apple-converted-space"> </span><span class="">ft_artifact_zvalue</span>. This has worked in the past, but now I get the error:</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div class="">"Undefined function or variable 'peaks'.<br class="">
Error in ft_artifact_zvalue (line 594)<br class="">
  cfg.artfctdef.zvalue.peaks=peaks'; "</div>
<div class=""><br class="">
</div>
<div class="">I call the funciton as<span class="Apple-converted-space"> </span><span class="">[cfg, artifact] = ft_artifact_zvalue(cfg, data)</span>.</div>
<div class="">My cfg is comprised of:</div>
<div class="">
<div class="">                cfg=[];<br class="">
                cfg.artfctdef.zvalue.channel = 'MEG';<br class="">
                cfg.artfctdef.zvalue.cutoff = 7;<br class="">
                cfg.artfctdef.zvalue.trlpadding = 0;<br class="">
                cfg.artfctdef.zvalue.artpadding = 0;<br class="">
                cfg.artfctdef.zvalue.fltpadding = 0;<br class="">
                cfg.artfctdef.zvalue.interactive = 'no';<br class="">
                cfg.artfctdef.zvalue.artfctpeak  = 'yes';</div>
and my data is segmented and filtered MEG data:</div>
<div class="">
<div class="">hdr: [1×1 struct]<br class="">
label: {200×1 cell}<br class="">
time: {1×60 cell}<br class="">
trial: {1×60 cell}<br class="">
fsample: 1000<br class="">
sampleinfo: [60×2 double]<br class="">
trialinfo: [60×1 double]<br class="">
grad: [1×1 struct]<br class="">
elec: [1×1 struct]<br class="">
cfg: [1×1 struct]</div>
</div>
<div class=""><br class="">
</div>
<div class="">Googling hasn't brought me any closer to a solution. I tried removing fieldtrip from the path, adding it again, and calling ft_defaults again. I also downloaded a new version of fieldtrip.</div>
<div class="">Does anyone have an idea what might be the problem here?</div>
<div class="">Thanks for aswers in advance!</div>
<div class=""><br class="">
</div>
<div class="">Kind regards</div>
Erika</div>
<br class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p>
</div>
<span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://doi.org/10.1371/journal.pcbi.1002202</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>