<div dir="ltr"><div><div>Hello Elisa,<br><br></div>I prefer writing my own functions/scripts for custom problems like this rather than using packaged functions like 'findpeaks' which barely address individualized requirements. For your specific question, given your external trigger generates similar signals every time (that is, amplitude of waviness in the signal and step function amplitude remains comparable - at least amplitude of step function is at least twice the height of waviness - in short, good 'signal-to-noise' ratio), you should use numerical differential of your signal to find peak/troughs and then select the ones with your desired step function amplitude. <br>

<br>If the external trigger output is saved as YourSignal (nx1 vector, with no clipping of step functions at beginning/end of saved output) in matlab workspace and you want a step function that is bigger than YourThreshold (1x1 scalar), try the following commands:<br>

peaktroughindex=find(diff(sign(diff([0;0;YourSignal])));<br>diffval=[0;diff(YourSignal(peaktroughindex))];<br>stepstartindex=peaktroughindex(find(diffval>YourThreshold));<br>stependindex=peaktroughindex(find(diffval<-YourThreshold));<br>

</div><div>stepmiddleindex=round(stepstartindex/2+stependindex/2);<br></div><div><br></div><div>Please excuse any typos - I quickly scribbled it and did not test it in the editor - I will be happy to follow-up on it if you need.<br>

</div><div><br></div><div></div><div>Hope this helps,<br>Pratik.<br></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><div>----</div><div><br></div>Pratik Yashvant Chhatbar, MBBS, PhD<div>Postdoctoral Scholar, Feng Lab<br>

Stroke Center at Neurology Division<br></div><div>MUSC Neurosciences, Charleston, SC<br>Desk: 843-792-3112<br>Cell: 917-892-2314<br></div><div style="padding-left:1px;width:1px;margin-right:0px"></div><div style="padding-left:1px;width:1px;margin-right:0px">

</div></div></div>
<br><br><div class="gmail_quote">On Thu, Jul 3, 2014 at 5:11 PM, Elisa Carlino <span dir="ltr"><<a href="mailto:elisa.carlino@gmail.com" target="_blank">elisa.carlino@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"><div><div><div><div><div><div><div><div><div><div><div><div><div>Dear all,<br></div>i have the following problem on my EEG data.<br></div>I have a noisy wave generated by an external trigger <br></div>and I need to transform this wave into squared waves<br>


in order to use these waves as events for the<br></div>erp analysis.<br><br></div>I attach a jpg of my wave (first line in blu) and a set<br></div>of waves that i desire (red waves): i need <br>- squared waves or<br>- the first peak of each wave (desirable option) or<br>


</div><div>- the middle peak of each wave or<br></div><div>- the final peak of each wave.<br></div><div>With the peak I can subsequently epoch<br></div></div>the EEG and analyze the ERPs.<br><br></div>I looked at this function: <br>


[pks,locs] = findpeaks(canaleTrigger,'MinPeakHeight',2000000,'MinPeakDistance',100,'THRESHOLD',2000000);<br><br></div>I tried to change the values but unsuccessfully. <br></div>When I apply this function the program finds too many peaks<br>


and not the first peak of each wave.<br></div><div>Is this function correct? How can I successfully apply the function?<br></div><div>Are there other ways to solve this problem?<br></div><div><br></div>Thanks,<br><br></div>


Elisa<br></div>
<br>_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu">eeglablist-request@sccn.ucsd.edu</a><br></blockquote></div><br></div></div>