Plotting high frequency EDF data from timetable
조회 수: 10 (최근 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.
.
댓글 수: 2
추가 답변 (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!