[Eeglablist] Merging two dataset
Arnaud Delorme
adelorme at ucsd.edu
Thu Oct 3 17:05:35 PDT 2024
Hi Niloofar,
You might want to try eeg_mergechannels. If you provide common events to this function, it will also interpolate the data to ensure perfect alignment of data samples. It is usually used to align EEG and eye tracker data (or other measures), but it may also be used to merge datasets acquired during hyperscanning.
This function is part of the EEG-BIDS plugin but will be moved to the EEGLAB core code in a future release.
Arno
> On Sep 24, 2024, at 00:17, goharbak--- via eeglablist <eeglablist at sccn.ucsd.edu> wrote:
>
> 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).
> ; Commas in channel names are coded as "\1".
> Ch1=Fz,,0.1,µV
> Ch2=F3,,0.1,µV
> Ch3=F7,,0.1,µV
> Ch4=F9,,0.1,µV
> Ch5=FT7,,0.1,µV
> Ch6=FC3,,0.1,µV
> Ch7=FCz,,0.1,µV
> Ch8=Cz,,0.1,µV
> Ch9=C3,,0.1,µV
> Ch10=T7,,0.1,µV
> Ch11=CP3,,0.1,µV
> Ch12=Pz,,0.1,µV
> Ch13=P3,,0.1,µV
> Ch14=P7,,0.1,µV
> Ch15=PO9,,0.1,µV
> Ch16=O1,,0.1,µV
> Ch17=Oz,,0.1,µV
> Ch18=O2,,0.1,µV
> Ch19=PO10,,0.1,µV
> Ch20=P8,,0.1,µV
> Ch21=P4,,0.1,µV
> Ch22=CP4,,0.1,µV
> Ch23=TP10,,0.1,µV
> Ch24=T8,,0.1,µV
> Ch25=C4,,0.1,µV
> Ch26=FT8,,0.1,µV
> Ch27=FC4,,0.1,µV
> Ch28=F4,,0.1,µV
> Ch29=F8,,0.1,µV
> Ch30=F10,,0.1,µV
> Ch31=VEOG1,,0.1,µV
> Ch32=VEOG2,,0.1,µV
> Ch33=2_Fz,,0.1,µV
> Ch34=2_F3,,0.1,µV
> Ch35=2_F7,,0.1,µV
> Ch36=2_F9,,0.1,µV
> Ch37=2_FT7,,0.1,µV
> Ch38=2_FC3,,0.1,µV
> Ch39=2_FCz,,0.1,µV
> Ch40=2_Cz,,0.1,µV
> Ch41=2_C3,,0.1,µV
> Ch42=2_T7,,0.1,µV
> Ch43=2_CP3,,0.1,µV
> Ch44=2_Pz,,0.1,µV
> Ch45=2_P3,,0.1,µV
> Ch46=2_P7,,0.1,µV
> Ch47=2_PO9,,0.1,µV
> Ch48=2_O1,,0.1,µV
> Ch49=2_Oz,,0.1,µV
> Ch50=2_O2,,0.1,µV
> Ch51=2_PO10,,0.1,µV
> Ch52=2_P8,,0.1,µV
> Ch53=2_P4,,0.1,µV
> Ch54=2_CP4,,0.1,µV
> Ch55=2_TP10,,0.1,µV
> Ch56=2_T8,,0.1,µV
> Ch57=2_C4,,0.1,µV
> Ch58=2_FT8,,0.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
>
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
More information about the eeglablist
mailing list