Plotting high frequency EDF data from timetable
9 次查看(过去 30 天)
显示 更早的评论
Using 2022a
Since 2020b the old FEX function edfread() was incorporated into matlab in the signal processing toolbox (native edfread). The function reads the data out in a timetable which I am having trouble manipulating/plotting:
For a record sampled at 500 Hz (e.g, EEG, MEG data):
a = edfread('test.edf')
a =
9500×128 timetable
Record Time C1 C2
0.632 sec {50×1 double} {50×1 double}
0.732 sec {50×1 double} {50×1 double}
0.832 sec {50×1 double} {50×1 double}
...
If this were sampled at 1024 Hz, the filed would contain 128x1 doubles corresponding to each Record Time increment (which would be 0.125 sec).
I'm having trouble finding an intuitive way to manipulate and plot these massive files.
I've tried:
- I can write a code to "unpack" all of the 50x1 cells into a single vector, but this is very resource intensive.
- Using 'DataRecordOutputType', 'vector' does not seem to change the output (I still get a timetable)
- using table2cell(a) or table2array(a) works to get it out of timetable format, but leaves me with a header-less cell/array of cells and the "unpacking" problem still exists.
0 个评论
采纳的回答
Star Strider
2022-4-18
I do not have your data, however using the MATLAB sample data, extracting the entire record of each variable may not be difficult
tt = edfread('example.edf')
RecTime = seconds(tt.('Record Time')); % Get Time Variable
ECGv = cat(1,tt.ECG{:}); % Concatenate The 'ECG' Variable
Ts = numel(tt.ECG{1})/mean(diff(RecTime)); % Sampling Intervals (Samples/Second)
Time = linspace(0, numel(ECGv)-1, numel(ECGv)).'/Ts; % Create Continuous Time Vector
figure % Plot Results
plot(Time, ECGv)
grid
xlabel('Time')
ylabel('Amplitude')
If I understand correctly what you want to do (and I may not), ‘unpacking’ the data is straightforward. This is somewhat facilitated by duration arrays having a regular sampling interval. It may be necessary to scale the ‘Time’ variable appropriately with your data.
.
更多回答(1 个)
Campion Loong
2022-5-18
edfData = edfread('example.edf');
% Unpack the ECG signals into a timetable of regularly sampled data
% (This assumes the 1280 data-points are sampled evenly between adjacent 'Record Time')
ECG = cat(1,edfData.ECG{:});
ECG2 = cat(1,edfData.ECG2{:});
tt = timetable(ECG, ECG2, 'TimeStep', seconds(10)/1280)
% Simply visualize both ECG series in one stackedplot
% (You can even scrub both series together with synchronized datatip to explore the signals further)
stackedplot(tt)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!