필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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
Joanne Hall
Joanne Hall 2022년 1월 16일
편집: Joanne Hall 2022년 1월 16일
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 2022년 1월 16일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Poorna
Poorna 2024년 1월 29일
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:

카테고리

Help CenterFile Exchange에서 AI for Signals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by