@@ -51,21 +51,58 @@ ReadTubeFile( const char * fileName )
51
51
52
52
typename SpatialObjectReaderType::GroupType::Pointer group =
53
53
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
+
55
73
return group;
56
74
}
57
75
58
76
template < unsigned int DimensionT >
59
77
void WriteTubeFile ( typename itk::GroupSpatialObject< DimensionT >::Pointer
60
78
object, const char * fileName )
61
79
{
80
+ std::cout << " Writing" << std::endl;
62
81
typedef itk::SpatialObjectWriter< DimensionT > SpatialObjectWriterType;
63
82
64
83
typename SpatialObjectWriterType::Pointer writer =
65
84
SpatialObjectWriterType::New ();
66
85
writer->SetInput ( object );
67
86
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
+
69
106
}
70
107
71
108
template < class PixelT , unsigned int DimensionT >
@@ -77,7 +114,24 @@ ReadImageFile( const char * fileName )
77
114
78
115
typename ImageReaderType::Pointer reader = ImageReaderType::New ();
79
116
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
+ }
81
135
82
136
return reader->GetOutput ();
83
137
}
@@ -138,13 +192,49 @@ int DoIt( MetaCommand & command )
138
192
command.GetValueAsString ( *it, " value" ) );
139
193
inputTubes = filter.GetOutputTubeGroup ();
140
194
}
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
+ }
141
231
else if ( it->name == " Delete" )
142
232
{
143
- ::tube::Message ( " Delete" );
233
+ ::tube::Message ( " Delete Not Implemented " );
144
234
}
145
235
else if ( it->name == " Reverse" )
146
236
{
147
- ::tube::Message ( " Reverse" );
237
+ ::tube::Message ( " Reverse Not Implemented " );
148
238
}
149
239
else if ( it->name == " FillGapsInTree" )
150
240
{
@@ -186,6 +276,12 @@ int DoIt( MetaCommand & command )
186
276
filter.SmoothTube ( sigma );
187
277
inputTubes = filter.GetOutputTubeGroup ();
188
278
}
279
+ else if ( it->name == " RenumberTubes" )
280
+ {
281
+ std::cout << " RenumberTubes" << std::endl;
282
+ filter.RenumberTubes ();
283
+ inputTubes = filter.GetOutputTubeGroup ();
284
+ }
189
285
else if ( it->name == " RenumberPoints" )
190
286
{
191
287
std::cout << " RenumberPoints" << std::endl;
@@ -338,6 +434,32 @@ int main( int argc, char * argv[] )
338
434
command.AddOptionField ( " LoadPointValuesFromImageMean" , " filename" ,
339
435
MetaCommand::STRING, true , " " , " Image filename" , MetaCommand::DATA_IN );
340
436
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
+
341
463
command.SetOption ( " FillGapsInTubeTree" , " f" , false ,
342
464
" Connects the parent and child tube if they have a gap inbetween,"
343
465
" by interpolating the path inbetween." );
@@ -354,6 +476,9 @@ int main( int argc, char * argv[] )
354
476
command.SetOption ( " RenumberPoints" , " r" , false ,
355
477
" Assigned points sequential numbers for Id." );
356
478
479
+ command.SetOption ( " RenumberTubes" , " R" , false ,
480
+ " Assigned tubes sequential numbers for Id." );
481
+
357
482
command.SetOption ( " ComputeTangentsAndNormals" , " n" , false ,
358
483
" Compute current tube's tangents and normals from point sequence." );
359
484
0 commit comments