Skip to content

Commit 5154017

Browse files
committed
Add comprehensive test suite for processFNIRS2
Introduces unit, integration, quick, and synthetic tests for pf2_base, including fixtures for sample data, full pipeline and roundtrip SNIRF tests, and quick validation scripts for import, export, and processing. Also adds synthetic artifact generation for testing, updates documentation, and removes obsolete readme file.
1 parent 9c7b708 commit 5154017

34 files changed

Lines changed: 9680 additions & 100 deletions
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
classdef SampleDataFixture < matlab.unittest.fixtures.Fixture
2+
% SAMPLEDATAFIXTURE Test fixture providing pre-loaded fNIRS sample data
3+
%
4+
% Provides shared access to sample fNIRS datasets for unit and integration
5+
% tests. Loading sample data once per test class (via fixture) improves
6+
% test performance compared to loading in each test method.
7+
%
8+
% Reference:
9+
% Internal pf2 test infrastructure. See matlab.unittest.fixtures.Fixture.
10+
%
11+
% Syntax:
12+
% fixture = pf2_base.tests.fixtures.SampleDataFixture()
13+
% testCase.applyFixture(fixture)
14+
%
15+
% Properties:
16+
% fNIR2000 - fNIR 2000 sample data [struct]
17+
% 18-channel prefrontal probe, 10 Hz sampling rate.
18+
% Loaded via pf2.import.sampleData.fNIR2000().
19+
% fNIR1200 - fNIR 1200 sample data [struct]
20+
% 16-channel probe configuration.
21+
% Loaded via pf2.import.sampleData.fNIR1200().
22+
% hitachi3x5 - Hitachi ETG-4000 3x5 sample data [struct]
23+
% 22-channel probe (3x5 optode array).
24+
% Loaded via pf2.import.sampleData.Hitachi_ETG4000_3x5().
25+
%
26+
% Example:
27+
% classdef MyTest < matlab.unittest.TestCase
28+
% methods (TestClassSetup)
29+
% function setupFixture(testCase)
30+
% fixture = pf2_base.tests.fixtures.SampleDataFixture();
31+
% testCase.applyFixture(fixture);
32+
% testCase.addTeardown(@() disp('Fixture cleanup'));
33+
% end
34+
% end
35+
%
36+
% methods (Test)
37+
% function testProcessing(testCase)
38+
% fixture = testCase.getSharedTestFixtures(...
39+
% 'pf2_base.tests.fixtures.SampleDataFixture');
40+
% data = fixture.fNIR2000;
41+
% result = processFNIRS2(data);
42+
% testCase.verifyNotEmpty(result.HbO);
43+
% end
44+
% end
45+
% end
46+
%
47+
% Notes:
48+
% - Sample data files must exist in processFNIRS2/sampledata/
49+
% - Fixture loads data silently (channelCheck=false, no GUI)
50+
% - Data is loaded once and shared across all tests using the fixture
51+
%
52+
% See also: matlab.unittest.fixtures.Fixture, pf2.import.sampleData
53+
54+
properties (SetAccess = private)
55+
% fNIR2000 - fNIR 2000 sample data struct
56+
% 18-channel prefrontal probe, 10 Hz sampling rate.
57+
% Contains raw intensity data, markers, and device configuration.
58+
fNIR2000
59+
60+
% fNIR1200 - fNIR 1200 sample data struct
61+
% 16-channel probe configuration.
62+
% Contains raw intensity data, markers, and device configuration.
63+
fNIR1200
64+
65+
% hitachi3x5 - Hitachi ETG-4000 3x5 sample data struct
66+
% 22-channel probe from 3x5 optode array.
67+
% Contains raw intensity data and device configuration.
68+
hitachi3x5
69+
end
70+
71+
methods
72+
function setup(fixture)
73+
% SETUP Load all sample datasets
74+
%
75+
% Loads fNIR2000, fNIR1200, and Hitachi 3x5 sample data.
76+
% Called automatically when fixture is applied to test case.
77+
78+
% Load fNIR 2000 sample data (18 channels, prefrontal)
79+
fixture.fNIR2000 = pf2.import.sampleData.fNIR2000();
80+
81+
% Load fNIR 1200 sample data (16 channels)
82+
fixture.fNIR1200 = pf2.import.sampleData.fNIR1200();
83+
84+
% Load Hitachi ETG-4000 3x5 sample data (22 channels)
85+
fixture.hitachi3x5 = pf2.import.sampleData.Hitachi_ETG4000_3x5();
86+
end
87+
88+
function teardown(~)
89+
% TEARDOWN Clean up after fixture use
90+
%
91+
% No cleanup required - data is released when fixture is destroyed.
92+
end
93+
end
94+
95+
methods (Access = protected)
96+
function tf = isCompatible(fixture, other)
97+
% ISCOMPATIBLE Check if two fixtures are compatible
98+
%
99+
% Returns true if both fixtures are SampleDataFixture instances.
100+
% Required by matlab.unittest.fixtures.Fixture interface.
101+
%
102+
% Inputs:
103+
% fixture - This fixture instance
104+
% other - Another fixture to compare
105+
%
106+
% Outputs:
107+
% tf - True if fixtures are compatible (same class)
108+
109+
tf = isa(other, 'pf2_base.tests.fixtures.SampleDataFixture');
110+
end
111+
end
112+
end

0 commit comments

Comments
 (0)