Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/KHU_example.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

%load boundary voltages of baseline recording, cleaning the data and
%plotting
[BV_baseline, KHUs_baseline]=KHU_Load('..\resources\data\KHU\B1',1,1);
[BV_baseline, KHUs_baseline]=KHU_Load('../resources/data/KHU/B1',1,1);

%% load Perturbation

%load boundary voltages of baseline recording, cleaning the data but not
%plotting
[BV_perturbation, KHUs_perturbation]=KHU_Load('..\resources\data\KHU\P1',1,0);
[BV_perturbation, KHUs_perturbation]=KHU_Load('../resources/data/KHU/P1',1,0);

6 changes: 3 additions & 3 deletions example/ScouseTom_example.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

%load boundary voltages of resistor phantom recording. The log files
%generated by the ScouseTom ssytem are located in same directory
[BVstruc_TD]=ScouseTom_Load('..\resources\data\ScouseTom\forreal_2_clean.bdf');
[BVstruc_TD]=ScouseTom_Load('../resources/data/ScouseTom/forreal_2_clean.bdf');

%% load Multifrequency data

%load boundary voltages of resistor phantom recording using multiple
%frequecies. The log files generated by the ScouseTom system is located in
%the same directory
[BVstruc_MF]=ScouseTom_Load('..\resources\data\ScouseTom\MultiFreq.bdf');
[BVstruc_MF]=ScouseTom_Load('../resources/data/ScouseTom/MultiFreq.bdf');

%% load contact impedance check

% perform contact impedance check on data collected on scalp with EEG
% electrodes. This code is a bit different as we want to estimate the
% contact impedance and plot it quickly. The protocol is also independent
% of that set by the ExpSetup
[Zout]=ScouseTom_Load('..\resources\data\ScouseTom\S1a_Z4.bdf');
[Zout]=ScouseTom_Load('../resources/data/ScouseTom/S1a_Z4.bdf');
2 changes: 1 addition & 1 deletion example/SwissTom_example.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

%load boundary voltages of resistor phantom recording. Removing injected
%channels, saturated channels, and plotting data
[STout]=SwissTom_Load('..\resources\data\Swisstom\r-phantom.eit',1,1,1);
[STout]=SwissTom_Load('../resources/data/Swisstom/r-phantom.eit',1,1,1);
2 changes: 1 addition & 1 deletion src/matlab/KHU_Load.m
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
KHU.info=info;

%get the name for the new files
k=strfind(dirname,filesep);
k=strfind(dirname,'/');
newnamestr=dirname(k(end)+1:end);


Expand Down
Binary file removed test/S3b_MF1_log.mat
Binary file not shown.
163 changes: 163 additions & 0 deletions tests/Test_ScouseTom.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
% test code is functioning on real examples. Requires files from https://doi.org/10.5281/zenodo.4783547

datadir='I:/Load_data_testing/';
%datadir='data/';
%% load bdfs

somethingwentwrong=0;


