edfwrite replaces all values in sigdata matrix with "0.48829" in every cell (matlab 2021b)

2 vues (au cours des 30 derniers jours)
Hi Matlab team,
I tried the following code in matlab 2021b and it produced a matrix with every cell containing only one value (for the most part): 0.48829.
++++++++++++++++++++++++++++++++++++++++++++++++++
fs = 256;
hdr = edfheader("EDF");
hdr.StartDate = '12.01.17';
hdr.StartTime = '01.45.04';
hdr.PhysicalDimensions = repmat("mV",1,38);
hdr.Patient = '...';
hdr.SignalLabels = ["C001";"C002";"C003";"C004";"C005";"C006";"C007";"C008";"C009";"C010";"C011";"C012";"C013";"C014";"C015";"C016";"C017";"C018";"C019";"C020";"C021";"C022";"C023";"C024";"C025";"C026";"C027";"C028";"C029";"C030";"C031";"C032";"C033";"C034";"C035";"C036";"C037";"C038"]';
hdr.NumDataRecords = 1;
hdr.Recording = ['SampleRate 256' 'Recording.PatientID_StudyID = 0 0' '...'];
hdr.PhysicalMin = repmat(-32000,1,38);
hdr.PhysicalMax = repmat(32000,1,38);
hdr.DigitalMin = repmat(-32768,1,38);
hdr.DigitalMax = repmat(32767,1,38);
hdr.NumSignals = 38;
hdr.DataRecordDuration = seconds(length(sigdata2)/fs);
edfw = edfwrite('Exportv2_3.edf',hdr,sigdata2);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The 'sigdata2' matrix is a 5122 X 38 DOUBLE matrix. (38 channels)
Thanks in advance for any guidance.
J.
  3 commentaires
Joanne Hall
Joanne Hall le 16 Jan 2022
Modifié(e) : Joanne Hall le 16 Jan 2022
Thanks Max. My question is how to get the edfwrite function to write out my original EEG data matrix with the original data values in the 'sigdata' (input argument) WITHOUT instead overwriting the original numeric values in the datamatrix by replacing all of those values with one single number: which is 0.488289. This one value is listed in every cell of the data matrix, and results in flat EEG signals when I open the edf file in edfbrowser. Please help.
I have attached the resulting data file as a .txt.
Joanne Hall
Joanne Hall le 16 Jan 2022
Hi Max,
I am also attaching the original data matrix that I would like to have as the edf output (instead of all cells containing the same value).
Joanne

Connectez-vous pour commenter.

Réponses (1)

Poorna
Poorna le 29 Jan 2024
Hi Joanne,
I get that you are unable to write the exact “sigdata2” to the EDF file using the MATLAB’s “edfwrite” function.
By setting the fields of the EDF header structure correctly you can replicate the exact data into the EDF file.
Specifically, you need to change the “PhysicalMin” and “PhysicalMax” attributes so that they reflect the actual minimum and maximum values present in your sigdata2 matrix.
Here's how you can adjust the header:
hdr.PhysicalMin = min(sigdata2)
hdr.PhysicalMax = max(sigdata2)
By setting these attributes to match your data range, you're instructing the edfwrite function to map your physical data directly to the digital values in the file without any unintended scaling.
Additionally, it's important to specify the sample type when writing the data. The edfwrite function has a property called InputSampleType that determines how the function interprets the incoming data. To ensure that the function processes your data as physical values rather than digital ones, you should set this property to physical.
Here's how you can modify your edfwrite function call:
edfw = edfwrite('Exportv2_3.edf',hdr,sigdata2, 'InputSampleType','physical');
With these adjustments, your EDF file should now accurately represent the original sigdata2 matrix, preserving the exact values.
To know more about the “edfwrite” function and “edfheader, refer to the following documentation:

Catégories

En savoir plus sur AI for Signals dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by