<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 14 (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;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 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";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Consolas","serif";
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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 bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi Ingrid, <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">thanks! That definitely helps a lot!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Cheers, <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Patrick<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> fieldtrip-bounces@science.ru.nl [mailto:fieldtrip-bounces@science.ru.nl]
<b>On Behalf Of </b>Ingrid Nieuwenhuis<br>
<b>Sent:</b> 05 December 2012 19:09<br>
<b>To:</b> fieldtrip@science.ru.nl<br>
<b>Subject:</b> Re: [FieldTrip] Partial artifact rejection<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Patrick,<br>
<br>
What you can do is use partial artifact rejection by calling ft_rejectarttifact with  cfg.artfctdef.reject = 'partial'. Then subsequently loop over the trials you get, and identify the ones (by looking at data.time{iTr}) that do not start at the time your trials
 normally start (this means it's a trial after an artifact). Finally, exclude those by using ft_redefinetrials.<br>
<br>
For instance, if your trials start with t=0, then after ft_rejectartifact you can do something like:<br>
ind_keep = zeros(length(data.trial),1); %allocate<br>
for iTrl = 1:length(data.trial)<br>
  if data.trial{iTrl}(1) ~= 0 <br>
    %this means it's a trial occurring AFTER an artifact<br>
    ind_keep(iTrl) = false;<br>
  else<br>
   %this means it's a trial occurring BEFORE an artifact<br>
    ind_keep(iTrl) = true;<br>
  end<br>
end<br>
<br>
%only keep the trials before the artifact:<br>
cfg = [];<br>
cfg.trials = find(ind_keep);<br>
data = ft_redefinetrial(cfg, data);<br>
<br>
Hope this helps,<br>
Ingrid<o:p></o:p></p>
<div>
<p class="MsoNormal">On 12/5/2012 5:57 AM, Jung, Patrick wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-GB">Dear all, </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">in the reference documentation it says “In case of partial artifact rejection, a minimum length of the</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">resulting sub-trials can be specified.”</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">I’d like to reject the trial segment from the beginning of the artifact onwards to keep only the data before the artifact occurred.
</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">But I don’t want to append subtrials.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">How can I do that in fieldtrip?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">Many thanks for your help!</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">Best, <br>
Patrick</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><br>
<br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>fieldtrip mailing list<o:p></o:p></pre>
<pre><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><o:p></o:p></pre>
<pre><a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><br>
<br>
<o:p></o:p></span></p>
<pre>-- <o:p></o:p></pre>
<pre>Ingrid Nieuwenhuis PhD<o:p></o:p></pre>
<pre>Postdoctoral Fellow<o:p></o:p></pre>
<pre>Sleep and Neuroimaging Laboratory<o:p></o:p></pre>
<pre>Department of Psychology<o:p></o:p></pre>
<pre>University of California, Berkeley<o:p></o:p></pre>
<pre>California 94720-1650<o:p></o:p></pre>
<pre>Tolman Hall, room 5305<o:p></o:p></pre>
</div>
</body>
</html>