<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello all,<div><br></div><div>I am having some further issues reading in my .mff data into fieldtrip. I feel I am getting close but some errors still seem to pop up. The conditions we wish to look at within our data are labeled "2bst" and "2gdv" via E-Prime. The sampling rate is 500. I can provide more information if need be. I will give a brief summary of what I am doing up to this point of error:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">clear <span style="color:rgb(178,69,243)">all</span>;                                      <span style="color:rgb(37,153,45)">% Remove variables from workspace</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">close <span style="color:rgb(178,69,243)">all</span>;                                      <span style="color:rgb(37,153,45)">% Close all open figures</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">ft_defaults;                                    <span style="color:rgb(37,153,45)">% Include only necessary subfolders</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(37,153,45);min-height:12px"> </p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(178,69,243)"><span style="color:rgb(0,0,0)">hdr = ft_read_header(</span>'/Applications/MATLAB_Plugins/AV2_AV.mff'<span style="color:rgb(0,0,0)">);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(178,69,243)"><span style="color:rgb(0,0,0)">dat = ft_read_data(</span>'/Applications/MATLAB_Plugins/AV2_AV.mff'<span style="color:rgb(0,0,0)">);</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(178,69,243)"><span style="color:rgb(0,0,0)">event = ft_read_event(</span>'/Applications/MATLAB_Plugins/AV2_AV.mff'<span style="color:rgb(0,0,0)">) </span><span style="color:rgb(37,153,45)">%Displays some information</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Courier;min-height:14px"><br></p><div>After completing this step, I am able to call upon the header, data, and events with no issue. I can see my different triggers within different events, and so on. At this point, following some walkthroughs on the website, it seems I am also able to "segment" or look at the data with the following code:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier"> hdr = ft_read_header(<span style="color:rgb(178,69,243)">'AV2_AV.mff'</span>);</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">event = ft_read_event(<span style="color:rgb(178,69,243)">'AV2_AV.mff'</span>);</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">sel = [];</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier"><span style="color:rgb(4,51,255)">for</span> i=1:length(event)</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(37,153,45)"><span style="color:rgb(0,0,0)">  </span>% test each event, we are looking for a trigger with value 4</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">  <span style="color:rgb(4,51,255)">if</span> isequal(event(i).type, <span style="color:rgb(178,69,243)">'trigger'</span>) && isequal(event(i).value, <span style="color:rgb(178,69,243)">'2bst'</span>)</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">    sel = [sel; i];</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(4,51,255)"><span style="color:rgb(0,0,0)">  </span>end</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(4,51,255)">end</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(37,153,45)"><span style="color:rgb(0,0,0)">sel = sel(1); </span>% select only the first trigger that was found</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">begsample = event(sel(1)).sample - 0.1*hdr.Fs; <span style="color:rgb(37,153,45)">% select 100ms before the sample of the trigger</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">endsample = event(sel(1)).sample + 0.6*hdr.Fs; <span style="color:rgb(37,153,45)">% select 600ms after the sample of the trigger</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">dat = ft_read_data(<span style="color:rgb(178,69,243)">'AV2_AV.mff'</span>, <span style="color:rgb(178,69,243)">'begsample'</span>, begsample, <span style="color:rgb(178,69,243)">'endsample'</span>, endsample);</p><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier"><br></p>I figured there would be some error here, as there is a lot going on and I am not very skilled at this. I receive an "Index exceeds number of array elements (0)" error.</div><div><br></div><div>An alternative way of doing this perhaps (provided in a script by a colleague) is the following code:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">cfg = [];</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(178,69,243)"><span style="color:rgb(0,0,0)">cfg.datafile = </span>'/Applications/MATLAB_Plugins/AV2_AV.mff'<span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">cfg.trialdef.eventtype = <span style="color:rgb(178,69,243)">'trigger'</span>; <span style="color:rgb(37,153,45)">%'?' for list</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">cfg.trialdef.eventvalue = {<span style="color:rgb(178,69,243)">'2bst'</span> <span style="color:rgb(178,69,243)">'2gdv'</span>};</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">cfg.trialdef.prestim = .1;</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">cfg.trialdef.poststim = .6;</p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;color:rgb(178,69,243)"><span style="color:rgb(0,0,0)">cfg.trialfun = </span>'ft_trialfun_general'<span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier;min-height:12px"> </p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">cfg = ft_definetrial(cfg);</p></div><div><br></div><div>The error I receive here is "Error using ft_definetrial (line 196)</div><div>no trials were defined, see FT_DEFINETRIAL for help"</div><div><br></div><div>I am unsure what this means exactly. Prior to this, I am able to call upon individual events and therefore I know the data is read in at least partially. I can't seem to run anything else before ft_definetrial is completed. Ultimately, our goal is to either process within fieldtrip to perform a cluster-based permutation test on the data- alternatively, we could read in an already processed file. However I believe I read averaged .mff files cannot be read in properly? I may be wrong. </div><div><br></div><div>Many thanks,</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><font face="times new roman, serif"><span style="color:rgb(0,0,0);font-size:12.8px;font-weight:600;line-height:19.2px">Ryan</span><span style="color:rgb(0,0,0);font-size:12.8px"> </span><span style="color:rgb(0,0,0);font-size:12.8px;font-weight:600;line-height:19.2px">Priefer</span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px;line-height:19.2px"></span><span style="color:rgb(0,0,0);font-size:12.8px;font-style:italic;line-height:19.2px">Lab Technical Coordinator</span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px;line-height:19.2px">Communication Sciences and Disorders</span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px;line-height:19.2px">t: 516.877.6787</span></font><br></div></div></div></div></div></div></div></div>