<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<font size="4" class="">Dear Hannah,</font>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class="">From your error, it seems that you called ft_REdefinetrial, rather than ft_definetrial, I am not sure whether that was intended.</font></div>
<div class=""><font size="4" class="">The way forward would be (in your case) </font></div>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class="">cfg = ft_definetrial(cfg);</font></div>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class="">% this yields a cfg.trl matrix that defines epochs  - from - marker1 - to - marker2</font></div>
<div class=""><br class="">
</div>
<div class=""><font size="4" class="">Then, you can use ft_preprocessing(cfg) to load in the epoched data, followed by a call to ft_redefinetrial to cut the epochs into 2 second snippets.</font></div>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class="">Alternatively, you can write a fancy â€™trialfun’ that also incorporates the cutting into epochs of desired length (+desired overlap). Perhaps you can have a look at Appendix 2 of this tutorial: <a href="http://www.fieldtriptoolbox.org/tutorial/coherence/" class="">http://www.fieldtriptoolbox.org/tutorial/coherence/</a>,
 which gives an example of such a trialfun.</font></div>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class="">Best wishes,</font></div>
<div class=""><font size="4" class="">Jan-Mathijs</font></div>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class="">
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 19 Jun 2020, at 05:31, Hannah Anderson <<a href="mailto:handerson@usc.edu.au" class="">handerson@usc.edu.au</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
Dear FieldTrip community </div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
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-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span class="">    Marker Segmentation<span class="Apple-converted-space"> </span><br class="">
</span>
<div class="">    cfg                                      = [];<br class="">
</div>
<div class="">    cfg.dataset                       = d(data).name;<br class="">
</div>
<div class="">    cfg.continuous                 = 'yes';<br class="">
</div>
<div class="">    cfg.trialfun                        = 'trial_fun_startend'; %trial_function for marker segmentation</div>
<div class="">    cfg.trialdef.prestim          = 0.2; %in seconds<br class="">
</div>
<div class="">    cfg.trialdef.poststim        = 0; %in seconds<br class="">
</div>
<div class="">    cfg.trialdef.ntrials             = inf;<br class="">
</div>
<div class=""><br class="">
</div>
<span class="">    cfg                                       = ft_definetrial(cfg);  % define trials</span><br class="">
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
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;" class="">I get an error;</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(200, 38, 19);" class="">-</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(200, 38, 19);" class="">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;" class="">
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);" class="">
<div style="margin: 0px;" class=""><span style="color: rgb(200, 38, 19);" class="">Error in ft_redefinetrial (line 267)</span></div>
<div style="margin: 0px;" class=""><span style="color: rgb(200, 38, 19);" class=""> offset    = newtrl(:,3);</span></div>
</div>
<br class="">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important;" class="">when I try and then segment the trial into 2 second trials with overlap. </span><br class="">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
This is my trialfun:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span class="">function [trl, event] = trial_fun_startend(cfg);<span class="Apple-converted-space"> </span><br class="">
</span>
<div class=""><br class="">
</div>
<div class="">hdr          = ft_read_header(cfg.dataset);<br class="">
</div>
<div class="">event        = ft_read_event(cfg.dataset);<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">detectflank  = 'up';<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">value        = [event(find(strcmp('STATUS', {event.type}))).value]';<br class="">
</div>
<div class="">sample       = [event(find(strcmp('STATUS', {event.type}))).sample]';<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">trl          = [];<br class="">
</div>
<div class="">sel          = find(strcmp({event.type}, 'STATUS'));<br class="">
</div>
<div class="">event        = event(sel)<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">begsample = event(1, 2);<br class="">
</div>
<div class="">endsample = event(1, 3);<br class="">
</div>
<div class="">offset    = newtrl(:,3);<br class="">
</div>
<div class="">trl      = [begsample endsample];<br class="">
</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span class=""><br class="">
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span class="">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;" class="">
<span class=""><br class="">
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span class="">Kind regards, </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<span class="">Hannah </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div id="Signature" class="">
<div class="">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<div style="margin: 0px; color: rgb(32, 31, 30); text-align: start; background-color: rgb(255, 255, 255); font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="margin: 0px; font-size: 10pt; color: rgb(127, 127, 127);" class="">University of the Sunshine Coast  l  CRICOS 01595D</span></div>
</div>
</div>
</div>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://doi.org/10.1371/journal.pcbi.1002202</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</body>
</html>