edfwrite can not export my signal properly

3 views (last 30 days)
Hi Everyone,
I would like to export my signal in edf format, using MATLAB 2022a (academic use). I wrote the following code for a representative EEG:
EEG=randn(1,360000);
%% edfheader
hdr = edfheader("EDF+");
hdr.Patient = "Mouse F";
hdr.Recording = "INH50";
hdr.StartDate = "13.09.23";
hdr.StartTime = "13.09.24";
hdr.Reserved = "EDF+C";
hdr.NumSignals = 1;
hdr.NumDataRecords = 1;
hdr.PhysicalMin = [-3200];
hdr.PhysicalMax = [3200];
hdr.DigitalMin = [-32768];
hdr.DigitalMax = [32767];
hdr.DataRecordDuration = seconds(360);
%%
edfwrite("EDFTEST.edf",hdr,EEG);
But when I use edfread to opne it, it shows:
edfread("EDFTEST.edf")
ans =
timetable
Record Time Signal_1
___________ _________________
0 sec {360000×1 double}
When I open the edf file in another program (Sigview), it is unusal:
Indeed, first I tried the code with my real EEG signal, and the exported signal was just some vertical lines!
It would be great if someone could tell me what my mistake in the code is, particularly in the header. I tried different values for PhysicalMin, PhysicalMax, DigitalMin, and DigitalMax, but there was no improvement.
I really appreciate your help, as I am stuck at this step!

Accepted Answer

Taylor
Taylor on 2 Nov 2023
You're on the right track thinking about the PhysicalMin, PhysicalMax, DigitalMin, and DigitalMax values. You need to specify the InputSampleType as "physical" when calling edfwrite.
A good indication that there is an issue involving ADC is the multi-level "clipping" you're seeing in your plot.
  1 Comment
Sadegh Rahimi
Sadegh Rahimi on 2 Nov 2023
Thanks for your suggestion. I will implement it to see, if it would solve the issue

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!