- 1, true, LRMost,
- distance_max_from_center_point,
- antMost);
- // Only add point if found
- if (found) {
- // ------- Convert 2D to 3D points --------
- MaskImageType::PointType p;
- clitk::PointsUtils<MaskImageType>::Convert2DTo3D(LRMost, input, i, p);
- LR.push_back(p);
- clitk::PointsUtils<MaskImageType>::Convert2DTo3D(antMost, input, i, p);
- Ant.push_back(p);
- clitk::PointsUtils<MaskImageType>::Convert2DTo3D(postMost, input, i, p);
- Post.push_back(p);
+ 2, false, B);
+ if (!b) {
+ clitkExceptionMacro("Error while searching most superior point in RightMiddleLobeBronchus. Abort");
+ }
+
+ // Insert into the DB
+ GetAFDB()->SetPoint3D("LineForS7S8Separation_Begin", A);
+ GetAFDB()->SetPoint3D("LineForS7S8Separation_End", B);
+ }
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class TImageType>
+double
+clitk::ExtractLymphStationsFilter<TImageType>::
+FindCarinaSlicePosition()
+{
+ double z;
+ try {
+ z = GetAFDB()->GetDouble("CarinaZ");
+ }
+ catch(clitk::ExceptionObject e) {
+ DD("FindCarinaSlicePosition");
+ // Get Carina
+ MaskImagePointer Carina = GetAFDB()->template GetImage<MaskImageType>("Carina");
+
+ // Get Centroid and Z value
+ std::vector<MaskImagePointType> centroids;
+ clitk::ComputeCentroids<MaskImageType>(Carina, GetBackgroundValue(), centroids);
+
+ // We dont need Carina structure from now
+ Carina->Delete();
+
+ // Put inside the AFDB
+ GetAFDB()->SetPoint3D("CarinaPoint", centroids[1]);
+ GetAFDB()->SetDouble("CarinaZ", centroids[1][2]);
+ WriteAFDB();
+ z = centroids[1][2];
+ }
+ return z;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class TImageType>
+void
+clitk::ExtractLymphStationsFilter<TImageType>::
+FindLeftAndRightBronchi()
+{
+ try {
+ m_RightBronchus = GetAFDB()->template GetImage <MaskImageType>("RightBronchus");
+ m_LeftBronchus = GetAFDB()->template GetImage <MaskImageType>("LeftBronchus");
+ }
+ catch(clitk::ExceptionObject & o) {
+
+ DD("FindLeftAndRightBronchi");
+ // The goal is to separate the trachea inferiorly to the carina into
+ // a Left and Right bronchus.
+
+ // Get the trachea
+ MaskImagePointer Trachea = GetAFDB()->template GetImage<MaskImageType>("Trachea");
+
+ // Get the Carina position
+ m_CarinaZ = FindCarinaSlicePosition();
+
+ // Consider only inferiorly to the Carina
+ MaskImagePointer m_Working_Trachea =
+ clitk::CropImageRemoveGreaterThan<MaskImageType>(Trachea, 2, m_CarinaZ, true, // AutoCrop
+ GetBackgroundValue());
+
+ // Labelize the trachea
+ m_Working_Trachea = Labelize<MaskImageType>(m_Working_Trachea, 0, true, 1);
+
+ // Carina position must at the first slice that separate the two
+ // main bronchus (not superiorly). We thus first check that the
+ // upper slice is composed of at least two labels
+ MaskImagePointer RightBronchus;
+ MaskImagePointer LeftBronchus;
+ typedef itk::ImageSliceIteratorWithIndex<MaskImageType> SliceIteratorType;
+ SliceIteratorType iter(m_Working_Trachea, m_Working_Trachea->GetLargestPossibleRegion());
+ iter.SetFirstDirection(0);
+ iter.SetSecondDirection(1);
+ iter.GoToReverseBegin(); // Start from the end (because image is IS not SI)
+ int maxLabel=0;
+ while (!iter.IsAtReverseEndOfSlice()) {
+ while (!iter.IsAtReverseEndOfLine()) {
+ if (iter.Get() > maxLabel) maxLabel = iter.Get();
+ --iter;
+ }
+ iter.PreviousLine();