try
BVs=ScouseTom_Load([datadir 'Baseline1.bdf']);
catch err
fprintf(2,'error on initial test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'Baseline1_missingstart.bdf']);
catch err
fprintf(2,'error on missing start test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'Baseline1_missingend.bdf']);
catch err
fprintf(2,'error on missing end test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'Baseline1_missingboth.bdf']);
catch err
fprintf(2,'error on missing both test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');
%% multifreq

try
BVs=ScouseTom_Load([datadir 'MultiFreq.bdf']);
catch err
fprintf(2,'error on Multifreq test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'MultiFreq_missingstart.bdf']);
catch err
fprintf(2,'error on Multifreq missing start test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'MultiFreq_missingend.bdf']);
catch err
fprintf(2,'error on Multifreq missing end test\n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'MultiFreq_missingboth.bdf']);
catch err
fprintf(2,'error on Multifreq missing both test\n');
somethingwentwrong=1;
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

%% Z check
try
Z=ScouseTom_Load([datadir 'firstinnir_zcheck_1.bdf']);
catch err
fprintf(2,'error on Z load \n');
somethingwentwrong=1;
fprintf(2, '%s\n', getReport(err, 'extended'));
end


%% AC check

try
BVs=ScouseTom_Load([datadir 'rptest2.eeg']);
catch err
fprintf(2,'error on Actichamp test 1\n');
somethingwentwrong=1;
end

disp('=================================================');
disp('=================================================');
disp('=================================================');

try
BVs=ScouseTom_Load([datadir 'rptest3.eeg']);
catch err
fprintf(2,'error on Actichamp test 2\n');
somethingwentwrong=1;
end

disp('=================================================');
disp('=================================================');
disp('=================================================');


%% Big file

try
BVs=ScouseTom_Load([datadir 'RealThing_NIRFACE_2.bdf']);
catch err
fprintf(2,'error on Multifreq big file test\n');
somethingwentwrong=1;
end

disp('=================================================');
disp('=================================================');
disp('=================================================');



%% did it work?

if somethingwentwrong
fprintf(2,'Oh No! SOMETHING WENT WRONG!\n');
else
fprintf('YAY! IT WORKED :)\n');
end

2 changes: 2 additions & 0 deletions tests/data/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Test dataset
Put files from [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4783527.svg)](https://doi.org/10.5281/zenodo.4783527) in this directory to run tests
121 changes: 121 additions & 0 deletions tests/filters/check_acc.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
function [ Amp_error, Phase_error,Vsig,Vsigdemod,Filt,trim_demod] = check_acc( Fc,InjTime,Amp_Inj,Amp_Meas,InjPhase,MeasPhaseDiff,DCoffset,DCoffsetInj, Padsec, Fs,decimate_factor)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

%%
inj = [ 2 4];

if exist('DCoffset','var') == 0 || isempty(DCoffset)
DCoffset=0;
end

if exist('DCoffsetInj','var') == 0 || isempty(DCoffsetInj)
DCoffsetInj=0;
end


BW=100;
chn=5;

if exist('Padsec','var') == 0 || isempty(Padsec)
Padsec=4;
end

if exist('Fs','var') == 0 || isempty(Fs)
Fs=16384;
end

if exist('decimate_factor','var') == 0 || isempty(decimate_factor)
decimate_factor=0;
end


%% Create ideal values, and voltages

AmpActual= repmat(Amp_Meas,chn,1);
AmpActual(inj)=Amp_Inj;

a=MeasPhaseDiff;

%force normal valus of deg
a = mod(a,360); % [0 2pi)

% shift
jj = a > 180;
a(jj) = a(jj) - 360;
jj = a < 0 - 180;
a(jj) = a(jj) + 360;

MeasPhaseDiff_corr = a;

MeasPhase = InjPhase + MeasPhaseDiff_corr; %deg
PhaseActual= repmat(MeasPhaseDiff_corr,chn,1);
PhaseActual(inj)=0;

Totaltime=ceil(InjTime + 2*Padsec);
t = 0:1/Fs:Totaltime-1/Fs;
%make sin wave

v_m= Amp_Meas*sin(2*pi*Fc*t+(pi*MeasPhase/180))+DCoffset;

% change amplitude
v_i=Amp_Inj*sin(2*pi*Fc*t+(pi*InjPhase/180))+DCoffsetInj;


%%
V=repmat(v_m,chn,1);

V(inj(1),:) = v_i;
V(inj(2),:) = v_i;

V=V';

%% decimate now if we want to

if decimate_factor
for iChn = 1 :size(V,2)
Vtmp(:,iChn) = decimate(V(:,iChn),decimate_factor);
end
Fs=Fs/decimate_factor;
V=Vtmp;
end

%%


%pad with a second of data either side, so the hilbert is more realistic
datastart = round(Padsec*Fs);
dataend = round((Padsec+InjTime)*Fs);

V(1:datastart,:)=V(1:datastart,:)*0.1;
V(dataend:end,:)=V(dataend:end,:)*0.1;

InjectionWindows =[datastart dataend];


%%
%find the corresponding filter settings
[trim_demod,Filt,Fc_found]=ScouseTom_data_GetFilterTrim(V(datastart:dataend,inj(1)),Fs,[],[],[]);

Vsig = V(datastart:dataend,inj(1));

[ Vdata_demod,Pdata_demod ] = ScouseTom_data_DemodHilbert( V,Filt);
Vsigdemod = Vdata_demod(datastart:dataend,inj(1));

%%
[Vmag,PhaseRaw,VmagSTD,PhaseRawSTD]=ScouseTom_data_getBV(Vdata_demod,Pdata_demod,trim_demod,InjectionWindows);
% [Vmag,PhaseRaw,VmagSTD,PhaseRawSTD]=ScouseTom_data_getBVChunk(Datafilt,trim_demod,InjectionWindows);


[Phase]=ScouseTom_data_PhaseEst(PhaseRaw,inj,1);

Phase_deg=(180/pi) * (Phase);

Phase_error = PhaseActual - Phase_deg';

Amp_error = AmpActual - Vmag';

fprintf('Amp error : %.6f, Phase error : %.6f\n',mean(Amp_error),mean(Phase_error));
end


Loading