Skip to content

Commit a36f38e

Browse files
committed
ENH: Improved methods and examples for CTA processing
Removed CTP processing.
1 parent cee053a commit a36f38e

25 files changed

+1393
-2244
lines changed

examples/Applications/TubeMath/TubeMath.cxx

Lines changed: 130 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,58 @@ ReadTubeFile( const char * fileName )
5151

5252
typename SpatialObjectReaderType::GroupType::Pointer group =
5353
reader->GetGroup();
54-
group->Update();
54+
try
55+
{
56+
group->Update();
57+
}
58+
catch( const itk::ExceptionObject & e )
59+
{
60+
std::cout << "ITK Error:" << std::endl;
61+
std::cout << e.GetDescription() << std::endl;
62+
}
63+
catch( const std::exception & e )
64+
{
65+
std::cout << "STD Error:" << std::endl;
66+
std::cout << e.what() << std::endl;
67+
}
68+
catch(...)
69+
{
70+
std::cout << "Unknown error." << std::endl;
71+
}
72+
5573
return group;
5674
}
5775

5876
template< unsigned int DimensionT >
5977
void WriteTubeFile( typename itk::GroupSpatialObject< DimensionT >::Pointer
6078
object, const char * fileName )
6179
{
80+
std::cout << "Writing" << std::endl;
6281
typedef itk::SpatialObjectWriter< DimensionT > SpatialObjectWriterType;
6382

6483
typename SpatialObjectWriterType::Pointer writer =
6584
SpatialObjectWriterType::New();
6685
writer->SetInput( object );
6786
writer->SetFileName( fileName );
68-
writer->Update();
87+
try
88+
{
89+
writer->Update();
90+
}
91+
catch( const itk::ExceptionObject & e )
92+
{
93+
std::cout << "ITK Error:" << std::endl;
94+
std::cout << e.GetDescription() << std::endl;
95+
}
96+
catch( const std::exception & e )
97+
{
98+
std::cout << "STD Error:" << std::endl;
99+
std::cout << e.what() << std::endl;
100+
}
101+
catch(...)
102+
{
103+
std::cout << "Unknown error." << std::endl;
104+
}
105+
69106
}
70107

71108
template< class PixelT, unsigned int DimensionT >
@@ -77,7 +114,24 @@ ReadImageFile( const char * fileName )
77114

78115
typename ImageReaderType::Pointer reader = ImageReaderType::New();
79116
reader->SetFileName( fileName );
80-
reader->Update();
117+
try
118+
{
119+
reader->Update();
120+
}
121+
catch( const itk::ExceptionObject & e )
122+
{
123+
std::cout << "ITK Error:" << std::endl;
124+
std::cout << e.GetDescription() << std::endl;
125+
}
126+
catch( const std::exception & e )
127+
{
128+
std::cout << "STD Error:" << std::endl;
129+
std::cout << e.what() << std::endl;
130+
}
131+
catch(...)
132+
{
133+
std::cout << "Unknown error." << std::endl;
134+
}
81135

