<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: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;}
/* 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:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
p.msochpdefault, li.msochpdefault, div.msochpdefault
        {mso-style-name:msochpdefault;
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri","sans-serif";}
span.e-mailformatvorlage17
        {mso-style-name:e-mailformatvorlage17;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.sprechblasentextzchn
        {mso-style-name:sprechblasentextzchn;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        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-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi Christine,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I’m sure that there is a “clean” fieldtrip way to solve your problem which should be the preferred solution. However here is an idea for debugging and a potential workaround that might help.<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">So ft_databrowser marks the artefacts you selected by storing the sampleinfo of the beginning and the end of you selection (these are two sampling points, counted from the beginning of your recording).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">They are stored in two column vectors (look it up in cfg.artfctdef.visual).
<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">I think something might have gone wrong when you cut your data because fieldtrip eventually removes and/or reconstructs sampleinfo if it is inconsistent or missing (don’t ask me how and when this does and does
 not happen). <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">So my guess for debugging would be: check at every step, what happens to your data.sampleinfo. It’s also worth to read through the command line output because you should get a warning if something funny is going
 on. <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">If you know your sampleinfo to be correct, here a workaround you might want to try:<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">% 1<sup>st</sup> Manually read out the trials that contain artifacts (right after you marked them: cfg_art= ft_databrowser(cfg, data));
<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">a_trials =[]; % trials with artifacts<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">artifacts=cfg_art.artfctdef.visual; % info about the artifacts<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">for n=1:size(artifacts.artifact,1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">    a_trials = [a_trials;find(data.sampleinfo(:,1) <= artifacts.artifact(n,1) ...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">        & data.sampleinfo(:,2) >= artifacts.artifact(n,1))]; %concatenate the trials that contain artifacts<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">end<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">% find out which trials are artefact free<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">trials=1:numel(data.trial); % all the trials<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">trialsel=find(~ismember(trials,a_trials)); % the selected trials are trials that are not member of the artifact trials<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">% Call ft_preprocessing (or ft_selectdata...) to select only the artefact free trials.<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">cfg=[];<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">cfg.trials=trialsel;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">data_clean = ft_selectdata(cfg, data);<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">I hope that helps.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Best,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Sebastian<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 lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> fieldtrip-bounces@science.ru.nl [mailto:fieldtrip-bounces@science.ru.nl]
<b>On Behalf Of </b>Blume Christine<br>
<b>Sent:</b> 13 May 2016 07:23<br>
<b>To:</b> fieldtrip@science.ru.nl<br>
<b>Subject:</b> [FieldTrip] Artefact rejection & ICA on continuous data followed by segmentation<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black">Dear community,
<o:p></o:p></span></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="DE" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">I would like to do the following steps, however fieldtrip does not seem to like this in my case:</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black"> </span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt"><span lang="EN-US" style="color:black">1.</span><span lang="EN-US" style="font-size:7.0pt;font-family:"Times New Roman","serif";color:black">     
</span><span lang="EN-US" style="color:black">Artefact rejection on continuous data using
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_databrowser</span><span lang="EN-US" style="color:black"> as I do not like
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_rejectvisual</span><span lang="EN-US" style="color:black">’s visualization (needs to be done on
<u>continuous data</u> as I will have overlapping segments once I segment, which is not supported by
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_databrowser</span><span lang="EN-US" style="color:black">). Calling
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_rejectartifact</span><span lang="EN-US" style="color:black"> following that procedure to exclude major artefacts before ICA.</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt"><span lang="EN-US" style="color:black">2.</span><span lang="EN-US" style="font-size:7.0pt;font-family:"Times New Roman","serif";color:black">     
</span><span lang="EN-US" style="color:black">ICA on cleaned continuous data, mainly to remove EOG artefacts</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt"><span lang="EN-US" style="color:black">3.</span><span lang="EN-US" style="font-size:7.0pt;font-family:"Times New Roman","serif";color:black">     
</span><span lang="EN-US" style="color:black">Another round of manual/visual artefact rejection on cleaned/eog-rejected continuous data using
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_databrowser</span><span lang="EN-US" style="color:black"> visualization (again, needs to be done on
<u>continuous data</u> as I will have overlapping segments once I segment, which is not supported by
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_databrowser</span><span lang="EN-US" style="color:black">)</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt"><span lang="EN-US" style="color:black">4.</span><span lang="EN-US" style="font-size:7.0pt;font-family:"Times New Roman","serif";color:black">     
</span><span lang="EN-US" style="color:black">Segmentation of cleaned data</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black"> </span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">I am experiencing problems with the artefact rejection (1) and the following segmentation (4), though. It works fine if I segment my data using
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_redefinetrial</span><span lang="EN-US" style="color:black"> and then call
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_rejectartifact
</span><span lang="EN-US" style="color:black">with the cfg returned from the (first) call to
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_databrowser</span><span lang="EN-US" style="color:black">. However, if I reject artefacts first and then try to apply
</span><span lang="EN-US" style="font-family:"Courier New";color:black">ft_redefinetrial</span><span lang="EN-US" style="color:black"> to the cleaned data, “bad” trials are not excluded.</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE" style="color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Any ideas how to solve this are highly appreciated.</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE" style="color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Best,</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Christine</span><span lang="DE" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE" style="color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="DE-AT" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black">  
</span><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE" style="color:black"> <o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>