[FieldTrip] Can I define the trials with only header, data, and event
Shikai Chen
3190101881 at zju.edu.cn
Wed May 28 11:21:10 CEST 2025
Dear all members,
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250528/4594d3cb/attachment.htm>
More information about the fieldtrip
mailing list