1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 //--------------------------------------------------------------------
20 clitk::RelativePositionDataBaseAnalyzerFilter::
21 RelativePositionDataBaseAnalyzerFilter():
23 clitk::FilterWithAnatomicalFeatureDatabaseManagement()
26 SetDatabaseFilename("default.dbrp");
28 //--------------------------------------------------------------------
31 //--------------------------------------------------------------------
33 clitk::RelativePositionDataBaseAnalyzerFilter::
38 //--------------------------------------------------------------------
41 //--------------------------------------------------------------------
43 clitk::RelativePositionDataBaseAnalyzerFilter::
46 // Load DB of relative position
47 db.Read(GetDatabaseFilename());
49 // Get list of objects, list of orientation
50 std::vector<std::string> m_ListOfObjects;
51 db.GetListOfObjects(GetStationName(), m_ListOfObjects);
53 // Set initial index in the DB
54 clitk::RelativePositionDataBase::IndexType index;
55 index.station = GetStationName();
58 std::vector<double> m_ListOfThresholds;
59 for(unsigned int i=0; i<m_ListOfObjects.size(); i++) {
61 // DD(m_ListOfObjects[i]);
63 index.object = m_ListOfObjects[i];
64 // Get the list of direction
65 std::vector<clitk::RelativePositionDirectionType> m_ListOfDirections;
66 db.GetListOfDirections(GetStationName(), index.object, m_ListOfDirections);
68 // Loop over direction
69 for(unsigned int j=0; j<m_ListOfDirections.size(); j++) {
71 // m_ListOfDirections[j].Println();
73 index.direction = m_ListOfDirections[j];
74 // Compute the best RelPos parameters
76 bool ok = ComputeOptimalThreshold(index, threshold);
77 m_ListOfThresholds.push_back(threshold);
81 /*std::cout << m_ListOfObjects[i] << " ";
82 m_ListOfDirections[j].Print();
83 std::cout << " " << threshold << " " << ok << std::endl;
85 std::cout << "# -----------------------" << std::endl
86 << "object = " << m_ListOfObjects[i] << std::endl;
87 m_ListOfDirections[j].PrintOptions();
88 std::cout << "threshold = " << threshold << std::endl
89 << "sliceBySlice" << std::endl << std::endl; // FIXME spacing ?
94 //--------------------------------------------------------------------
97 //--------------------------------------------------------------------
99 clitk::RelativePositionDataBaseAnalyzerFilter::
100 ComputeOptimalThreshold(RelativePositionDataBaseIndexType & index, double & threshold)
102 // Get list of patient
103 std::vector<std::string> & ListOfPatients = db.GetListOfPatients(index);
104 // DD(ListOfPatients.size());
105 // index.direction.Println();
107 // For a given station, object, direction
110 if (index.direction.notFlag) threshold = 0.0;
111 else threshold = 1.0;
112 while (!stop && (i<ListOfPatients.size())) {
113 index.patient = ListOfPatients[i];
115 if (!db.CheckIndex(index)) {
116 std::cout << "Warning index does not exist in the DB. index = ";
117 index.Println(std::cout);
120 if (index.direction.notFlag) threshold = std::max(db.GetThreshold(index), threshold);
121 else threshold = std::min(db.GetThreshold(index), threshold);
126 if (index.direction.notFlag) {
127 if (threshold >=1) return false; // not useful
130 if (threshold <=0) return false; // not useful
134 //--------------------------------------------------------------------