<div dir="ltr"><div>Hi Martin,</div><div><br></div><div>If I understand correctly: If you add columns<b> to your .trl field</b> (so after the first 3 that define start/end/offset samples) which you feed into ft_preprocessing,
ft_preprocessing
will create the .trialinfo field for you, which should track through your analyses.<br></div><div><br></div><div>Cheers,</div><div>Stephen<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 16 Jan 2019 at 17:15, Martin Rosenfelder <<a href="mailto:martin.rosenfelder@uni-ulm.de">martin.rosenfelder@uni-ulm.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Stephen,<br>
<br>
Exactly, preferably, the events should be single values in a struct array or a cell array. <br>
This can then be added to the existing trial array. So far so good. <br>
<br>
However, my dataset misses a .trialinfo field after calling ft_preprocessing, to which I could add the cell array with the condition labels. <br>
I then added the array with the condition labels to 'mydataset.trial'. Unfortunately, this seems to confuse the ft_rejectvisual I call afterwards for artifact rejection.<br>
Do I have to create the .trialinfo-field by hand to my dataset?<br>
<br>
Best,<br>
Martin <br>
<br>
<br>
-- <br>
M.Sc.-Psych. Martin Rosenfelder<br>
Wissenschaftlicher Mitarbeiter<br>
Klinische und Biologische Psychologie<br>
Universität Ulm<br>
Raum 47.2.259<br>
+49 731-50 26592<br>
<a href="mailto:martin.rosenfelder@uni-ulm.de" target="_blank">martin.rosenfelder@uni-ulm.de</a> <br>
<br>
Am Dienstag, 15. Januar 2019 17:40 CET, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank">stephen.whitmarsh@gmail.com</a>> schrieb: <br>
<br>
> Hi Martin,<br>
> <br>
> No indeed, your conditions/RT/events should indeed be (re)coded as single<br>
> values. This also makes selecting trials etc. much easier with logical<br>
> expressions, e.g. you can then simply do cfg.trials = (data.trialinfo(:,1)<br>
> == 3 && data.trialinfo(:,2) > 0.5, where the first column e.g. is your<br>
> condition, and the second RT, to just give an example.<br>
> <br>
> Cheers,<br>
> Stephen<br>
> <br>
> On Tue, 15 Jan 2019 at 17:35, Martin Rosenfelder <<br>
> <a href="mailto:martin.rosenfelder@uni-ulm.de" target="_blank">martin.rosenfelder@uni-ulm.de</a>> wrote:<br>
> <br>
> > Dear Stephen,<br>
> ><br>
> > Thank you very much for the hint on ft_selectdata.<br>
> ><br>
> > I tried to build the structure for .trialinfo as you described it in your<br>
> > reply. I did this creating a structure array with the eventvalues as<br>
> > elements.<br>
> > Then I concatenated the .trl matrix and the event value matrix. This<br>
> > however failed, since .trl is a double array and the event value matrix is<br>
> > a struct array.<br>
> > I double-checked that the nr. of rows in the two matrices match each other<br>
> > (120 elements).<br>
> ><br>
> > Is there a way to add the event value matrix (120x1 struct) to the .trl<br>
> > matrix (120x3 double)?<br>
> ><br>
> > Best,<br>
> > Martin<br>
> ><br>
> ><br>
> > --<br>
> > M.Sc.-Psych. Martin Rosenfelder<br>
> > Wissenschaftlicher Mitarbeiter<br>
> > Klinische und Biologische Psychologie<br>
> > Universität Ulm<br>
> > Raum 47.2.259<br>
> > +49 731-50 26592<br>
> > <a href="mailto:martin.rosenfelder@uni-ulm.de" target="_blank">martin.rosenfelder@uni-ulm.de</a><br>
> ><br>
> > Am Montag, 14. Januar 2019 19:01 CET, Stephen Whitmarsh <<br>
> > <a href="mailto:stephen.whitmarsh@gmail.com" target="_blank">stephen.whitmarsh@gmail.com</a>> schrieb:<br>
> ><br>
> > > Dear Martin,<br>
> > ><br>
> > > Use ft_selectdata instead of ft_redefinetrial.<br>
> > ><br>
> > ><br>
> > "cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue(1,2)"<br>
> > > is scary! And I can imagine very inconvenient, as it will move deeper and<br>
> > > deeper in to infinite previousnessness.<br>
> > > Instead, one of the best 'easter eggs' (i.e. not so well-documented<br>
> > > functionality) of FieldTrip is to create extra columns of info in your<br>
> > .trl<br>
> > > when using preprocessing to epoch your data. These extra columns will<br>
> > then<br>
> > > enter into a field .trialinfo of your data. Most if not all functions,<br>
> > such<br>
> > > as ft_selectdata (selecting trials) will update that field. So I advice<br>
> > you<br>
> > > to put your eventvalue (as well as RT, response, etc. etc.) as columns in<br>
> > > your trialinfo (so same nr. of rows as your nr. of trials). In this way,<br>
> > > they will travel with your data, and stay in the same structure and on<br>
> > the<br>
> > > same level whatever happens.<br>
> > ><br>
> > > Cheers,<br>
> > > Stephen<br>
> > ><br>
> > ><br>
> > > On Mon, 14 Jan 2019 at 18:47, Martin Rosenfelder <<br>
> > > <a href="mailto:martin.rosenfelder@uni-ulm.de" target="_blank">martin.rosenfelder@uni-ulm.de</a>> wrote:<br>
> > ><br>
> > > > Dear Fieldtrip community,<br>
> > > ><br>
> > > > I have preprocessed a single dataset with two different conditions<br>
> > > > ('Swim', 'Rest'). The conditions are stored in the 'eventvalue' field<br>
> > of<br>
> > > > the cfg as 1x2 cell array. The event values are stored in the<br>
> > > ><br>
> > 'data_ref.cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue'<br>
> > > > field of the data set.<br>
> > > > Having done the preprocessing I now would like to do<br>
> > ft_timelockanalysis<br>
> > > > and ft_freqanalysis on the data. Afterwards I statistically compare<br>
> > the two<br>
> > > > conditions using ft_timelockstatistics and ft_freqstatistics.<br>
> > > > How can I split the data set according to the event values ('Swim',<br>
> > > > 'Rest')? I need the event values to split the data set into the two<br>
> > trial<br>
> > > > classes in the ft_timelockanalysis / ft_freqanalysis and to compare<br>
> > these<br>
> > > > two conditions.<br>
> > > ><br>
> > > > I tried ft_redefinetrial, but do not know how to define the cfg.trials<br>
> > > > field of this function.<br>
> > > ><br>
> > > > % trial redefinition<br>
> > > ><br>
> > > > % containing only trials in the 'swim' condition<br>
> > > > cfg.trials = (1,<br>
> > > ><br>
> > data_ref.cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue(1,1));<br>
> > > > swim = ft_redefinetrial(cfg,data_ref);<br>
> > > ><br>
> > > > % containing only trials in the 'resting' condition<br>
> > > > cfg.trials = (1,<br>
> > > ><br>
> > data_ref.cfg.previous.previous.previous{1,1}.previous.previous.trialdef.eventvalue(1,2));<br>
> > > > rest = ft_redefinetrial(cfg,data_ref);<br>
> > > ><br>
> > > > I hope the description was quite clear. In case, I can provide some<br>
> > more<br>
> > > > lines of code to clarify the issue.<br>
> > > ><br>
> > > > Thank you very much in advance for your advice!<br>
> > > ><br>
> > > > Best regards,<br>
> > > > Martin<br>
> > > ><br>
> > > > --<br>
> > > > M.Sc.-Psych. Martin Rosenfelder<br>
> > > > Wissenschaftlicher Mitarbeiter<br>
> > > > Klinische und Biologische Psychologie<br>
> > > > Universität Ulm<br>
> > > > Raum 47.2.259<br>
> > > > +49 731-50 26592<br>
> > > > <a href="mailto:martin.rosenfelder@uni-ulm.de" target="_blank">martin.rosenfelder@uni-ulm.de</a><br>
> > > ><br>
> > > ><br>
> > > > _______________________________________________<br>
> > > > fieldtrip mailing list<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>
> > > > <a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
> > > ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > fieldtrip mailing list<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>
> > <a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
> ><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
fieldtrip mailing list<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>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div>