is >> index.patient;
is >> index.station;
is >> index.object;
- is >> index.orientation.angle1;
- index.orientation.angle1 = clitk::deg2rad(index.orientation.angle1);
- is >> index.orientation.angle2;
- index.orientation.angle2 = clitk::deg2rad(index.orientation.angle2);
+ is >> index.direction.angle1;
+ index.direction.angle1 = clitk::deg2rad(index.direction.angle1);
+ is >> index.direction.angle2;
+ index.direction.angle2 = clitk::deg2rad(index.direction.angle2);
std::string s;
is >> s;
- if (s=="true") index.orientation.notFlag = true;
- else index.orientation.notFlag = false;
+ if (s=="true") index.direction.notFlag = true;
+ else index.direction.notFlag = false;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void RelativePositionDataBase::Read(const std::string & filename)
{
- DD(filename);
std::ifstream is;
openFileForReading(is, filename);
}
MapByObjectType & s = m_DB[index.station];
- // Get Orientation map from Object
+ // Get Direction map from Object
if (s.find(index.object) == s.end()) {
- MapByOrientationType r;
+ MapByDirectionType r;
s[index.object] = r;
}
- MapByOrientationType & r = s[index.object];
+ MapByDirectionType & r = s[index.object];
- // Get Patient map from Orientation
- if (r.find(index.orientation) == r.end()) {
+ // Get Patient map from Direction
+ if (r.find(index.direction) == r.end()) {
MapByPatientType q;
- r[index.orientation] = q;
+ r[index.direction] = q;
}
- MapByPatientType & q = r[index.orientation];
+ MapByPatientType & q = r[index.direction];
// Set value by patient
q[index.patient] = v;
} // End insertion
} // end loop reading
- DD("end read");
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
- const RelativePositionDataBase::MapByOrientationType &
- RelativePositionDataBase::GetMapByOrientation(const IndexType & index) const
+ const RelativePositionDataBase::MapByDirectionType &
+ RelativePositionDataBase::GetMapByDirection(const IndexType & index) const
{
const MapByObjectType & a = GetMapByObject(index.station);
if (a.find(index.object) == a.end()) {
const RelativePositionDataBase::MapByPatientType &
RelativePositionDataBase::GetMapByPatient(const IndexType & index) const
{
- const MapByOrientationType & a = GetMapByOrientation(index);
- if (a.find(index.orientation) == a.end()) {
+ const MapByDirectionType & a = GetMapByDirection(index);
+ if (a.find(index.direction) == a.end()) {
std::ostringstream s;
- index.orientation.Print(s);
- clitkExceptionMacro("Could not find index in DB (orientation= '" << s.str() << "' not found).");
+ index.direction.Print(s);
+ clitkExceptionMacro("Could not find index in DB (direction= '" << s.str() << "' not found).");
}
- return a.find(index.orientation)->second;
+ return a.find(index.direction)->second;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void
- RelativePositionDataBase::GetListOfOrientations(const std::string & station,
+ RelativePositionDataBase::GetListOfDirections(const std::string & station,
const std::string & object,
- std::vector<RelativePositionOrientationType> & orientations) const
+ std::vector<RelativePositionDirectionType> & directions) const
{
IndexType i;
i.station = station;
i.object = object;
- const MapByOrientationType & n = GetMapByOrientation(i);
- MapToVecFirst(n, orientations);
+ const MapByDirectionType & n = GetMapByDirection(i);
+ MapToVecFirst(n, directions);
}
//--------------------------------------------------------------------
--- /dev/null
+/*=========================================================================
+ 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 CLITKRELATIVEPOSITIONDATABASE_H
+#define CLITKRELATIVEPOSITIONDATABASE_H
+
+// clitk
+#include "clitkCommon.h"
+
+namespace clitk {
+
+ //--------------------------------------------------------------------
+ /*
+ FIXME
+ */
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ class RelativePositionDirectionType {
+ public:
+ double angle1;
+ double angle2;
+ bool notFlag;
+
+ void Print(std::ostream & os = std::cout) const {
+ os << clitk::rad2deg(angle1) << " " << clitk::rad2deg(angle2) << " ";
+ if (notFlag) os << "true";
+ else os << "false";
+ os << " ";
+ }
+
+ void PrintOptions(std::ostream & os = std::cout) const {
+ os << "angle1 = " << clitk::rad2deg(angle1) << std::endl
+ << "angle2 = " << clitk::rad2deg(angle2) << std::endl;
+ if (notFlag) os << "inverse" << std::endl;
+ }
+
+ void Println(std::ostream & os = std::cout) const {
+ Print(os);
+ os << std::endl;
+ }
+
+ bool operator< (const RelativePositionDirectionType &compare) const
+ {
+ if (angle1 < compare.angle1) return true;
+ if (angle1 > compare.angle1) return false;
+
+ if (angle2 < compare.angle2) return true;
+ if (angle2 > compare.angle2) return false;
+
+ if (notFlag == true) {
+ if (compare.notFlag == false) return true;
+ else return false;
+ }
+ return false;
+ }
+ };
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ class RelativePositionDataBaseIndexType {
+ public:
+ std::string patient;
+ std::string station;
+ std::string object;
+ RelativePositionDirectionType direction;
+ void Print(std::ostream & os = std::cout) const {
+ os << patient << " " << station << " " << object << " ";
+ direction.Print(os);
+ }
+ void Println(std::ostream & os = std::cout) const {
+ Print(os);
+ os << std::endl;
+ }
+ };
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ class RelativePositionInformationType {
+ public:
+ double threshold;
+ int sizeBeforeThreshold;
+ int sizeAfterThreshold;
+ int sizeReference;
+ void Print(std::ostream & os = std::cout) const {
+ os << threshold << " " << sizeBeforeThreshold << " "
+ << sizeAfterThreshold << " " << sizeReference;
+ }
+ void Println(std::ostream & os = std::cout) const {
+ Print(os);
+ os << std::endl;
+ }
+ };
+ //--------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------
+ class RelativePositionDataBase {
+
+ public:
+ RelativePositionDataBase() {}
+ ~RelativePositionDataBase() {}
+
+ typedef RelativePositionDataBaseIndexType IndexType;
+
+ void Read(const std::string & filename);
+ double GetAreaGain(const IndexType & index) const;
+ double GetThreshold(const IndexType & index) const;
+ int GetNumberOfPatient(const IndexType & index) const;
+ std::vector<std::string> & GetListOfPatients(const IndexType & index) const;
+ void GetListOfObjects(const std::string & station, std::vector<std::string> & objects) const;
+ void GetListOfDirections(const std::string & station,
+ const std::string & object,
+ std::vector<RelativePositionDirectionType> & directions) const;
+ bool CheckIndex(const IndexType & index) const;
+
+ protected:
+ typedef std::map<std::string, RelativePositionInformationType> MapByPatientType;
+ typedef std::map<RelativePositionDirectionType, MapByPatientType> MapByDirectionType;
+ typedef std::map<std::string, MapByDirectionType> MapByObjectType;
+ typedef std::map<std::string, MapByObjectType> MapByStationType;
+ MapByStationType m_DB;
+
+ void ReadIndex(std::istream & is, IndexType & index);
+ void ReadInformation(std::istream & is, RelativePositionInformationType & v);
+
+ const MapByDirectionType & GetMapByDirection(const IndexType & index) const;
+ const MapByPatientType & GetMapByPatient(const IndexType & index) const;
+ const RelativePositionInformationType & GetInformation(const IndexType & index) const;
+ const MapByObjectType & GetMapByObject(const std::string & station) const;
+
+ }; // end class
+ //--------------------------------------------------------------------
+
+} // end namespace clitk
+//--------------------------------------------------------------------
+
+#endif