<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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); background-color: rgb(255, 255, 255);" class="elementToProof">
Dear Nir,<br>
<br>
Thank you very much for this clarification! It does the job indeed. Hopefully the instructions of this option gets edited in future for more clarity.<br>
<br>
Best,<br>
<br>
Zlati<br>
</div>
<div class="elementToProof">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">PhD Researcher</span></div>
<span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt"></span>
<div><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">School of Psychology</span></div>
<span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt"></span>
<div><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">University of Birmingham</span></div>
<div><br>
</div>
<div><span><i><span style="font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 9pt; color: rgb(114, 50, 173);">Please note that I am currently working more flexibly, which</span><span style="font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 9pt; color: rgb(114, 50, 173);">
 may result in sending and </span><span style="color: rgb(114, 50, 173);"><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">responding to emails out of hours,</span><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">
 but </span></span><span style="font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 9pt; color: rgb(114, 50, 173);">there is no expectation on you to do the same.</span></i></span><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Nir Ofir <nirofir2@gmail.com><br>
<b>Sent:</b> Tuesday, April 18, 2023 2:23 PM<br>
<b>To:</b> FieldTrip discussion list <fieldtrip@science.ru.nl><br>
<b>Cc:</b> Zlatomira Ilchovska (PhD Psychology Lab FT) <ZXI820@student.bham.ac.uk><br>
<b>Subject:</b> Re: [FieldTrip] cfg.offset cutting randomly trial length</font>
<div> </div>
</div>
<div>
<table border="0" cellspacing="0" cellpadding="0" align="left" width="100%">
<tbody>
<tr>
<td style="background-color:#ffeb9c; width:10%; border:1px solid #ffeb9c; padding:2pt; border-style:solid; border-color:#9c6500">
<b>CAUTION:</b> This email originated from outside the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe.</td>
</tr>
</tbody>
</table>
<br>
<div>
<div dir="ltr">Dear Zlatomira,
<div><br>
</div>
<div>Assuming that the response comes after t=0, and that the RTs are calculated with respect to t=0, you want to use the negative of the RT in cfg.offset. In your code now, taking the first trial for example, t=0 in <span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><i>data_RT_corr_offset
</i>corresponds to t=-1.249 in </span><i style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">data_RT_corr</i><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">, which is the opposite
 of what you want.</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">Changing </span><i style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">cfg.offset = rts_code</i><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"> into </span><i style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">cfg.offset
 = -rts_code</i><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"> should do the trick.</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><br>
</span></div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Tue, Apr 18, 2023 at 3:43 PM Zlatomira Ilchovska via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Good afternoon,<br>
<br>
I'm using cfg.offset as an option in ft_redefinetrial, for the purpose of offsetting my t=0 to the response time for each trial. My problem is that after doing this successfully, some of my trials are cut at the ends "randomly" (e.g., instead of being -0.15sec.
 +1.55sec. around the new zero point, some are quite randomly cut to, for instance, -0.01sec. +1.0sec. around the new zero time). I am sure that my original trial length before offsetting is long enough to allow for a -0.15sec. +1.55sec. around the new "offset"
 zero point. So it's not a matter of that. I can't seem to figure out where the problem is though. Here is the code I use:<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<i>r500=[1.249;0.99;0.012;1.003;0.868;0.904;0.761;0.75;0.59;1.034;1.137;1.077;0.46;1.833;0.029;1.167;0.907;1.154;0.926;1.386;0.864;0.898;0.864;0.205;1.203;0.943;0.75;1.035;0.953;0.803;0.849;1.126;0.953;1.169;0.86;0.921;1.079;1.003;0.735;0.798;1.101;0.893;0.857;0.906;0.737;0.876;0.993;0.984;0.968;1.04;0.948;0.925;0.866;1.126;1.278;0.933;0.988;0.814;0.841;0.744;1.289;1.29;1.016;1.333;1.08;0.723;1.207;0.83;0.981;0.949;0.839;1.017;1.061;0.681;0.763;1.012;1.327;1.051;1.137;0.888;1.165;1.077;1.248;0.987;0.841;1.016;1.208;0.914;1.286;1.068;1.451;1.337;0.909;1.536;1.495;1.496;1.033;1.082;1.139;0.895;0.892;1.038;0.739;1.726;1.353;1.259;0.922;1.155;0.926;0.956;1.167;1.233;0.824;0.849;1.048;1.28;1.006;0.929;0.801;0.831;1.1;0.894;1.499;0.903;1.154;1.212;0.839;1.209;1.069;1.124;0.936;0.824;0.923;1.15;1.302;0.907;1.422;1.251;0.791;1.13;1.052;0.893;0.885;0.822;1.328;1.138;1.086;1.573;1.084;0.888;1.295;0.987;0.876;1.441;0.971;1.045;1.524;1.121;1.081;1.133;0.984;0.757;1.307;1.183;1.528;0.942;1.06;1.167;0.887;1.068;1.041;0.842;1.202;1.536;1.156;1.233;1.36;0.944;1.34;0.844;1.013;1.034;0.686;0.897;1.28;1.122;1.105;1.206;1.085;1.037;1.169;0.919;0.844;0.869;1.177;0.836;0.737;0.897;0.692;1.509;1.341;1.387;0.74;1.44;1.149;1.067;0.979;0.951;1.068;1.78;1.033;1.281;1.273;1.63;1.007;1.151;0.819;1.718;1.178;1.116;0.941;1.403;1.142;1.406;0.941;0.866;0.844;1.087;0.951;0.945;1.244;1.04;0.856;1.055;0.945;0.821;1.057]
