MCPcopy Create free account
hub / github.com/astra-toolbox/astra-toolbox / initialize

Method initialize

src/ArtAlgorithm.cpp:87–143  ·  view source on GitHub ↗

--------------------------------------------------------------------------------------- Initialize - Config

Source from the content-addressed store, hash-verified

85//---------------------------------------------------------------------------------------
86// Initialize - Config
87bool CArtAlgorithm::initialize(const Config& _cfg)
88{
89 assert(!m_bIsInitialized);
90
91 ConfigReader<CAlgorithm> CR("ArtAlgorithm", this, _cfg);
92
93 // initialization of parent class
94 if (!CReconstructionAlgorithm2D::initialize(_cfg)) {
95 return false;
96 }
97
98 // ray order
99 std::string projOrder;
100 if (!CR.getOptionString("RayOrder", projOrder, "sequential"))
101 return false;
102 m_iCurrentRay = 0;
103 int iRayCount = m_pProjector->getProjectionGeometry().getProjectionAngleCount() *
104 m_pProjector->getProjectionGeometry().getDetectorCount();
105 if (projOrder == "sequential") {
106 m_piProjectionOrder.resize(iRayCount);
107 m_piDetectorOrder.resize(iRayCount);
108 for (int i = 0; i < iRayCount; i++) {
109 m_piProjectionOrder[i] = i / m_pProjector->getProjectionGeometry().getDetectorCount();
110 m_piDetectorOrder[i] = i % m_pProjector->getProjectionGeometry().getDetectorCount();
111 }
112 } else if (projOrder == "custom") {
113 std::vector<int> rayOrderList;
114 if (!CR.hasOption("RayOrderList"))
115 return false;
116 if (!CR.getOptionIntArray("RayOrderList", rayOrderList))
117 return false;
118 iRayCount = rayOrderList.size() / 2;
119 m_piProjectionOrder.resize(iRayCount);
120 m_piDetectorOrder.resize(iRayCount);
121 for (int i = 0; i < iRayCount; i++) {
122 m_piProjectionOrder[i] = rayOrderList[2*i];
123 m_piDetectorOrder[i] = rayOrderList[2*i+1];
124 }
125 } else {
126 ASTRA_ERROR("Unknown RayOrder");
127 return false;
128 }
129
130 bool ok = true;
131
132 // "Lambda" is replaced by the more descriptive "Relaxation"
133 if (CR.hasOption("Relaxation"))
134 ok &= CR.getOptionNumerical("Relaxation", m_fLambda, 1.0f);
135 else
136 ok &= CR.getOptionNumerical("Lambda", m_fLambda, 1.0f);
137 if (!ok)
138 return false;
139
140 // success
141 m_bIsInitialized = _check();
142 return m_bIsInitialized;
143}
144

Callers

nothing calls this directly

Calls 6

getDetectorCountMethod · 0.80
getOptionStringMethod · 0.45
hasOptionMethod · 0.45
getOptionIntArrayMethod · 0.45
getOptionNumericalMethod · 0.45

Tested by

no test coverage detected