[FieldTrip] Can I define the trials with only header, data, and event
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Wed May 28 14:10:42 CEST 2025
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/20250528/56a04d3b/attachment.htm>
More information about the fieldtrip
mailing list