<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head><body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear FieldTrip community </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am attempting to define a trial based on a start and end marker, and then cut the trial into 2 second segments with 0.5% overlap. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>    Marker Segmentation <br>
</span>
<div>    cfg                                      = [];<br>
</div>
<div>    cfg.dataset                       = d(data).name;<br>
</div>
<div>    cfg.continuous                 = 'yes';<br>
</div>
<div>    cfg.trialfun                        = 'trial_fun_startend'; %trial_function for marker segmentation</div>
<div>    cfg.trialdef.prestim          = 0.2; %in seconds<br>
</div>
<div>    cfg.trialdef.poststim        = 0; %in seconds<br>
</div>
<div>    cfg.trialdef.ntrials             = inf;<br>
</div>
<div><br>
</div>
<span>    cfg                                       = ft_definetrial(cfg);  % define trials</span><br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I created a trial fun which is successful in creating a trial from start marker to end marker but I get an error <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">I get an error;</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(200, 38, 19);">-</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(200, 38, 19);">Index in position 2 exceeds array
 bounds (must not exceed 2) </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<div style="margin: 0px"><span style="color: rgb(200, 38, 19);">Error in ft_redefinetrial (line 267)</span></div>
<div style="margin: 0px"><span style="color: rgb(200, 38, 19);"> offset    = newtrl(:,3);</span></div>
</div>
<br>
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">when I try and then segment the trial into 2 second trials with overlap. </span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This is my trialfun:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>function [trl, event] = trial_fun_startend(cfg); <br>
</span>
<div><br>
</div>
<div>hdr          = ft_read_header(cfg.dataset);<br>
</div>
<div>event        = ft_read_event(cfg.dataset);<br>
</div>
<div><br>
</div>
<div>detectflank  = 'up';<br>
</div>
<div><br>
</div>
<div>value        = [event(find(strcmp('STATUS', {event.type}))).value]';<br>
</div>
<div>sample       = [event(find(strcmp('STATUS', {event.type}))).sample]';<br>
</div>
<div><br>
</div>
<div>trl          = [];<br>
</div>
<div>sel          = find(strcmp({event.type}, 'STATUS'));<br>
</div>
<div>event        = event(sel)<br>
</div>
<div><br>
</div>
<div>begsample = event(1, 2);<br>
</div>
<div>endsample = event(1, 3);<br>
</div>
<div>offset    = newtrl(:,3);<br>
</div>
<div>trl      = [begsample endsample];<br>
</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>I am not sure what else I can try as the other define trial options segment the data into two trials (one for each trigger) and I need it to be one dataset starting at trigger 1 and ending at trigger 2. If anyone could offer some advice/assistance it
 would be greatly appreciated. </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>Kind regards, </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>Hannah </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">
<p style="color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px">
<span style="margin:0px; font-size:10pt; color:rgb(127,127,127)">University of the Sunshine Coast  l  CRICOS 01595D</span></p>
</div>
</div>
</div>
</div>


</body></html>