<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><span style="color: rgb(34, 34, 34); font-family: arial; font-size: small; background-color: rgb(255, 255, 255);">Dear Katrin,</span><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255); position: static; z-index: auto;">if you use a custom trialfun (<a href="http://fieldtrip.fcdonders.nl/example/making_your_own_trialfun_for_conditional_trial_definition">http://fieldtrip.fcdonders.nl/example/making_your_own_trialfun_for_conditional_trial_definition</a>) you can code the time between stimulus onset and response in an additional column. That way, you can shift the time axis of the data by this amount on each trial. For example:</div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255); position: static; z-index: auto;"><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);"><span style="color: rgb(0, 0, 0);"> </span>% redefine trials</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> offset = (data.trialinfo(:,RTcol));</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> prestim = 1;</div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);"><span style="color: rgb(34, 34, 34);"> </span><span style="color: rgb(34, 34, 34);">poststim</span><span style="color: rgb(34, 34, 34);"> </span><span style="color: rgb(34, 34, 34);">= 2;</span><br></div><p style="margin: 0px; font-size: 10px; font-family: Courier; min-height: 12px;"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg = [];</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg.begsample = round(offset - prestim*data.fsample);<br></div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg.endsample = round(offset + poststim*data.fsample);</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> data = ft_redefinetrial(cfg, data);</div><p style="margin: 0px; font-size: 10px; font-family: Courier; min-height: 12px;"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);"><span style="color: rgb(0, 0, 0);"> </span>% then shift the time axis</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg = [];</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg.offset = -offset;</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> data = ft_redefinetrial(cfg, data);</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"><br></div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);"><span style="color: rgb(0, 0, 0);"> </span>% timelock</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg = [];</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> cfg.keeptrials = <span style="color: rgb(178, 69, 243);">'yes'</span>;</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"> data = ft_timelockanalysis(cfg, data);</div></div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);">That way, your new data structure will now be response locked. Note that the timelockanalysis is optional, and only works when you have trials that are all the same length. </div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);">If you do not want to use a custom trialfun, you could also rerun the same analysis as you have for the stimulus-locked data, but then taking the response code as your eventvalue.</div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial; background-color: rgb(255, 255, 255);">Good luck,</div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="" style="orphans: auto; text-align: start; text-indent: 0px; widows: auto; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">---<br>Anne E. Urai, MSc<br>PhD student | Institut für Neurophysiologie und Pathophysiologie | Universitätsklinikum Hamburg-Eppendorf</div><div class="" style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><span style="text-align: -webkit-auto; orphans: auto; widows: auto;">Martinistrasse 52, </span><span style="text-align: -webkit-auto; orphans: auto; widows: auto;">20246 Hamburg, </span><span style="text-align: -webkit-auto; orphans: auto; widows: auto;">Germany | </span><span style="text-align: -webkit-auto;"><a href="http://anneurai.wordpress.com">http://anneurai.wordpress.com</a></span></div><div class="" style="orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><br><br><br></div></div></div></div></div></div></div></div>
</div>
<br><div style=""><div>On 28 Sep 2014, at 11:54, KatrinH Heimann <<a href="mailto:katrinheimann@gmail.com">katrinheimann@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Dear all,<div>I know I asked this already twice, but I did not get the right answer yet and just cannot figure it out myself.</div><div style="">So, I did cut my data in quite large trials using ft_define trial and logging it to the beginning of a slide. </div><div style=""><br></div><div style=""><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg = [];</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.dataset = name;</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialfun = <span style="color:rgb(178,69,243)">'ft_trialfun_general'</span>; <span style="color:rgb(37,153,45)">% this is the default</span></div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialdef.eventtype = <span style="color:rgb(178,69,243)">'trigger'</span>;</div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);"><span style="">cfg.trialdef.eventvalue = </span><span style="color:rgb(178,69,243)">'ceck'</span><span style="">; </span>% the value of the stimulus trigger </div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialdef.prestim = 0.216; <span style="color:rgb(37,153,45)">% in seconds</span></div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);"><span style="">cfg.trialdef.poststim = 7.284; </span>% in seconds (max time of check slide)</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg = ft_definetrial(cfg);</div><p style="margin:0px;font-size:10px;font-family:Courier;min-height:12px"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);">% cancel out training trials</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trl([1:4],:) = [];</div><p style="margin:0px;font-size:10px;font-family:Courier;min-height:12px"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);">%change timeline according to constant offset of 16 ms = 8 samples (because recorded with 500 hz)in</div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);">%structure trial - plus delay reported by EGE = 18 ms = 9 samples</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trl(:,3)=cfg.trl(:,3)-17</div><p style="margin:0px;font-size:10px;font-family:Courier;min-height:12px"> <br class="webkit-block-placeholder"></p><p style="margin:0px;font-size:10px;font-family:Courier;min-height:12px"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10px; font-family: Courier; min-height: 12px;"><br></div><div style="margin: 0px; font-size: 10px; font-family: Courier; min-height: 12px;"><span style="font-family:arial;font-size:small"> Then I preprocessed these trials </span><br></div><div style="margin: 0px; font-size: 10px; font-family: Courier; min-height: 12px;"><span style="font-family:arial;font-size:small"><br></span></div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);">%% preprocess data</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.channel = <span style="color:rgb(178,69,243)">'all'</span>;</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.preproc.detrend = <span style="color:rgb(178,69,243)">'yes'</span>;</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.preproc.demean = <span style="color:rgb(178,69,243)">'yes'</span>;</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.preproc.baselinewindow = [-0.1 0]</div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);">% <br></div><div style="margin: 0px; font-size: 10px; font-family: Courier;">mov_data = ft_preprocessing(cfg);</div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(37, 153, 45);">% </div><div><div style="margin: 0px; font-size: 10px; font-family: Courier; color: rgb(178, 69, 243);"><span style="">save (strcat(sb,</span>'mov_data'<span style="">) , </span>'mov_data'<span style="">)</span></div><p style="margin:0px;font-size:10px;font-family:Courier;min-height:12px"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"><br></div></div><div style="">Now I wanna cut out smaller pieces that are centered around another trigger - the response of the subject. I did not use this trigger at the beginning as then defining a baselinewindow is impossible (as the response is always happening at a different time).</div><div style=""><br></div><div style="">I tried to just use ft_definetrial again, as I don't see a possibility to use ft_redefine trial:</div><div style=""><br></div><div style=""><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg = []</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.dataset= strcat(sb,<span style="color:rgb(178,69,243)">'mov_data.mat'</span>)<br></div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialdef.eventtype = <span style="color:rgb(178,69,243)">'trigger'</span>;<br></div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialdef.eventvalue = <span style="color:rgb(178,69,243)">'resp'</span></div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialdef.prestim = 0.75</div><div style="margin: 0px; font-size: 10px; font-family: Courier;">cfg.trialdef.poststim = 0.75</div><p style="margin:0px;font-size:10px;font-family:Courier;min-height:12px"> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10px; font-family: Courier;">mov_data_small = ft_definetrial(cfg)</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"><br></div><div style="margin: 0px; font-size: 10px; font-family: Courier;">but I get the error message:</div><div style="margin: 0px; font-size: 10px; font-family: Courier;"><br></div><p style="margin:0px;font-size:10px;font-family:Courier"></p><div style="margin: 0px;">Error using ft_read_header (line 1833)<br></div><div style="margin: 0px;">unsupported header format (matlab)</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">Error in ft_trialfun_general (line 71)</div><div style="margin: 0px;">hdr = ft_read_header(cfg.headerfile, 'headerformat', cfg.headerformat);</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">Error in ft_definetrial (line 169)</div><div style="margin: 0px;"> [trl, event] = feval(cfg.trialfun, cfg);</div><p style="margin:0px"> </p><div><br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"><span style="font-family:arial;font-size:small"> I wonder if that is as the file produced by fieldtrip during the preprocessing is not one that is specified for ft_read_header - but how do I deal with this?</span><br></div><div style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"><span style="font-family:arial;font-size:small"><br></span></div><div style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"><span style="font-family:arial;font-size:small">Thanks a lot for your help</span></div><div style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"><span style="font-family:arial;font-size:small"><br></span></div><div style="margin: 0px; font-size: 12px; font-family: Courier; min-height: 14px;"><span style="font-family:arial;font-size:small">Katrin</span></div></div></div></div>
_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</blockquote></div><br></body></html>