</i><span style="color:rgb(12,100,192)"><i>%the RTs for one example participant</i></span></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>p500=[1;0;1;1;0;1;1;1;1;1;1;0;1;1;1;1;0;0;1;1;1;1;1;1;0;1;1;1;1;1;1;0;1;1;1;1;1;1;1;1;1;1;1;0;1;1;1;1;1;0;1;1;1;1;1;0;1;1;0;1;1;1;1;1;1;1;1;1;1;0;0;1;0;0;1;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;0;1;1;1;1;1;1;1;1;1;0;1;1;0;1;1;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;0;1;1;1;0;1;1;1;1;0;1;1;1;1;1;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;0;1;1;1;1;1;1;1;1;0;1;1;1;1;1;1;1;1;1;0;1;0;1;1;1;1;1;1;0;0;1;1;1;0;1;1;1;1;0;1;1;1;1;1;1;1;0;1;1;1;0;1;1;1;1;1;1;1;0;0;1;1;1;1;1;1;0;0;1;0;1;1;0;1;1;1;1;1;1;1;1;1;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;0;1;0;1;1;1;1;0;1;1;1;1;0;1;1;1]
</i><span style="color:rgb(12,100,192)"><i>%the correct trials for one example participant</i></span><i><br>
</i></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<i><br>
cfg=[];</i></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div><i>cfg.trials=p500 <br>
</i></div>
<i>data_RT_corr = ft_redefinetrial(cfg, data_RT) </i><span style="color:rgb(12,100,192)"><i>%here I just select the trials that are correct and hence have a response time</i></span><i><br>
<br>
</i></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<i>rts_code = round(r500*500) </i><span style="color:rgb(12,100,192)"><i>%here I transform my RTs from seconds to samples (my sampling rate is 500 Hz)</i></span><i><br>
</i></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<i>cfg.offset = rts_code <br>
data_RT_corr_offset = ft_redefinetrial(cfg, data_RT_corr);</i><span style="color:rgb(12,100,192)"><i> %here is where I offset to the new t=0 for each trial</i></span><i><br>
</i>
<div><i>    </i></div>
<div><span style="color:rgb(12,100,192)"><i>% Now make the epochs until +1.55 sec after the new t=0:</i></span></div>
<div><i>cfg = [];</i></div>
<div><i>cfg.toilim = [-0.150 1.550]</i></div>
<div><i>data_RT_corr_offset = ft_redefinetrial(cfg, data_RT_corr_offset); </i><span style="color:rgb(12,100,192)"><i>%adjust the epoch length
</i></span><i><br>
</i></div>
<div><i>   </i></div>
<div>Any suggestions would be very much appreciated. Thank you!<br>
<br>
Best,<br>
</div>
<br>
Zlati<br>
<br>
</div>
<div id="x_m_9222975809072763816m_-2105060711726491524Signature">
<div>
<div id="x_m_9222975809072763816m_-2105060711726491524divtagdefaultwrapper" dir="ltr" style="font-size:12pt; font-family:Calibri,Helvetica,sans-serif; color:rgb(0,0,0)">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">PhD Researcher</span></div>
<span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt"></span>
<div><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">School of Psychology</span></div>
<span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt"></span>
<div><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">University of Birmingham</span></div>
<div><br>
</div>
<div><span><i><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt; color:rgb(114,50,173)">Please note that I am currently working more flexibly, which</span><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt; color:rgb(114,50,173)">
 may result in sending and </span><span style="color:rgb(114,50,173)"><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">responding to emails out of hours,</span><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt">
 but </span></span><span style="font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif; font-size:9pt; color:rgb(114,50,173)">there is no expectation on you to do the same.</span></i></span><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!4480cx1LzwzsXmG5sF0IUsm_9lhmU3BeZ6X5biyPQK7MTTJyANFzykzkSKtNbphe8NJGHpiz7RNnvw_N48PQI1TCHbeg$" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>