<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="">
Dear Yan,<br class="">
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class=""><br class="">
</div>
<div class="">The relevant code section for you (which also explains why it does not work) is l 215-223 (in the current FT master branch on github, but very likely the same line numbers apply to any sufficiently up-to-date FT version) of ft_trialfun_general:</div>
<div class=""><br class="">
</div>
<div class="">
<table class="highlight js-file-line-container tab-size" data-tab-size="2" data-paste-markdown-skip="" style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; tab-size: 2; caret-color: rgb(36, 41, 46); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px;">
<tbody style="box-sizing: border-box;" class="">
<tr style="box-sizing: border-box;" class="">
<td id="LC213" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
</td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L215" class="blob-num js-line-number" data-line-number="215" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC215" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">if</span> isnumeric(event(i).value)</td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L216" class="blob-num js-line-number" data-line-number="216" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC216" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
val = [val; event(i).value];</td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L217" class="blob-num js-line-number" data-line-number="217" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC217" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">elseif</span> ischar(event(i).value)
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">&&</span> numel(event(i).value)>1
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">&&</span> (event(i).value(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">1</span>)==<span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);"><span class="pl-pds" style="box-sizing: border-box;">'</span>S<span class="pl-pds" style="box-sizing: border-box;">'</span></span>||
 event(i).value(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">1</span>)==<span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);"><span class="pl-pds" style="box-sizing: border-box;">'</span>R<span class="pl-pds" style="box-sizing: border-box;">'</span></span>)</td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L218" class="blob-num js-line-number" data-line-number="218" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC218" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
<span class="pl-c" style="box-sizing: border-box; color: rgb(106, 115, 125);"><span class="pl-c" style="box-sizing: border-box;">%</span> on brainvision these are called 'S 1' for stimuli or 'R 1' for responses</span></td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L219" class="blob-num js-line-number" data-line-number="219" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC219" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
val = [val; str2double(event(i).value(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">2</span>:<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">end</span>))];</td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L220" class="blob-num js-line-number" data-line-number="220" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC220" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">else</span></td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L221" class="blob-num js-line-number" data-line-number="221" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC221" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
val = [val; <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">
nan</span>];</td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L222" class="blob-num js-line-number" data-line-number="222" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC222" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">end</span></td>
</tr>
<tr style="box-sizing: border-box;" class="">
<td id="L223" class="blob-num js-line-number" data-line-number="223" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;">
</td>
<td id="LC223" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; word-wrap: normal;">
<br class="">
<font color="#d73a49" face="SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace" class=""><span style="font-size: 12px; white-space: pre;" class=""><br class="">
</span></font></td>
</tr>
</tbody>
</table>
<div class="">In your case event(i).value looks like ’11’, i.e. the code does not get past the ‘if’ and ‘elseif’, causing the variable nan to be all ’NaN’. As a consequence, the val variable will not make it into the trialinfo field. </div>
<div class=""><br class="">
</div>
<div class="">Given the fact that it is reasonable to expect that an eventvalue that represents a meaningful number as a string ends up in the trialinfo, another ‘elseif’ statement might need to be added to the code, which handles your use case.</div>
<div class=""><br class="">
</div>
<div class="">Perhaps you could try and come up with a possible solution yourself, and submit this as a pull request on github? </div>
<div class=""><br class="">
</div>
<div class="">Looking forward to your contribution.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 26 Aug 2020, at 04:07, liyy90 <<a href="mailto:liyy90@163.com" class="">liyy90@163.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class="">
<div style="margin:0;" class="">Dear List,</div>
<div style="margin:0;" class=""><br class="">
</div>
<div style="margin:0;" class="">When I use the following code to define trials and preprocess my data, I got no trialinfo in my data structure. </div>
<div style="margin:0;" class="">I need the trialinfo to extract different condition epochs in the following ERP analysis and I have no idea how to fix it. </div>
<div style="margin:0;" class="">Hope anyone can help.</div>
<div style="margin:0;" class=""><br class="">
</div>
<div style="margin:0;" class="">
<div style="margin:0;" class="">cfg = [];</div>
<div style="margin:0;" class="">cfg.dataset             = 'raw_data/sample_data.set';</div>
<div style="margin:0;" class="">cfg.trialfun           = 'ft_trialfun_general'; </div>
<div style="margin:0;" class="">cfg.trialdef.eventtype = 'trigger';</div>
<div style="margin:0;" class="">cfg.trialdef.eventvalue = {'11', '12', '13', '14'};</div>
<div style="margin:0;" class="">cfg.trialdef.prestim = 0.2; </div>
<div style="margin:0;" class="">cfg.trialdef.poststim = 0.8;</div>
<div style="margin:0;" class="">cfg      = ft_definetrial(cfg);</div>
<div style="margin:0;" class=""><br class="">
</div>
<div style="margin:0;" class="">
<div style="margin:0;" class="">data        = ft_preprocessing(cfg);</div>
<div class=""><br class="">
</div>
<div class="">And the result in data structure:</div>
<div class=""><span id="cid:3cd1c95f$1$17428853db4$Coremail$liyy90$163.com" class=""><image.png></span></div>
</div>
</div>
<div style="margin:0;" class=""><br class="">
</div>
<div style="margin:0;" class="">Many thanks.</div>
<div style="margin:0;" class="">Yan</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
<br class="">
</div>
<br class="">
</body>
</html>