<div dir="ltr">Hi Rachel,<div><br></div><div>Given that you already have the data imported into matlab and organized into trials, try creating a structure 'data' with the following fields (i.e. data.label, data.time, data.trial) and the following dimensions:</div><div><br></div><div><pre style="white-space:pre-wrap;padding:0.5em;margin-top:0px;font-size:12px;border:1px dashed rgb(204,204,204);color:rgb(0,0,0);overflow:hidden;font-family:Consolas,'Andale Mono',Menlo,Monaco,monospace;background-color:rgb(247,249,250);width:640px;text-align:justify">label: {151x1 cell} the channel labels (e.g. 'MRC13')
time: {1x266 cell} the timeaxis [1*Ntime double] per trial
trial: {1x266 cell} the numeric data [151*Ntime double] per trial</pre></div><div>Then, for a proof of principle, try:</div><div><br></div><div>cfg = [];</div><div>cfg.demean = 'yes';</div><div>data2 = ft_preprocessing(cfg, data);</div><div><br></div><div>Let us know if this worked for you.</div><div>Arjen<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-07-15 9:51 GMT-07:00 Nakyung Lee <span dir="ltr"><<a href="mailto:rleese12@berkeley.edu" target="_blank">rleese12@berkeley.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Jan-Mathijs,<div><br></div><div>Thanks for your advice.</div><div>Yes, I used 'ft_=definetrial' to segment the data.</div><div>My data is in the fieldtrip style data format not because it's been segmented and preprocessed through fieldtrip but because our original dataformat is unsupported by fieldtrip (.Tbk, .Tdx, .tev, .tsq to be exact).</div><div>So my coworker transformed those data into a .mat file and I transformed into a fieldtrip style raw data but it still needs some segmenting and some other preprocessing done on it (for example high-gamma filtering).</div><div>But if 'ft_preprocessing'<span style="font-size:12.8px"> is only useable when reading proprietary data from disk, there's just no way we can preprocess the above data using fieldtrip?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thank you,</span></div><div><span style="font-size:12.8px">Rachel</span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 15, 2016 at 1:10 AM, Schoffelen, J.M. (Jan Mathijs) <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
Hi Rachel,
<div><br>
</div>
<div>Once your data is represented in a fieldtrip-style structure, there’s no need anymore to call ft_definetrial with a specified named dataset in the cfg.</div>
<div><br>
</div>
<div>If you want to segment your data, you may still want to call ft_definetrial to generate a so-called ‘trl’ matrix, and subsequently use ft_redefinetrial to re-segment, i.e.:</div>
<div><br>
</div>
<div>load(’signal_raw.mat’); % I assume that this files contains the fieldtrip-style data structure</div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.trl = trl;</div>
<div>data_epoched = ft_redefinetrial(cfg, data);</div>
<div><br>
</div>
<div>So, note that ft_preprocessing shouldn’t be called, this is onlyl useable when reading proprietary data from disk.</div>
<div><br>
</div>
<div>It seems that you don’t need the cfg.dataset argument to begin with, and if you manage to titrate your ft_trialfun_test such that it converts the timestamps you provide it with into the correct trl-matrix, I don’t see a reason why it shouldn’t
work.</div>
<div><br>
</div>
<div>Best,</div>
<div>Jan-Mathijs</div><div><div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div>On 15 Jul 2016, at 08:49, Nakyung Lee <<a href="mailto:rleese12@berkeley.edu" target="_blank">rleese12@berkeley.edu</a>> wrote:</div>
<br>
<div>
<div dir="ltr">
<div>Hi Arjen,</div>
<div><br>
</div>
<div>Thank you for your reply.</div>
<div>Your email got forwarded successfully.</div>
<div><br>
</div>
<div>So currently I tried using 'ft_definetrial' and 'ft_preprocessing'.</div>
<div>'ft_definetrial' returns an error when used with 'ft_trialfun' set to default.</div>
<div>Below is the code I used (and 'signal_raw.mat' is a fieldtrip raw data and it has all three fields you mentioned).</div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">cfg.dataset = 'signal_raw.mat';</font></div>
<div><font color="#0b5394">cfg.trialdef.event = subj_globals.buttonpress_times;</font></div>
<div><font color="#0b5394">cfg = ft_definetrial(cfg);</font></div>
<div><br>
</div>
<div>So I simply call ft_definetrial with minimal configuration and here's the error I got:</div>
<div><font color="#0b5394"><br>
</font></div>
<div>
<div><font color="#0b5394">Error using ft_read_header (line 2194)</font></div>
<div><font color="#0b5394">unsupported header format "matlab"</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">Error in ft_trialfun_general (line 78)</font></div>
<div><font color="#0b5394">hdr = ft_read_header(cfg.headerfile, 'headerformat', cfg.headerformat);</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">Error in ft_definetrial (line 177)</font></div>
<div><font color="#0b5394"> [trl, event] = feval(cfg.trialfun, cfg);</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">Error in trialdef_alsotest (line 12)</font></div>
<div><font color="#0b5394">cfg = ft_definetrial(cfg);</font></div>
</div>
<div><font color="#0b5394"><br>
</font></div>
<div>I circumvented this issue by using my own trialfun ('ft_trialfun_test' in the code).</div>
<div>We already have all the necessary timestamps so I could build a very simple one.<br>
</div>
<div>Here's a new code (I ran the code with minimal cfg for 'ft_preprocessing' to isolate the problem):</div>
<div><font color="#0b5394"><br>
</font></div>
<div>
<div><font color="#0b5394">cfg.dataset = 'signal_raw.mat';</font></div>
<div><font color="#0b5394">cfg.trialfun = 'ft_trialfun_test'; </font></div>
<div><font color="#0b5394">cfg.trialdef.event = subj_globals.buttonpress_times;</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">cfg = ft_definetrial(cfg);</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">cfg.continuous = 'yes';</font></div>
<div><font color="#0b5394">buttonpress_hg = ft_preprocessing(cfg);</font></div>
</div>
<div><br>
</div>
<div>And here's the error I got:</div>
<div><br>
</div>
<div>
<div><font color="#0b5394">Error using ft_read_header (line 2194)</font></div>
<div><font color="#0b5394">unsupported header format "matlab"</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">Error in ft_preprocessing (line 397)</font></div>
<div><font color="#0b5394"> hdr = ft_read_header(cfg.headerfile, 'headerformat', cfg.headerformat, 'coordsys', cfg.coordsys, 'coilaccuracy',</font></div>
<div><font color="#0b5394"> cfg.coilaccuracy);</font></div>
<div><font color="#0b5394"><br>
</font></div>
<div><font color="#0b5394">Error in test_trialdef (line 18)</font></div>
<div><font color="#0b5394">buttonpress_hg = ft_preprocessing(cfg);</font></div>
</div>
<div><br>
</div>
<div>So both error come from 'ft_read_header'.</div>
<div>I've been looking at the code but it seemed quite hard to debug as 'ft_read_header' uses a lower level function that directly reads from the file (hence it seemed like a simple fix like passing in a fake header wouldn't work).</div>
<div>Am I doing something wrong here?</div>
<div><br>
</div>
<div>Again, thank you for your reply and let me know if you need more information.</div>
<div><br>
</div>
<div>Best,</div>
<div>Rachel</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Jul 14, 2016 at 12:10 AM, Arjen Stolk <span dir="ltr">
<<a href="mailto:a.stolk8@gmail.com" target="_blank">a.stolk8@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Rachel,<br>
<br>
What is the error you're receiving, and how are you calling ft_preprocessing?<br>
<br>
If the data is in raw format (incl a trial, time and label field), it should theoretically be possible to use ft_preprocessing on it, eg;<br>
cfg = []<br>
cfg ..<br>
data = ft_preprocessing(cfg, raw)<br>
<br>
where raw is your data as described above.<br>
<br>
Best,<br>
Arjen<br>
<div>
<div><br>
> On Jul 13, 2016, at 11:50 PM, Nakyung Lee <<a href="mailto:rleese12@berkeley.edu" target="_blank">rleese12@berkeley.edu</a>> wrote:<br>
><br>
> Dear FieldTrip community,<br>
><br>
> My name is Rachel Lee and I'm a research assistant in Prof. Ming Hsu's lab in UC Berkeley.<br>
><br>
> We currently have a .Tbk file, a .Tdx file, .tev file, .tsq file to preprocess and analyze but it seems like those data formats are not yet supported by FieldTrip.<br>
> So, instead of using those raw data files, we've been trying to find a workaround by transforming them into a .mat file (and casting the .mat file into a raw datatype in FieldTrip by manually assigning fields to it).<br>
> This hasn't been so successful; we've been unable to call ft_preprocessing because of the lack of a proper header format (which is needed in ft_read_header, one of the lower level functions that ft_preprocessing calls).<br>
> I've been looking at the codes but been unable to come up with a solution.<br>
><br>
> Does anyone have a similar experience?<br>
> Is there any way to circumvent this issue?<br>
> Any type of help would be appreciated.<br>
><br>
> Thank you,<br>
> Rachel Lee<br>
</div>
</div>
> _______________________________________________<br>
> fieldtrip mailing list<br>
> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
> <a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</blockquote>
</div>
<br>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br>
</div>
</div></div></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>