[FieldTrip] Can I define the trials with only header, data, and event
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Thu May 29 19:09:05 CEST 2025
Hi Shikai,
If I understand correctly, you have a - what you call - ’trial’ for which a part is represented in datafile1, and another part is represented in datafile2. From what you describe, I can only conclude that there is a temporal discontinuity from the end of datafile1 to the beginning of datafile2. In other words, it does not make sense to salvage this trial by sticking the ends together, so consider this trial lost for further analysis.
Good luck with your analysis endeavours,
Jan-Mathijs
On 29 May 2025, at 16:20, Shikai Chen via fieldtrip <fieldtrip at science.ru.nl> wrote:
Hi Jan-Mathijs,
Thank you so much for your reply! I want to define the trials, but I found in the tutorials, I have to use the name of the MEG data, like cfg.dataset = ‘filename”. And my two data files are continuous—the second starts in the middle of one trial from the first one. So I want to combine them into one, save the data as new file and then define the trials. I was wondering if I have to use cfg.dataset = ‘filename”.
I also tried ft_appenddata. But I am confused what should I do after this to define the trials. When I had the defined trials in cfg, and tried this: data = ft_preprocessing(cfg,data), it shows warning: The field cfg.trl is forbidden, it will be removed from your configuration. So I can’t successfully define the trials through this.
Thank you again for your help!
Best,
Shikai
2025年5月29日 18:00,fieldtrip-request at science.ru.nl 写道:
Hi Shikai,
Please can you reformulate your question a bit more coherently (provided the below does not give you enough pointers to proceed with your endeavours)? You mention a lot of functions and a lot of things, but it is unclear what you really aim to achieve. It’s unclear why you think that you need to use ft_write_data to ’stitch’ two raw datafiles together in a ‘raw’ fileformat that is the same (or similar) as the vendor specific acquisition system.
If you are facing the reality that the data recorded from a single subject ended up in 2 datafiles, and need to be processed together at some point, then import/epoch the data per file, and append the two resulting data structures in FieldTrip, using ft_appenddata.
Good luck,
Jan-Mathijs
May I ask if I can define the trials with only header, data, and event? I see cfg.dataset = “filename” and can I use the information of header, data, and event instead? These are generated by ft_read_header, ft_read_data and ft_read_event.
My MEG data is recorded into two data sets accidentally. So I combine these two into one using ft_read_header, ft_read_data and ft_read_event and cat. But I didn’t find the “MEG "format in ft_write_data and other formats would lose some information and regard the data as EEG data. So how can I make some changes to the following code?
hdr1 = ft_read_header(filename1);
dat1 = ft_read_data(filename1);
evt1 = ft_read_event(filename1);
hdr2 = ft_read_header(filename2);
dat2 = ft_read_data(filename2);
evt2 = ft_read_event(filename2);
hdr = hdr1;
hdr.nSamples = hdr1.nSamples + hdr2.nSamples;
dat = cat(2,dat1,dat2);
nsamples1 = hdr1.nSamples;
for i = 1:length(evt2)
evt2(i).sample = evt2(i).sample + nsamples1;
end
evt = cat(1,evt1,evt2);
cfg = [];
cfg.dataset = [path, '\data.vhdr’];
cfg.trialfun = 'trialfun_conditionaltrigger’;
cfg.trialdef.pre = 5;
cfg.trialdef.post = 68;
cfg = ft_definetrial(cfg);
data = ft_preprocessing(cfg);
Thank you so much for your help!
Best,
Shikai
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250529/75e0cef8/attachment.htm>
More information about the fieldtrip
mailing list