Commit 5daf0062 authored by Theodor local's avatar Theodor local
Browse files

Added custom geometry generator

parent e2378a19
Pipeline #441407 failed with stages
in 58 seconds
......@@ -139,4 +139,62 @@ namespace elsa
return std::make_unique<PlanarDetectorDescriptor>(coeffs, spacing, geometryList);
}
std::unique_ptr<DetectorDescriptor> CircleTrajectoryGenerator::createTrajectoryCustom(
index_t detectorSize, const DataDescriptor& volumeDescriptor,
real_t sourceToCenter, real_t centerToDetector, std::vector<float> angles)
{
// pull in geometry namespace, to reduce cluttering
using namespace geometry;
// sanity check
const auto dim = volumeDescriptor.getNumberOfDimensions();
if (dim < 2 || dim > 3)
throw std::invalid_argument("CircleTrajectoryGenerator: can only handle 2d/3d");
size_t numberOfPoses = angles.size();
Logger::get("CircleTrajectoryGenerator")
->info("creating custom {}D trajectory with {} poses", dim, numberOfPoses);
IndexVector_t coeffs(dim);
RealVector_t spacing(dim);
if (dim == 2) {
// int next_power_of_two = std::pow(2, int(std::log2(volumeDescriptor.getNumberOfCoefficientsPerDimension()[0]))+1);
coeffs << detectorSize, numberOfPoses;
spacing << volumeDescriptor.getSpacingPerDimension()[0], 1;
} else {
coeffs << detectorSize, detectorSize, numberOfPoses;
spacing << volumeDescriptor.getSpacingPerDimension()[0],
volumeDescriptor.getSpacingPerDimension()[1], 1;
}
// Create vector and reserve the necessary size, minor optimization such that no new
// allocations are necessary in the loop
std::vector<Geometry> geometryList;
geometryList.reserve(numberOfPoses);
for (index_t i = 0; i < numberOfPoses; ++i) {
if (dim == 2) {
// Use emplace_back, then no copy is created
geometryList.emplace_back(SourceToCenterOfRotation{sourceToCenter},
CenterOfRotationToDetector{centerToDetector},
Radian{Degree{angles.at(i)}},
VolumeData2D{volumeDescriptor.getSpacingPerDimension(),
volumeDescriptor.getLocationOfOrigin()},
SinogramData2D{Size2D{coeffs}, Spacing2D{spacing}});
} else {
geometryList.emplace_back(SourceToCenterOfRotation{sourceToCenter},
CenterOfRotationToDetector{centerToDetector},
VolumeData3D{volumeDescriptor.getSpacingPerDimension(),
volumeDescriptor.getLocationOfOrigin()},
SinogramData3D{Size3D{coeffs}, Spacing3D{spacing}},
RotationAngles3D{Radian{Degree{angles.at(i)}}, Radian{0}, Radian{0}});
}
}
return std::make_unique<PlanarDetectorDescriptor>(coeffs, spacing, geometryList);
}
} // namespace elsa
......@@ -48,6 +48,10 @@ namespace elsa
static std::unique_ptr<DetectorDescriptor>
createTrajectoryFromSize(index_t numberOfPoses, index_t detectorSize, const DataDescriptor& volumeDescriptor, index_t arcDegrees,
real_t sourceToCenter, real_t centerToDetector);
static std::unique_ptr<DetectorDescriptor>
createTrajectoryCustom(index_t detectorSize, const DataDescriptor& volumeDescriptor,
real_t sourceToCenter, real_t centerToDetector, std::vector<float> angles);
};
} // namespace elsa
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment