edfwrite distortes my signal!

1 回表示 (過去 30 日間)
Sadegh Rahimi
Sadegh Rahimi 2022 年 7 月 26 日
Hi there,
I would like to open an EDF file, modify the signal and export it again in EDF; however, the edfwrite distortes my signal!
original signal:
exported signal:
clc;
clear all
close all
[EEG_for_HFO, annotations]=edfread('Rec-06.0001-GFP.edf');
header=edfinfo('Rec-06.0001-GFP.edf');
%% Inputs
EEG=EEG_for_HFO.EEG;
EEG=cell2mat(EEG);
SR=1000; % Sampling rate
% % Artifact Removal
% Threshold=1.5; % Threshold level for Artifact Removing in mili volt
% Window=10; % Length of step for Artifact Removing in mili second
% TimeDuration=100; % Time duration for Artifact Removing in mili second - Before and After
% % Highpass Filter
% FilterLevel=5; % Level of highpass filter
% Cutoff=2;
% %% Orders ------> 1 means On
% ArtifactRemoving=1;
% Filter=1;
% %% Plot
% figure;
% Time=1:length(EEG);
% plot(Time,EEG,'b');
% title('Raw signal')
% xlabel('Time(ms)');ylabel('EEG(mV)')
% %% Artifact Removal
% if (ArtifactRemoving==1)
% Start=100;
% End=Start+Window;
% for ii=1:(round(length(EEG)/Window)-Window)-1
% [Max(ii),max_indices(ii)]=max(abs(EEG(Start:End)));
% if Max(ii)>Threshold
% Before=max_indices(ii)-TimeDuration+Start;
% After=max_indices(ii)+TimeDuration-1+Start;
% EEG(Before:After)=0;
% end
%
% Start=Start+Window;
% End=End+Window;
% end
%
% hold on
% Time=1:length(EEG);
% plot(Time,EEG,'r')
% end
%
% %% Highpass Filter
% if (Filter==1)
%
% a=[];b=[];
% [b,a]=butter(FilterLevel,Cutoff/(SR/2),'high'); % Highpass filtering 2 Hz
% EEG=filtfilt(b,a,EEG);
% end
%% creating header
hdr=edfheader("EDF+");
hdr.Patient="Mice";
hdr.Recording="2021";
hdr.NumDataRecords=1;
hdr.NumSignals=1;
hdr.SignalLabels="EEG";
hdr.PhysicalDimensions="mV";
hdr.PhysicalMin=-5;
hdr.PhysicalMax=5;
hdr.DigitalMin=-32256;
hdr.DigitalMax=32256;
%% exporting edf
%EEGCell= mat2cell(EEG(:), SR*ones(1,numel(EEG)/SR), 1);
f=edfwrite("file.edf",hdr,EEG, annotations);
You can find an example of my EDF files here: EDF
Thanks!

回答 (0 件)

カテゴリ

Help Center および File ExchangeAI for Signals についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by