<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Dear FieldTrip community,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My name is Hans Revers. I am a PhD student in the Cognitive Neuropsychology department at Tilburg University, working on decoding emotions from EEG patterns.
<o:p></o:p></p>
<p class="MsoNormal">I would appreciate your insight on how to handle NaNs in TFR power spectra resulting from partial artifact rejection.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We have trials of 90 seconds duration, with artifacts marked from pre-processing in Brain Vision Analyzer. We wish to do a time-frequency analysis (montecarlo cluster analysis) and a classification (mvpa-light). We would want to exclude
 only the artefact parts per trial while retaining the non-artifact parts and the temporal information. Partial rejection of artifacts appears to be the way to achieve this (<a href="https://mailman.science.ru.nl/pipermail/fieldtrip/2018-May/012138.html">https://mailman.science.ru.nl/pipermail/fieldtrip/2018-May/012138.html</a>).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">     % reject artefact cfg<o:p></o:p></p>
<p class="MsoNormal">     cfg_artifact = [];<o:p></o:p></p>
<p class="MsoNormal">     cfg_artifact.artfctdef.reject = 'partial'; <o:p></o:p></p>
<p class="MsoNormal">     % remove artifacts<o:p></o:p></p>
<p class="MsoNormal">     cfg_artifact.artfctdef.xxx.artifact = formatArtifactList(Dairy_per_pp(pp_i).cfg);
<o:p></o:p></p>
<p class="MsoNormal">     % The formatArtifactList() function returns an Nx2 matrix containing
<o:p></o:p></p>
<p class="MsoNormal">     % the start/end samples of each ‘Bad Interval’.<o:p></o:p></p>
<p class="MsoNormal">     ConditionA_per_pp(pp_i) = ft_rejectartifact(cfg_artifact, ConditionA _per_pp(pp_i));<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This works as expected. Artifact intervals are stored in the cfg of the data in artfcdef.xxx.artifact. Next, ft_freqanalysis results in NaNs in the power spectrum for these intervals with a half taper width before and after. Baseline normalization
 with ft_freqbaseline seems to handle these NaNs just fine. So far, so good. (I guess we need to make sure that the baseline does not consist of solely NaNs.)<o:p></o:p></p>
<p class="MsoNormal">However, when we average over participants with ft_freqgrandaverage, the GA results in a NaN for each time bin that has a NaN for one (or more) of the participants. We had expected a nanmean result.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This could be easily fixed by calculating our own nanmean GA powerspectrum, but I am hesitant to alter the intended workings of FieldTrip and I have the following concerns:
<o:p></o:p></p>
<p class="MsoNormal">Question 1)  Are there reasons not to use a nanmean GA? <o:p>
</o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">ft_freqstatistics appears to run unaffected by the presence of NaNs in the per-pp power spectra. We are using non-parametric montecarlo cluster analysis with depsamplesT test. ft_statfun_depsamplesT seems to use a nanmean in the calculation
 of the statistics. <o:p></o:p></p>
<p class="MsoNormal">Question 2)   Can we assume that the statistics are reliable? Or do the NaNs compromise the statistics?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And similarly <o:p></o:p></p>
<p class="MsoNormal">Question 3) Will mvpa classification results be reliable?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any help would be appreciated.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Kind regards,<span style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:X-NONE"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:X-NONE">Hans Revers<o:p></o:p></span></p>
<p class="MsoNormal"><a href="https://www.tilburguniversity.edu/about/schools/socialsciences/organization/departments/cognitive-neuropsychology.htm"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:X-NONE">Department of Cognitive
 Neuropsychology</span></a><span style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:X-NONE"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:X-NONE">Tilburg University<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>