11function test_suite = test_generateStf
2- % The output should always be test_suite, and the function name the same as
3- % your file name
4-
5- %% Header
6- % The header is required to be in this format for automatic test collection
7- % by MOxUnit
8-
9- % To collect all tests defined below, this is needed in newer Matlab
10- % versions. test_functions will collect function handles to below test
11- % functions
12- test_functions= localfunctions();
13-
14- % This will initialize the test suite, i.e., take the functions from
15- % test_functions, check if they contain "test", convert them into a MOxUnit
16- % Test Case, and add them to the test-runner
17- initTestSuite ;
18-
19- %% Custom Tests
20- % Tests use assert*-like Functions to check outputs etc:
21- % assertTrue(a) - a is true
22- % assertFalse(a) - a is false
23- % assertEqual(a,b) - a and be are equal (isequal)
24- % assertElementsAlmostEqual(a,b) - numerical test for all vector / matrix elements. Has Additional arguments for absolute / relative tolerance
25- % assertVectorsAlmostEqual(a,b) - numerical test using vector norm
26- % assertExceptionThrown(f,id) - test if exception of id is thrown. Take care of Octave issues with exception id (or don't provide id)
27- % Check MOxUnit for more information or look at other tests
2+ % The output should always be test_suite, and the function name the same as
3+ % your file name
4+
5+ %% Header
6+ % The header is required to be in this format for automatic test collection
7+ % by MOxUnit
8+
9+ % To collect all tests defined below, this is needed in newer Matlab
10+ % versions. test_functions will collect function handles to below test
11+ % functions
12+ test_functions= localfunctions();
13+
14+ % This will initialize the test suite, i.e., take the functions from
15+ % test_functions, check if they contain "test", convert them into a MOxUnit
16+ % Test Case, and add them to the test-runner
17+ initTestSuite ;
18+
19+ %% Custom Tests
20+ % Tests use assert*-like Functions to check outputs etc:
21+ % assertTrue(a) - a is true
22+ % assertFalse(a) - a is false
23+ % assertEqual(a,b) - a and be are equal (isequal)
24+ % assertElementsAlmostEqual(a,b) - numerical test for all vector / matrix elements. Has Additional arguments for absolute / relative tolerance
25+ % assertVectorsAlmostEqual(a,b) - numerical test using vector norm
26+ % assertExceptionThrown(f,id) - test if exception of id is thrown. Take care of Octave issues with exception id (or don't provide id)
27+ % Check MOxUnit for more information or look at other tests
28+
29+ function test_generateStf_photons
30+ load TG119.mat ;
31+ pln = helper_basicPln(' photons' ,ct ,cst );
2832
29- function test_generateStf_photons
30- load TG119.mat ;
31- pln = helper_basicPln(' photons' ,ct ,cst );
32-
33- stf = matRad_generateStf(ct ,cst ,pln );
34- assertTrue(isstruct(stf ));
35- assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
33+ stf = matRad_generateStf(ct ,cst ,pln );
34+ assertTrue(isstruct(stf ));
35+ assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
3636
37- function test_generateStf_protons
38- load TG119.mat ;
39- pln = helper_basicPln(' protons' ,ct ,cst );
40-
41- stf = matRad_generateStf(ct ,cst ,pln );
42- assertTrue(isstruct(stf ));
43- assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
37+ function test_generateStf_protons
38+ load TG119.mat ;
39+ pln = helper_basicPln(' protons' ,ct ,cst );
40+
41+ stf = matRad_generateStf(ct ,cst ,pln );
42+ assertTrue(isstruct(stf ));
43+ assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
4444
45- function test_generateStf_helium
46- load TG119.mat ;
47- pln = helper_basicPln(' helium' ,ct ,cst );
48-
49- stf = matRad_generateStf(ct ,cst ,pln );
50- assertTrue(isstruct(stf ));
51- assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
45+ function test_generateStf_helium
46+ load TG119.mat ;
47+ pln = helper_basicPln(' helium' ,ct ,cst );
48+
49+ stf = matRad_generateStf(ct ,cst ,pln );
50+ assertTrue(isstruct(stf ));
51+ assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
5252
53- function test_generateStf_carbon
54- load TG119.mat ;
55- pln = helper_basicPln(' carbon' ,ct ,cst );
56-
57- stf = matRad_generateStf(ct ,cst ,pln );
58- assertTrue(isstruct(stf ));
59- assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
53+ function test_generateStf_carbon
54+ load TG119.mat ;
55+ pln = helper_basicPln(' carbon' ,ct ,cst );
56+
57+ stf = matRad_generateStf(ct ,cst ,pln );
58+ assertTrue(isstruct(stf ));
59+ assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
6060
61- function test_generateStf_noTargetObjectives
62- load TG119.mat ;
63- [cst{: ,6 }] = deal([]);
64- pln = helper_basicPln(' photons' ,ct ,cst );
65-
66- stf = matRad_generateStf(ct ,cst ,pln );
67- assertTrue(isstruct(stf ));
68- assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
61+ function test_generateStf_noTargetObjectives
62+ load TG119.mat ;
63+ [cst{: ,6 }] = deal([]);
64+ pln = helper_basicPln(' photons' ,ct ,cst );
65+
66+ stf = matRad_generateStf(ct ,cst ,pln );
67+ assertTrue(isstruct(stf ));
68+ assertEqual(numel(stf ),numel(pln .propStf .gantryAngles ));
6969
70+ function test_generateStfSingleBixel
71+ load TG119.mat ;
72+ pln = helper_basicPln(' photons' ,ct ,cst );
73+ stf = matRad_generateSingleBixelStf(ct ,cst ,pln );
74+ assertTrue(isstruct(stf ));
7075
71- function pln = helper_basicPln(modality ,ct ,cst )
72- pln.radiationMode = modality ;
73- pln.numOfFractions = 30 ;
74- pln.machine = ' Generic' ;
75- pln.multScen = matRad_NominalScenario(ct );
76- pln.propStf.gantryAngles = 0 ;
77- pln.propStf.couchAngles = 0 ;
78- pln.propStf.bixelWidth = 5 ;
79- pln.propStf.isoCenter = matRad_getIsoCenter(cst ,ct );
80-
76+ pln = helper_basicPln(' protons' ,ct ,cst );
77+ stf = matRad_generateSingleBixelStf(ct ,cst ,pln );
78+ assertTrue(isstruct(stf ));
8179
82-
80+ function pln = helper_basicPln(modality ,ct ,cst )
81+ pln.radiationMode = modality ;
82+ pln.numOfFractions = 30 ;
83+ pln.machine = ' Generic' ;
84+ pln.multScen = matRad_NominalScenario(ct );
85+ pln.propStf.gantryAngles = 0 ;
86+ pln.propStf.couchAngles = 0 ;
87+ pln.propStf.bixelWidth = 5 ;
88+ pln.propStf.isoCenter = matRad_getIsoCenter(cst ,ct );
0 commit comments