[Eeglablist] Merging two dataset
goharbak at uni-bremen.de
goharbak at uni-bremen.de
Tue Sep 24 00:17:15 PDT 2024
Hi dear community,
I have one problem that I could not solve myself. I have two eeg datasets, one for mother and one for infant. They are for eeg hyperscanning experiment. I recorded these two datasets with separate amplifiers and in separate files with brain recorder. As I should use a pipeline for analyzing my data, I should import infant and mother's data to MATLAB in one file and not separated. Therefore, I should merge my data. Bothe data has the same sampling rate 500 but there is two problems:
1.The name of the channels in two datasets are different
2.Data points in two datasets are different because I started recording for one of the participants with delay as I had two systems(they have the same number of markers)
I solved the channel's name. I changed the channels' name of one of the datasets to avoid any confusion. But I do not know how I can match the data point in two datasets and then I can merge them.
Below, it is a code that I am using for changing the channels' name and merging but it prefers one of the channels' names and ignores the channels' name of other dataset and then merges both datasets.
% Load EEGLAB
eeglab;
% Define file paths and file names for the first dataset
filepath1 = 'C:\Users\goharbakhsh\Desktop\EEG\ostracism hyper\original EEG data\New folder\New folder'; % Replace with your actual path
filename1 = 'infant.vhdr'; % Replace
% Load the first dataset
EEG1 = pop_loadbv(filepath1, filename1);
% Define file paths and file names for the second dataset
filepath2 = 'C:\Users\goharbakhsh\Desktop\EEG\ostracism hyper\original EEG data\New folder\New folder'; % Replace with your actual path
filename2 = 'mother.vhdr'; % Replace
% Load the second dataset
EEG2 = pop_loadbv(filepath2, filename2);
% Example: Add a prefix "m_" to all channels in EEG2
for i = 1:length(EEG2.chanlocs)
EEG2.chanlocs(i).labels = ['m_' EEG2.chanlocs(i).labels];
end
% Display updated channel labels in EEG2
disp({EEG2.chanlocs.labels});
% Merge the two datasets
EEG_merged = pop_mergeset(EEG1, EEG2, 0);
% Saving mergeg data
pop_writebva(EEG, fullfile(outputPath, outputFilename));
The *vhdr file of the data should be in the format below for the pipelin. There are 64 channels, half of them is for the mothers and half is for infants.
[Channel Infos]
; Each entry: Ch<Channel number>=<Name>,<Reference channel name>,
; <Resolution in "Unit">,<Unit>, Future extensions..
; Fields are delimited by commas, some fields might be omitted (empty).
;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1,µV
Ch59=2_FC4,,0.1,µV
Ch60=2_F4,,0.1,µV
Ch61=2_F8,,0.1,µV
Ch62=2_F10,,0.1,µV
Ch63=2_VEOG1,,0.1,µV
Ch64=2_VEOG2,,0.1,µV
Do you have any ideas how can I marge my data to get this format?
Thank you very much for your time.
Kind regards,
Niloofar
----
Niloofar Goharbakhsh
PhD student in Developmental and Educational Psychology,
University of Bremen, Germany
More information about the eeglablist
mailing list