<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">HI Daniel,<br>
      <br>
      thanks for reporting this. Strange error... but it should not be
      related to having timepoint before 0. The fix of the time-axis in
      raw2timelock was implemented because of numerical inaccuracies
      that can occur across trials. For example, some trials might start
      at -0.24999 others at -0.25 (this can happen during acquisition or
      during resampling, etc., also computers make errors, especially
      when dealing with decimals). When computing a common time-axis,
      Matlab would compare these two values and treat them as two
      samples before 0 rather than 1  (which strictly speaking is true).
      So a common time-axis needs to be build, which is invariant to
      small differences. Unfortunately, that was not very trivial to
      accomplish. I've build a test scripts which tests very many
      different cases for which this function works fine. So first, just
      to be sure, are you using the most recent version of FieldTrip?<br>
      <br>
      Most colleagues in our group including myself are interested in
      the prestimulus period, so if this was a trivial error, we
      probably would have found it long time ago ;) However, it might be
      that it indeed breaks with your data nonetheless due to some
      reason. Since this might be specific to some few datasets, it
      would be great if you could send me a snippet of your data (like
      one or two trials) together with some lines of code to reproduce
      this error. It is quite nasty to debug this stuff, so in order to
      not keep you from doing research, just go ahead with the fix you
      implemented for this one dataset, but be aware that I am pretty
      sure that it will break for other datasets ;)<br>
      <br>
      Best regards,<br>
      Jörn<br>
      <br>
      <br>
      On 3/18/2013 7:18 PM, Daniel Stolzberg wrote:<br>
    </div>
    <blockquote
cite="mid:CAF_tj0eXNStmO8vnNz75NFBbMpK9gc=WjqjM-qd3xSYYMpD84Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hello,
        <div><br>
        </div>
        <div>I have been working with continuous data trials which begin
          before the trigger occurs (ex: [-0.25 1.0] sec) and have run
          into a snag when using ft_singleplotER.  The error occurs in
          the raw2timelock subfunction of ft_checkdata after calling
          ft_singleplotER with a time axis that includes pre-trigger
          (i.e. < 0) time points.  This error may not be for
          ft_singleplotER, but it is the function I was trying to use.<br
            clear="all">
          <div><br>
          </div>
          <div style="">Here is the error:</div>
          <div style="">
            <div>> Subscripted assignment dimension mismatch.</div>
            <div>> </div>
            <div>> Error in ft_checkdata>raw2timelock (line 1753)</div>
            <div>>     tmptrial(i,:,begsmp(i):endsmp(i)) =
              data.trial{i};</div>
            <div>> <br>
            </div>
            <div>> Error in ft_checkdata (line 302)</div>
            <div>>         data = raw2timelock(data);</div>
            <div>> <br>
            </div>
            <div>> Error in ft_singleplotER (line 186)</div>
            <div>>   varargin{i} = ft_checkdata(varargin{i},
              'datatype', {'timelock', 'freq'});</div>
            <div><br>
            </div>
            <div style="">After some debugging, I found that the number
              of samples used to (re)generate the time vector is always
              1 sample too small if there are negative time values.  I
              assume that this is because the time point 0 is not being
              considered (?).  By adding the following line to
              raw2timelock in ft_checkdata of the most recent build, I
              was able to get around any errors in this subfunction and
              all is now copacetic:</div>
          </div>
          <div><br>
          </div>
          <div>
            <div>line 1740:    nsmp = nsmp + any(time<0); % <---
              acounting for timepoint at 0?</div>
          </div>
          <div><br>
          </div>
          <div style="">I don't know if anyone else has run into this
            problem but I thought I would share this with the community.</div>
          <div style=""><br>
          </div>
          <div style="">Regards,</div>
          <div style="">Dan</div>
          <div style=""><br>
          </div>
          -- <br>
          <div dir="ltr">Daniel Stolzberg, PhD
            <div>Post-doctoral Fellow</div>
            <div>Cerebral Systems Laboratory</div>
            <div>Department of Physiology and Pharmacology</div>
            <div>Schulich School of Medicine & Dentistry</div>
            <div>University of Western Ontario</div>
            <div><a moz-do-not-send="true"
                href="http://www.cerebralsystems.ca/" target="_blank">http://www.cerebralsystems.ca/</a><br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
fieldtrip mailing list
<a class="moz-txt-link-abbreviated" href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a>
<a class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Jörn M. Horschig
PhD Student
Donders Institute for Brain, Cognition and Behaviour 
Centre for Cognitive Neuroimaging
Radboud University Nijmegen 
Neuronal Oscillations Group
FieldTrip Development Team

P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Contact:
E-Mail: <a class="moz-txt-link-abbreviated" href="mailto:jm.horschig@donders.ru.nl">jm.horschig@donders.ru.nl</a>
Tel:    +31-(0)24-36-68493
Web: <a class="moz-txt-link-freetext" href="http://www.ru.nl/donders">http://www.ru.nl/donders</a>

Visiting address:
Trigon, room 2.30
Kapittelweg 29
NL-6525 EN Nijmegen
The Netherlands</pre>
  </body>
</html>