<div dir="ltr">Sir,<div>This is Abhishek. I am trying to analyse Motor Evoked field MEG data. I have been trying to use the EMG channel as the trial definition for the triggers of epoch creation. But when I use the script that is given in tutorial definition I am getting the following error. </div><div><br></div><div>The Input</div><div><br></div><div><div>cfg = [];</div><div>cfg.dataset    = 'preetham_lt_motor_raw_tsss_mc.fif';</div><div>cfg.trialdef.prestim        = 1;</div><div>cfg.trialdef.poststim       = 0.5;</div><div>cfg.trialfun  = 'trialfun_emgdetect';</div><div>cfg           = ft_definetrial(cfg);</div><div>data          = ft_preprocessing(cfg);</div></div><div><br></div><div>The Error</div><div><br></div><div><div>306 MEG channel locations transformed</div><div>Reading preetham_lt_motor_raw_tsss_mc.fif ...</div><div>Opening raw data file preetham_lt_motor_raw_tsss_mc.fif...</div><div><span style="white-space:pre">  </span>Range : 124000 ... 669999  =     62.000 ...   335.000 secs</div><div>Ready.</div><div>Reading 124000 ... 669999  =     62.000 ...   335.000 secs... [done]</div><div>found 0 events</div><div>created 210265 trials</div><div>the call to "ft_definetrial" took 528 seconds</div><div><span style="white-space:pre"> </span>306 MEG channel locations transformed</div><div>Reading preetham_lt_motor_raw_tsss_mc.fif ...</div><div>Opening raw data file preetham_lt_motor_raw_tsss_mc.fif...</div><div><span style="white-space:pre">    </span>Range : 124000 ... 669999  =     62.000 ...   335.000 secs</div><div>Ready.</div><div>processing channel { 'EOG001' 'ECG002' 'EEG001' 'EEG002' 'EEG003' 'EEG004' 'EEG005' 'EEG006' 'EEG007' 'EEG008' 'EEG009' 'EEG010' 'EEG011' 'EEG012' 'EEG013' 'EEG014' 'EEG015' 'EEG016' 'EEG017' 'EEG018' 'EEG019' 'EEG020' 'EEG021' 'EEG022' 'EEG023' 'EEG024' 'EEG025' 'EXCI' 'IASX+' 'IASX-' 'IASY+' 'IASY-' 'IASZ+' 'IASZ-' 'IAS_DX' 'IAS_DY' 'IAS_X' 'IAS_Y' 'IAS_Z' 'MEG0111' 'MEG0112' 'MEG0113' 'MEG0121' 'MEG0122' 'MEG0123' 'MEG0131' 'MEG0132' 'MEG0133' 'MEG0141' 'MEG0142' 'MEG0143' 'MEG0211' 'MEG0212' 'MEG0213' 'MEG0221' 'MEG0222' 'MEG0223' 'MEG0231' 'MEG0232' 'MEG0233' 'MEG0241' 'MEG0242' 'MEG0243' 'MEG0311' 'MEG0312' 'MEG0313' 'MEG0321' 'MEG0322' 'MEG0323' 'MEG0331' 'MEG0332' 'MEG0333' 'MEG0341' 'MEG0342' 'MEG0343' 'MEG0411' 'MEG0412' 'MEG0413' 'MEG0421' 'MEG0422' 'MEG0423' 'MEG0431' 'MEG0432' 'MEG0433' 'MEG0441' 'MEG0442' 'MEG0443' 'MEG0511' 'MEG0512' 'MEG0513' 'MEG0521' 'MEG0522' 'MEG0523' 'MEG0531' 'MEG0532' 'MEG0533' 'MEG0541' 'MEG0542' 'MEG0543' 'MEG0611' 'MEG0612' 'MEG0613' 'MEG0621' 'MEG0622' 'MEG0623' 'MEG0631' 'MEG0632' 'MEG0633' 'MEG0641' 'MEG0642' 'MEG0643' 'MEG0711' 'MEG0712' 'MEG0713' 'MEG0721' 'MEG0722' 'MEG0723' 'MEG0731' 'MEG0732' 'MEG0733' 'MEG0741' 'MEG0742' 'MEG0743' 'MEG0811' 'MEG0812' 'MEG0813' 'MEG0821' 'MEG0822' 'MEG0823' 'MEG0911' 'MEG0912' 'MEG0913' 'MEG0921' 'MEG0922' 'MEG0923' 'MEG0931' 'MEG0932' 'MEG0933' 'MEG0941' 'MEG0942' 'MEG0943' 'MEG1011' 'MEG1012' 'MEG1013' 'MEG1021' 'MEG1022' 'MEG1023' 'MEG1031' 'MEG1032' 'MEG1033' 'MEG1041' 'MEG1042' 'MEG1043' 'MEG1111' 'MEG1112' 'MEG1113' 'MEG1121' 'MEG1122' 'MEG1123' 'MEG1131' 'MEG1132' 'MEG1133' 'MEG1141' 'MEG1142' 'MEG1143' 'MEG1211' 'MEG1212' 'MEG1213' 'MEG1221' 'MEG1222' 'MEG1223' 'MEG1231' 'MEG1232' 'MEG1233' 'MEG1241' 'MEG1242' 'MEG1243' 'MEG1311' 'MEG1312' 'MEG1313' 'MEG1321' 'MEG1322' 'MEG1323' 'MEG1331' 'MEG1332' 'MEG1333' 'MEG1341' 'MEG1342' 'MEG1343' 'MEG1411' 'MEG1412' 'MEG1413' 'MEG1421' 'MEG1422' 'MEG1423' 'MEG1431' 'MEG1432' 'MEG1433' 'MEG1441' 'MEG1442' 'MEG1443' 'MEG1511' 'MEG1512' 'MEG1513' 'MEG1521' 'MEG1522' 'MEG1523' 'MEG1531' 'MEG1532' 'MEG1533' 'MEG1541' 'MEG1542' 'MEG1543' 'MEG1611' 'MEG1612' 'MEG1613' 'MEG1621' 'MEG1622' 'MEG1623' 'MEG1631' 'MEG1632' 'MEG1633' 'MEG1641' 'MEG1642' 'MEG1643' 'MEG1711' 'MEG1712' 'MEG1713' 'MEG1721' 'MEG1722' 'MEG1723' 'MEG1731' 'MEG1732' 'MEG1733' 'MEG1741' 'MEG1742' 'MEG1743' 'MEG1811' 'MEG1812' 'MEG1813' 'MEG1821' 'MEG1822' 'MEG1823' 'MEG1831' 'MEG1832' 'MEG1833' 'MEG1841' 'MEG1842' 'MEG1843' 'MEG1911' 'MEG1912' 'MEG1913' 'MEG1921' 'MEG1922' 'MEG1923' 'MEG1931' 'MEG1932' 'MEG1933' 'MEG1941' 'MEG1942' 'MEG1943' 'MEG2011' 'MEG2012' 'MEG2013' 'MEG2021' 'MEG2022' 'MEG2023' 'MEG2031' 'MEG2032' 'MEG2033' 'MEG2041' 'MEG2042' 'MEG2043' 'MEG2111' 'MEG2112' 'MEG2113' 'MEG2121' 'MEG2122' 'MEG2123' 'MEG2131' 'MEG2132' 'MEG2133' 'MEG2141' 'MEG2142' 'MEG2143' 'MEG2211' 'MEG2212' 'MEG2213' 'MEG2221' 'MEG2222' 'MEG2223' 'MEG2231' 'MEG2232' 'MEG2233' 'MEG2241' 'MEG2242' 'MEG2243' 'MEG2311' 'MEG2312' 'MEG2313' 'MEG2321' 'MEG2322' 'MEG2323' 'MEG2331' 'MEG2332' 'MEG2333' 'MEG2341' 'MEG2342' 'MEG2343' 'MEG2411' 'MEG2412' 'MEG2413' 'MEG2421' 'MEG2422' 'MEG2423' 'MEG2431' 'MEG2432' 'MEG2433' 'MEG2441' 'MEG2442' 'MEG2443' 'MEG2511' 'MEG2512' 'MEG2513' 'MEG2521' 'MEG2522' 'MEG2523' 'MEG2531' 'MEG2532' 'MEG2533' 'MEG2541' 'MEG2542' 'MEG2543' 'MEG2611' 'MEG2612' 'MEG2613' 'MEG2621' 'MEG2622' 'MEG2623' 'MEG2631' 'MEG2632' 'MEG2633' 'MEG2641' 'MEG2642' 'MEG2643' 'STI101' 'SYS201' 'CHPI001' 'CHPI002' 'CHPI003' 'CHPI004' 'CHPI005' 'CHPI006' 'CHPI007' 'CHPI008' 'CHPI009' }</div><div>reading and preprocessing</div><div>reading and preprocessing trial 1 from 210265</div><div>Reading 264027 ... 4792reading and preprocessing trial 2 from 210265</div><div>Reading 327742 ... 4802reading and preprocessing trial 3 from 210265</div></div><div>.</div><div>.</div><div>.</div><div>.</div><div>.</div><div><div>Reading 635443 ... 66reading and preprocessing trial 116 from 210265</div><div><font color="#ff0000">Error using ft_read_data (line 225)</font></div><div><font color="#ff0000">cannot read data after the end of the file</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">Error in ft_preprocessing (line 582)</font></div><div><font color="#ff0000">      dat = ft_read_data(cfg.datafile, 'header', hdr, 'begsample', begsample, 'endsample', endsample, 'chanindx', rawindx,</font></div><div><font color="#ff0000">      'checkboundary', strcmp(cfg.continuous, 'no'), 'dataformat', cfg.dataformat);</font></div></div><div><font color="#ff0000"><br></font></div><div><br></div><div><br></div><div><font color="#000000">I am new to fieldtrip. Please help me with the above error.</font></div><div><font color="#000000">Regards,</font></div><div><font color="#000000">Abhishek.</font></div></div>