<div dir="ltr">Hi Harsimrat,<div><br></div><div style>One way this could be achieved is by reading in the specific channel by calling ft_read_data, just like calling ft_read_event and ft_read_header. On how to specify the call to ft_read_data, please see the documentation/help of the function. </div>

<div style><br></div><div style>Hope it helps,</div><div style>Roemer</div><div style><br></div><div style><br></div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 18, 2013 at 5:50 PM, Harsimrat Singh <span dir="ltr"><<a href="mailto:singhharsimrat@gmail.com" target="_blank">singhharsimrat@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="color:#1f497d"></span><div class="gmail_quote"><div link="blue" vlink="purple" lang="EN-GB">

<div>
<p class="MsoNormal"><span style="color:#1f497d"></span></p>
<p class="MsoNormal">Hi All<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am trying to read in my data in which the first channel contains the marker signal (spike) superimposed on the trigger channel.<u></u><u></u></p>
<p class="MsoNormal">I would like to use mytrialfun before ft_definetrial. To do this I would like to check the value of the marker channel and compare it with mean value of the channel and record that value in the even field.<u></u><u></u></p>




<p class="MsoNormal">But I guess I can’t do it as the fieldtrip doesn’t read the channel values before ft_definetrial.  Can I use data channel values in mytrialfun? If not, is there a way around this?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Here is my trialfun<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif";color:blue">function</span><span style="font-size:10.0pt;font-family:"Courier New","serif""> [trl, event] = mytrialfun(cfg)</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif";color:forestgreen">% read the header information and the events from the data</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">hdr   = ft_read_header(cfg.datafile);</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">event = ft_read_event(cfg.datafile,</span><span style="font-size:10.0pt;font-family:"Courier New","serif";color:#a020f0">'trigindx'</span><span style="font-size:10.0pt;font-family:"Courier New","serif"">,1,</span><span style="font-size:10.0pt;font-family:"Courier New","serif";color:#a020f0">'threshold'</span><span style="font-size:10.0pt;font-family:"Courier New","serif"">,5e2,</span><span style="font-size:10.0pt;font-family:"Courier New","serif";color:#a020f0">'detectflank'</span><span style="font-size:10.0pt;font-family:"Courier New","serif"">,</span><span style="font-size:10.0pt;font-family:"Courier New","serif";color:#a020f0">'up'</span><span style="font-size:10.0pt;font-family:"Courier New","serif"">);</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif";color:forestgreen">% search for "trigger" events according to 'trigchannel' defined outside the function</span><font><span style="font-family:"Courier New","serif""></span></font></p>



<font>
</font><p class="MsoNormal"><font><span style="font-family:"Courier New","serif"">The problem lies here</span></font></p><p class="MsoNormal"><font><span style="font-family:"Courier New","serif""></span></font><b><span style="font-size:14.0pt;font-family:"Courier New","serif""></span></b></p>



<p class="MsoNormal" style="text-autospace:none"><font size="4"><b><span style="font-family:"Courier New","serif"">value = [event(find(cfg.trialdef.trigchannel<font color="#ff0000"> (it needs data of this channel & not channel name)</font>)>mean(cfg.trialdef.trigchannel)+500)]</span></b></font><span style="font-size:10.0pt;font-family:"Courier New","serif";color:forestgreen">
 %mkrchannel is data.trial{1}(1,:));</span><span style="font-size:12.0pt;font-family:"Courier New","serif""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif";color:forestgreen">% creating your own trialdefinition based upon the events</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif";color:blue">for</span><span style="font-size:10.0pt;font-family:"Courier New","serif""> j = 1:length(value);</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">    trlbegin = sample(j) + pretrig;</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">    trlend   = sample(j) + posttrig;</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">    offset   = pretrig;</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">    newtrl   = [ trlbegin trlend offset];</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif"">    trl      = [ trl; newtrl]; 
</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New","serif";color:blue">end</span><span style="font-size:12.0pt;font-family:"Courier New","serif""><u></u><u></u></span></p>




<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks in advance<u></u><u></u></p>
<p class="MsoNormal">Best regards<span class="HOEnZb"><font color="#888888"><span><font color="#888888"><u></u><u></u></font></span></font></span></p><span class="HOEnZb"><font color="#888888"><span><font color="#888888">
<p class="MsoNormal">Harsimrat<u></u><u></u></p>
</font></span></font></span></div>
</div>

</div><br></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" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div><br clear="all"><div><br></div>-- <br><font size="3"><font color="darkblue"><font face="calibri">Roemer
            van der Meij M.Sc.<br>
            PhD Candidate<br>
            Donders Institute for Brain, Cognition and Behaviour<br>
            Centre for Cognition<br>
            P.O. Box 9104<br>
            6500 HE Nijmegen<br>
            The Netherlands<br>
            Tel: +31(0)24 3655932<br>
            E-mail: <a href="mailto:r.vandermeij@donders.ru.nl" target="_blank">r.vandermeij@donders.ru.nl</a></font></font></font><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">

</div>