<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Maarten,<br>
<br>
no idea what might go wrong there (for me your code snippet works
fine). Anyway, you could try to first round
cfg.trialdef.prestim*hdr.Fs (same for poststim) outside the loop and
store them as local variables and then continue without having to
round in every single iteration for every single trial-def, e.g.:<br>
<br>
trloff = round(-cfg.trialdef.prestim*hdr.Fs);<br>
trldur = round((cfg.trialdef.poststim+cfg.trialdef.prestim)*hdr.Fs)
- 1;<br>
% that's from trialfun_general<br>
<br>
I bet this will make a difference, although it should of course not.
Maybe someone else can confirm the error with your code snippet...<br>
<br>
Best,<br>
Jörn<br>
<br>
<br>
<br>
On 5/6/2011 2:10 PM, Maarten van-Casteren wrote:
<blockquote
cite="mid:076BBBEE0241DF4FA4F09E43B8EB0176391359F1@WSR21.mrc-cbsu.local"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I've just started to use Fieldtrip and I
don't<o:p></o:p></p>
<p class="MsoNormal">have much experience with Matlab, so I
could<o:p></o:p></p>
<p class="MsoNormal">just be making a stupid mistake, but I
found<o:p></o:p></p>
<p class="MsoNormal">some very strange behavious when I tried to<o:p></o:p></p>
<p class="MsoNormal">specify my own trailfunction.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I started from the example given on the
tutorial<o:p></o:p></p>
<p class="MsoNormal">pages of the wiki. I've indicated the line
of interest<o:p></o:p></p>
<p class="MsoNormal">with an additional '->'. This is what I
used:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN">for i=1:length(event)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> if
strcmp(event(i).type, cfg.trialdef.eventtype)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> % it is a trigger,
see whether it has the right value<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> if
ismember(event(i).value, cfg.trialdef.eventvalue)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> % add this to the
trl definition<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> begsample =
event(i).sample - cfg.trialdef.prestim*hdr.Fs;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> endsample =
event(i).sample + cfg.trialdef.poststim*hdr.Fs - 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> offset =
-cfg.trialdef.prestim*hdr.Fs;
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> trigger =
event(i).value; % remember the trigger (=condition) for each
trial<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN">-> trl(end+1, :) =
[round([begsample endsample offset]) trigger];
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> end<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN"> end<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">end<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">When
I use it like this it will clip all sample and<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">offset
values at 0 – 65536, that is the limits of an<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">unsigned
integer. I had to change the actual line<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">that
appends the trial to this to make it work:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN">trl(end+1, :) =
[double(begsample) double(endsample) double(offset)
double(trigger)];</span><span style="font-size: 12pt;
font-family: "Times New Roman","serif";"
lang="EN"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">All
values are shown by the debugger as doubles<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">anyway,
so why this explicit conversion is needed<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">is
completely beyond me.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">Does
anyone of you know what is going on?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">I
already asked one of the local Matlab gurus,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">but
he was even more amazed than me...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif";" lang="EN">Maarten<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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
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
Kapitelweg 29
NL-6525 EN Nijmegen
The Netherlands</pre>
</body>
</html>