Skip to content

Commit d7d3c9c

Browse files
author
Nicole Aucoin
committed
ENH: add testing for the pointfile
Add test for bulk data for the point file, but the parameter file reading and writing don't check the tags. Added a simple test case in the module description parser test, added a sample xml file based on the Slicer Excecution Module tour xml file to exercise the point and pointfile types. Issue #2979
1 parent 6cc5271 commit d7d3c9c

File tree

4 files changed

+115
-1
lines changed

4 files changed

+115
-1
lines changed

ModuleDescriptionParser/ModuleDescription.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ WriteParameterFile(const std::string& filename, bool withHandlesToBulkParameters
384384
&& (*pit).GetTag() != "transform"
385385
&& (*pit).GetTag() != "table"
386386
&& (*pit).GetTag() != "measurement"
387-
&& (*pit).GetTag() != "point" // point and region are special
387+
&& (*pit).GetTag() != "point" // point and point file and region are special
388+
&& (*pit).GetTag() != "pointfile"
388389
&& (*pit).GetTag() != "region")))
389390
{
390391
rtp << (*pit).GetName() << " = "

ModuleDescriptionParser/Testing/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ add_test(
4040
NAME Parser1Test2
4141
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:Parser1Test> ${TEST_DATA}/ParserTest2.xml)
4242

43+
add_test(
44+
NAME Parser1Test3
45+
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:Parser1Test> ${TEST_DATA}/ParserTest3.xml)
46+
4347
add_test(
4448
NAME ModuleDescriptionTest
4549
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:${KIT}CxxTests> ModuleDescriptionTest ${TEST_DATA}

ModuleDescriptionParser/Testing/ModuleDescriptionTest.cxx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//---------------------------------------------------------------------------
1010
bool TestReadParameterFileWithMissingValue();
11+
bool TestParameterFileWithPointFile();
1112

1213
//---------------------------------------------------------------------------
1314
namespace
@@ -31,6 +32,11 @@ int ModuleDescriptionTest(int argc, char * argv[])
3132
return EXIT_FAILURE;
3233
}
3334

35+
if (!TestParameterFileWithPointFile())
36+
{
37+
return EXIT_FAILURE;
38+
}
39+
3440
return EXIT_SUCCESS;
3541
}
3642

@@ -99,3 +105,68 @@ bool TestReadParameterFileWithMissingValue()
99105

100106
return true;
101107
}
108+
109+
//---------------------------------------------------------------------------
110+
bool TestParameterFileWithPointFile()
111+
{
112+
std::string input = INPUT_DIR
113+
+ "/parameter-file-with-pointfile-slicer-issue2979.params";
114+
115+
ModuleParameterGroup group;
116+
117+
{
118+
ModuleParameter parameter;
119+
parameter.SetName("Input Fiducial File");
120+
parameter.SetDefault("input.fcsv");
121+
parameter.SetTag("pointfile");
122+
parameter.SetMultiple("false");
123+
parameter.SetFileExtensionsAsString(".fcsv");
124+
parameter.SetCoordinateSystem("ras");
125+
parameter.SetChannel("input");
126+
group.AddParameter(parameter);
127+
}
128+
129+
{
130+
ModuleParameter parameter;
131+
parameter.SetName("Output Fiducial File");
132+
parameter.SetDefault("output.fcsv");
133+
parameter.SetTag("pointfile");
134+
parameter.SetMultiple("false");
135+
parameter.SetFileExtensionsAsString(".fcsv");
136+
parameter.SetCoordinateSystem("lps");
137+
parameter.SetChannel("output");
138+
group.AddParameter(parameter);
139+
}
140+
141+
ModuleDescription desc;
142+
desc.AddParameterGroup(group);
143+
144+
if (!desc.HasParameter("Input Fiducial File") || !desc.HasParameter("Output Fiducial File"))
145+
{
146+
std::cerr << "Line " << __LINE__
147+
<< " - Parameters are expected."
148+
<< std::endl;
149+
return false;
150+
}
151+
if (!desc.WriteParameterFile(input, true))
152+
{
153+
std::cerr << "Line " << __LINE__
154+
<< " - Unable to write parameter file "
155+
<< input
156+
<< std::endl;
157+
return false;
158+
}
159+
160+
ModuleDescription readDesc;
161+
if (readDesc.ReadParameterFile(input))
162+
{
163+
std::cerr << "Line " << __LINE__
164+
<< " - Unable to read parameter file, something changed"
165+
<< ", but it was reading into an empty description "
166+
<< input
167+
<< std::endl;
168+
return false;
169+
}
170+
171+
return true;
172+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<executable>
3+
<category>Developer Tools</category>
4+
<title>Fiducial XML Parsing Test</title>
5+
<description><![CDATA[Shows point and pointfiles.]]></description>
6+
<version>0.1.0.$Revision$(alpha)</version>
7+
<license/>
8+
<contributor>Nicole Aucoin (BWH)</contributor>
9+
<acknowledgements><![CDATA[This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.]]></acknowledgements>
10+
<parameters>
11+
<label>Fiducial Input Parameters</label>
12+
<description><![CDATA[Parameters that describe input fidicuals.]]></description>
13+
<point multiple="true" coordinateSystem="ras">
14+
<name>seed</name>
15+
<label>Seeds</label>
16+
<longflag>--seed</longflag>
17+
<description><![CDATA[Lists of points in the CLI correspond to slicer fiducial lists]]></description>
18+
<default>0,0,0</default>
19+
</point>
20+
<pointfile multiple="true" fileExtensions=".fcsv" coordinateSystem="lps">
21+
<name>seedsFile</name>
22+
<description><![CDATA[Test file of input fiducials, compared to seeds]]></description>
23+
<label>Seeds file</label>
24+
<longflag>seedsFile</longflag>
25+
<channel>input</channel>
26+
</pointfile>
27+
</parameters>
28+
<parameters>
29+
<label>Fiducial file return types</label>
30+
<pointfile fileExtensions=".fcsv" coordinateSystem="lps">
31+
<name>seedsOutFile</name>
32+
<label>Output Fiducials File</label>
33+
<description><![CDATA[Output file to read back in.]]></description>
34+
<longflag>seedsOutFile</longflag>
35+
<channel>output</channel>
36+
</pointfile>
37+
</parameters>
38+
</executable>

0 commit comments

Comments
 (0)