82136
return reader->GetOutput();
83137
}
@@ -138,13 +192,49 @@ int DoIt( MetaCommand & command )
138192
command.GetValueAsString( *it, "value" ) );
139193
inputTubes = filter.GetOutputTubeGroup();
140194
}
195+
else if( it->name == "LoadPointValuesFromTubeRegions" )
196+
{
197+
static bool first = true;
198+
std::cout << "Load Values From Regions" << std::endl;
199+
typedef itk::Image< float, DimensionT > ImageType;
200+
typename ImageType::Pointer valueImage = ReadImageFile< float,
201+
DimensionT >( command.GetValueAsString( *it, "filename" ).c_str() );
202+
if( first )
203+
{
204+
first = false;
205+
filter.ComputeTubeRegions(valueImage);
206+
}
207+
filter.SetPointValuesFromTubeRegions( valueImage,
208+
command.GetValueAsString( *it, "value" ),
209+
command.GetValueAsFloat( *it, "minRadiusFactor" ),
210+
command.GetValueAsFloat( *it, "maxRadiusFactor" ) );
211+
inputTubes = filter.GetOutputTubeGroup();
212+
}
213+
else if( it->name == "LoadPointValuesFromTubeRadius" )
214+
{
215+
static bool first = true;
216+
std::cout << "Load Values From Radius" << std::endl;
217+
typedef itk::Image< float, DimensionT > ImageType;
218+
typename ImageType::Pointer valueImage = ReadImageFile< float,
219+
DimensionT >( command.GetValueAsString( *it, "filename" ).c_str() );
220+
if( first )
221+
{
222+
first = false;
223+
filter.ComputeTubeRegions(valueImage);
224+
}
225+
filter.SetPointValuesFromTubeRadius( valueImage,
226+
command.GetValueAsString( *it, "value" ),
227+
command.GetValueAsFloat( *it, "minRadiusFactor" ),
228+
command.GetValueAsFloat( *it, "maxRadiusFactor" ) );
229+
inputTubes = filter.GetOutputTubeGroup();
230+
}
141231
else if( it->name == "Delete" )
142232
{
143-
::tube::Message( "Delete" );
233+
::tube::Message( "Delete Not Implemented" );
144234
}
145235
else if( it->name == "Reverse" )
146236
{
147-
::tube::Message( "Reverse" );
237+
::tube::Message( "Reverse Not Implemented" );
148238
}
149239
else if( it->name == "FillGapsInTree" )
150240
{
@@ -186,6 +276,12 @@ int DoIt( MetaCommand & command )
186276
filter.SmoothTube( sigma );
187277
inputTubes = filter.GetOutputTubeGroup();
188278
}
279+
else if( it->name == "RenumberTubes" )
280+
{
281+
std::cout << "RenumberTubes" << std::endl;
282+
filter.RenumberTubes();
283+
inputTubes = filter.GetOutputTubeGroup();
284+
}
189285
else if( it->name == "RenumberPoints" )
190286
{
191287
std::cout << "RenumberPoints" << std::endl;
@@ -338,6 +434,32 @@ int main( int argc, char * argv[] )
338434
command.AddOptionField( "LoadPointValuesFromImageMean", "filename",
339435
MetaCommand::STRING, true, "", "Image filename", MetaCommand::DATA_IN );
340436

437+
command.SetOption( "LoadPointValuesFromTubeRegions", "p", false,
438+
"Set tube point values as averages in regions that are closest to them." );
439+
command.AddOptionField( "LoadPointValuesFromTubeRegions", "value",
440+
MetaCommand::STRING, true, "",
441+
"Ridgeness, Medialness, Branchness, Radius, <NewVarName>",
442+
MetaCommand::DATA_IN );
443+
command.AddOptionField( "LoadPointValuesFromTubeRegions", "filename",
444+
MetaCommand::STRING, true, "", "Image filename", MetaCommand::DATA_IN );
445+
command.AddOptionField( "LoadPointValuesFromTubeRegions", "minRadiusFactor",
446+
MetaCommand::FLOAT, true );
447+
command.AddOptionField( "LoadPointValuesFromTubeRegions", "maxRadiusFactor",
448+
MetaCommand::FLOAT, true );
449+
450+
command.SetOption( "LoadPointValuesFromTubeRadius", "P", false,
451+
"Set tube point values as averages in regions that are closest to them." );
452+
command.AddOptionField( "LoadPointValuesFromTubeRadius", "value",
453+
MetaCommand::STRING, true, "",
454+
"Ridgeness, Medialness, Branchness, Radius, <NewVarName>",
455+
MetaCommand::DATA_IN );
456+
command.AddOptionField( "LoadPointValuesFromTubeRadius", "filename",
457+
MetaCommand::STRING, true, "", "Image filename", MetaCommand::DATA_IN );
458+
command.AddOptionField( "LoadPointValuesFromTubeRadius", "minRadiusFactor",
459+
MetaCommand::FLOAT, true );
460+
command.AddOptionField( "LoadPointValuesFromTubeRadius", "maxRadiusFactor",
461+
MetaCommand::FLOAT, true );
462+
341463
command.SetOption( "FillGapsInTubeTree", "f", false,
342464
"Connects the parent and child tube if they have a gap inbetween,"
343465
" by interpolating the path inbetween." );
@@ -354,6 +476,9 @@ int main( int argc, char * argv[] )
354476
command.SetOption( "RenumberPoints", "r", false,
355477
"Assigned points sequential numbers for Id." );
356478

479+
command.SetOption( "RenumberTubes", "R", false,
480+
"Assigned tubes sequential numbers for Id." );
481+
357482
command.SetOption( "ComputeTangentsAndNormals", "n", false,
358483
"Compute current tube's tangents and normals from point sequence." );
359484

Binary file not shown.

0 commit comments

Comments
 (0)