From: David Sarrut Date: Thu, 27 Oct 2011 13:54:16 +0000 (+0200) Subject: Add first version of clitkRelativePositionDataBaseAnalyzer X-Git-Tag: v1.3.0~174^2~22 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6ce8b7b14aa86942f0fa47347e452db65c34ab0d;p=clitk.git Add first version of clitkRelativePositionDataBaseAnalyzer --- diff --git a/itk/clitkRelativePositionDataBaseAnalyzerFilter.h b/itk/clitkRelativePositionDataBaseAnalyzerFilter.h new file mode 100644 index 0000000..7066c63 --- /dev/null +++ b/itk/clitkRelativePositionDataBaseAnalyzerFilter.h @@ -0,0 +1,78 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ===========================================================================**/ + +#ifndef CLITKRELATIVEPOSITIONANALYZERFILTER_H +#define CLITKRELATIVEPOSITIONANALYZERFILTER_H + +// clitk +#include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h" +#include "clitkFilterBase.h" +#include "clitkRelativePositionDataBase.h" + +namespace clitk { + + //-------------------------------------------------------------------- + /* + Load a database of relative positions. Analyze it and provide + common relative position for each patient. + */ + //-------------------------------------------------------------------- + + class RelativePositionDataBaseAnalyzerFilter: + public virtual clitk::FilterBase, + public clitk::FilterWithAnatomicalFeatureDatabaseManagement + { + + public: + RelativePositionDataBaseAnalyzerFilter(); + virtual ~RelativePositionDataBaseAnalyzerFilter() {} + + // Input + itkGetConstMacro(DatabaseFilename, std::string); + itkSetMacro(DatabaseFilename, std::string); + itkGetConstMacro(StationName, std::string); + itkSetMacro(StationName, std::string); + itkGetConstMacro(ObjectName, std::string); + itkSetMacro(ObjectName, std::string); + itkGetConstMacro(OutputFilename, std::string); + itkSetMacro(OutputFilename, std::string); + + // For debug + void PrintOptions(); + + // Go ! + virtual void Update(); + + protected: + std::string m_DatabaseFilename; + std::string m_StationName; + std::string m_ObjectName; + std::string m_OutputFilename; + clitk::RelativePositionDataBase db; + + bool ComputeOptimalThreshold(RelativePositionDataBaseIndexType & index, double & threshold); + + }; // end class + //-------------------------------------------------------------------- + +} // end namespace clitk +//-------------------------------------------------------------------- + +#include "clitkRelativePositionDataBaseAnalyzerFilter.txx" + +#endif diff --git a/itk/clitkRelativePositionDataBaseAnalyzerFilter.txx b/itk/clitkRelativePositionDataBaseAnalyzerFilter.txx new file mode 100644 index 0000000..6aa5f3a --- /dev/null +++ b/itk/clitkRelativePositionDataBaseAnalyzerFilter.txx @@ -0,0 +1,131 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ===========================================================================**/ + +//-------------------------------------------------------------------- +clitk::RelativePositionDataBaseAnalyzerFilter:: +RelativePositionDataBaseAnalyzerFilter(): + clitk::FilterBase(), + clitk::FilterWithAnatomicalFeatureDatabaseManagement() +{ + VerboseFlagOff(); + SetDatabaseFilename("default.dbrp"); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void +clitk::RelativePositionDataBaseAnalyzerFilter:: +PrintOptions() +{ + DD("TODO"); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void +clitk::RelativePositionDataBaseAnalyzerFilter:: +Update() +{ + // Load DB of relative position + db.Read(GetDatabaseFilename()); + + // Get list of objects, list of orientation + std::vector m_ListOfObjects; + db.GetListOfObjects(GetStationName(), m_ListOfObjects); + + // Set initial index in the DB + clitk::RelativePositionDataBase::IndexType index; + index.station = GetStationName(); + + // Loop over objects + std::vector m_ListOfThresholds; + for(int i=0; i m_ListOfOrientations; + db.GetListOfOrientations(GetStationName(), index.object, m_ListOfOrientations); + + // Loop over orientation + for(int j=0; j & ListOfPatients = db.GetListOfPatients(index); + // DD(ListOfPatients.size()); + // index.orientation.Println(); + + // For a given station, object, orientation + bool stop=false; + int i=0; + if (index.orientation.notFlag) threshold = 0.0; + else threshold = 1.0; + while (!stop && (i