Commit 702a7057 authored by kulvait's avatar kulvait

Parsing regression arguments

Add classes to simpler parsing of CT regression arguments
parent 6c56e5d1
#pragma once
#include "CLI/CLI.hpp" //Command line parser
#include "PROG/Arguments.hpp"
namespace CTL::util {
// Using virtual inheritance to include only one copy of Arguments class into the pegigree
class ArgumentsAcquisitionSetup : public virtual Arguments
{
public:
ArgumentsAcquisitionSetup(int argc, char** argv, std::string prgName)
: Arguments(argc, argv, prgName){};
// Acquisition setup parameters
CLI::Option_group* og_acquisition = nullptr;
/**
*Size of pause between sweeps [ms].
*
*Computed from DICOM files as 2088.88889ms. Based on experiment, it is 1171ms.
*/
float pause_size = 1171;
/** Frame Time. (0018, 1063) Nominal time (in msec) per individual frame.
*
*The model assumes that there is delay between two consecutive frames of the frame_time.
*First frame is aquired directly after pause. From DICOM it is 16.6666667ms. From
*experiment 16.8ms.
*/
float frame_time = 16.8;
uint32_t sweep_count = 10;
uint32_t angles_per_sweep = 248;
protected:
void addCarmAcquisitionSetupGroup();
void addCarmAcquisitionSetupArgs(bool sweepCountAsConfigurableArgument = false, bool anglesPerSweepAsConfigurableArgument = false);
private:
};
} // namespace CTL::util
#pragma once
#include "CLI/CLI.hpp" //Command line parser
#include "PROG/Arguments.hpp"
namespace CTL::util {
// Using virtual inheritance to include only one copy of Arguments class into the pegigree
class ArgumentsBasisSpecification : public virtual Arguments
{
public:
ArgumentsBasisSpecification(int argc, char** argv, std::string prgName)
: Arguments(argc, argv, prgName){};
// Basis specification
CLI::Option_group* og_basis = nullptr;
CLI::Option_group* og_basis_type = nullptr;
bool useLegendrePolynomials = false;
bool useChebyshevPolynomials = false;
bool useFourierBasis = false;
std::string engineerBasis = "";
// Basis and timings
uint32_t basisSize = 5;
/** Controls the size of the time interval [ms] that should be identified with 0.0.
*
* For offsetted acquisitions also often 4145.
*/
float start_offset = 0.0, end_offset = 0.0;
/**How to treat functions outside the interval support
*
* removeOutsideInterval ... don't consider values outside interval and delete them from
* analysis constantOutsideInterval .. consider only the endvalues of the first basis function
* other zero endvalueOutsideInterval .. extend endvalues of every basis function, this might
* lead to the loss of orthogonality
*/
CLI::Option_group* og_outside_basis = nullptr;
bool removeOutsideInterval = false;
bool constantOutsideInterval = false;
bool endvalueOutsideInterval = false;
CLI::Option_group* og_fourier_basis = nullptr;
// In the interval outside [start_offset, end_offset] is still performed the fitting when the
// parameter is false, when the parameter is true, data outside of this interval is not used at
// all
bool halfPeriodicFunctions = false;
CLI::Option_group* og_polynomial_basis = nullptr;
CLI::Option_group* og_engineer_basis = nullptr;
bool fitSplinesToTheBasisBreakpoints = false;
float basisTimeShift = 0.0;
protected:
void addBasisSpecificationGroup();
void addOutsideBasisSpecificationGroup();
void addBasisTypeGroup();
void addBasisSpecificationArgs(bool includeBasisSize, bool includeBasisSetSelectionArgs);
void addFourierBasisSpecificationGroup();
void addFourierBasisSpecificationArgs();
void addPolynomialBasisSpecificationGroup();
void addPolynomialBasisSpecificationArgs();
void addEngineerBasisSpecificationGroup();
void addEngineerBasisSpecificationArgs();
private:
};
} // namespace CTL::util
#include "PROG/ArgumentsAcquisitionSetup.hpp" //Command line parser
using namespace CTL;
using namespace CTL::util;
void ArgumentsAcquisitionSetup::addCarmAcquisitionSetupGroup()
{
if(og_acquisition == nullptr)
{
og_acquisition = cliApp->add_option_group(
"Acquisition setup",
"Specification of the C-Arm CT acquisition timings and other parameters.");
registerOptionGroup("acquisition", og_acquisition);
}
}
void ArgumentsAcquisitionSetup::addCarmAcquisitionSetupArgs(bool sweepCountAsConfigurableArgument, bool anglesPerSweepAsConfigurableArgument)
{
addCarmAcquisitionSetupGroup();
std::string optstr = io::xprintf(
"Size of pause between two consecutive sweeps [ms]. Defaults to %.1f.", pause_size);
CLI::Option* option = og_acquisition->add_option("-s,--pause-size", pause_size, optstr);
registerOption("pause_size", option);
optstr = io::xprintf("Frame time. Nominal time (in msec) per individual frame, dicom (0018, "
"1063) [ms]. Defaults to %.1f.",
frame_time);
option = og_acquisition->add_option("-f,--frame-time", frame_time, optstr);
registerOption("frame_time", option);
if(sweepCountAsConfigurableArgument)
{
optstr = io::xprintf(
"Sweep count. Number of full rotations per acquisition. Forward rotation "
"with consecutive backward rotation are counted as two sweeps [defaults to %d].",
sweep_count);
option = og_acquisition->add_option("--sweep-count", sweep_count, optstr);
registerOption("sweep_count", option);
}
if(anglesPerSweepAsConfigurableArgument)
{
optstr = io::xprintf("Number of angles per single sweep [default is %d].", angles_per_sweep);
option = og_acquisition->add_option("--angles-per-sweep", angles_per_sweep, optstr)
->check(CLI::Range(1, 1000));
registerOption("angles_per_sweep", option);
}
}
#include "PROG/ArgumentsBasisSpecification.hpp"
using namespace CTL;
using namespace CTL::util;
void ArgumentsBasisSpecification::addBasisSpecificationGroup()
{
if(og_basis == nullptr)
{
og_basis = cliApp->add_option_group("Basis specification",
"Specification of the basis and its parameters.");
registerOptionGroup("basis", og_basis);
}
}
void ArgumentsBasisSpecification::addBasisTypeGroup()
{
addBasisSpecificationGroup();
if(og_basis_type == nullptr)
{
og_basis_type
= og_basis->add_option_group("Basis type", "Specification of the basis type.");
registerOptionGroup("basis_type", og_basis_type);
}
}
void ArgumentsBasisSpecification::addFourierBasisSpecificationGroup()
{
addBasisSpecificationGroup();
if(og_fourier_basis == nullptr)
{
og_fourier_basis = og_basis->add_option_group(
"Fourier basis specification",
"Parameters that apply to the specification of the Fourier basis.");
registerOptionGroup("fourier_basis", og_fourier_basis);
}
}
void ArgumentsBasisSpecification::addPolynomialBasisSpecificationGroup()
{
addBasisSpecificationGroup();
if(og_polynomial_basis == nullptr)
{
og_polynomial_basis = og_basis->add_option_group(
"Polynomial basis setting", "Select type of polynomials either Legendre or Chebyshev.");
registerOptionGroup("polynomial_basis", og_polynomial_basis);
}
}
void ArgumentsBasisSpecification::addEngineerBasisSpecificationGroup()
{
addBasisSpecificationGroup();
if(og_engineer_basis == nullptr)
{
og_engineer_basis = og_basis->add_option_group("Engineer basis setting",
"Select fitting type and possible shift.");
registerOptionGroup("engineer_basis", og_engineer_basis);
}
}
void ArgumentsBasisSpecification::addOutsideBasisSpecificationGroup()
{
addBasisSpecificationGroup();
if(og_outside_basis == nullptr)
{
og_outside_basis = og_basis->add_option_group(
"Outside basis values handling specification",
"Specify how to handle values outside basis support interval.");
registerOptionGroup("outside_basis", og_outside_basis);
}
}
void ArgumentsBasisSpecification::addBasisSpecificationArgs(bool includeBasisSize,
bool includeBasisSetSelectionArgs)
{
addBasisSpecificationGroup();
std::string optstr;
CLI::Option* option;
if(includeBasisSetSelectionArgs)
{
addBasisTypeGroup();
addFourierBasisSpecificationArgs();
option = og_basis_type->add_flag("--legendre", useLegendrePolynomials,
"Use Legendre polynomials.");
registerOption("legendre", option);
option
= og_basis_type->add_flag("--chebyshev", useChebyshevPolynomials, "Use Fourier basis.");
registerOption("chebyshev", option);
option = og_basis_type->add_flag("--fourier", useFourierBasis, "Use Fourier basis.");
registerOption("fourier", option);
getRegisteredOption("half_periodic_functions")->needs(option);
option = og_basis_type->add_option("--engineer", engineerBasis,
"Use basis that is stored in a DEN file.");
registerOption("engineer", option);
og_basis_type->require_option(1);
}
if(includeBasisSize)
{
option = og_basis
->add_option("--basis-size", basisSize,
io::xprintf("Size of the basis. Defaults to %d.", basisSize))
->check(CLI::Range(1, 65535));
registerOption("basis_size", option);
}
optstr = io::xprintf(
"From frame_time and pause_size is computed the scan time and time of "
"acquisition of particular frames. In reality time dynamics might apply after "
"some delay from the acquisition of the first frame due to the mask image or "
"contrast delay. This parameter controls the lenght of the time interval [ms] "
"from the start of the acquisition to the time when the basis functions are "
"used to estimate dynamics. Before this time basis functions are considered "
"having the same value as at the beggining of their support [defaults to %.1f].",
start_offset);
option = og_basis->add_option("-i,--start-offset", start_offset, optstr)
->check(CLI::Range(0.0, 100000.0));
registerOption("start_offset", option);
optstr = io::xprintf(
"From frame_time and pause_size is computed the scan time and time of the "
"acquisition of particular frames. In reality we can assume that time dynamic "
"does not affect the beginning and the end of the acquisition. This parameter "
"controls the length of the time interval [ms] before the end of the "
"acquisition in which all basis functions are considered having the same value "
"as at the end of their support [defaults to %.1f].",
end_offset);
option = og_basis->add_option("-e,--end-offset", end_offset, optstr)
->check(CLI::Range(0.0, 100000.0));
registerOption("end_offset", option);
addOutsideBasisSpecificationGroup();
optstr
= io::xprintf("In the interval outside [start_offset, acquisition - end_offset] is still "
"performed the fitting when the parameter is false, when the parameter is "
"true, data outside of this interval is not used at all [defaults to %s].",
removeOutsideInterval ? "true" : "false");
option = og_outside_basis->add_flag("--remove-outside-interval", removeOutsideInterval, optstr);
registerOption("remove_outside_interval", option);
optstr = io::xprintf("Data outside interval are fitted on the first function endinterval, "
"other functions zero [defaults to %s].",
constantOutsideInterval ? "true" : "false");
option = og_outside_basis->add_flag("--constant-outside-interval", constantOutsideInterval,
optstr);
registerOption("constant_outside_interval", option);
optstr = io::xprintf(
"Extended endvalues of the basis functions outside interval [defaults to %s].",
endvalueOutsideInterval ? "true" : "false");
option = og_outside_basis->add_flag("--endvalue-outside-interval", endvalueOutsideInterval,
optstr);
registerOption("endvalue_outside_interval", option);
og_outside_basis->require_option(1);
}
void ArgumentsBasisSpecification::addFourierBasisSpecificationArgs()
{
addFourierBasisSpecificationGroup();
std::string optstr;
CLI::Option* option;
optstr = io::xprintf("Use Fourier basis and include half periodic functions [defaults to");
if(halfPeriodicFunctions)
{
optstr = optstr + " true].";
} else
{
optstr = optstr + " false].";
}
option = og_fourier_basis->add_flag("--half-periodic-functions", halfPeriodicFunctions, optstr);
registerOption("half_periodic_functions", option);
}
void ArgumentsBasisSpecification::addPolynomialBasisSpecificationArgs()
{
addPolynomialBasisSpecificationGroup();
og_polynomial_basis->add_flag("--chebyshev", useChebyshevPolynomials,
"Use Chebyshev polynomials.");
og_polynomial_basis->add_flag("--legendre", useLegendrePolynomials,
"Use Legendre polynomials.");
og_polynomial_basis->require_option(1);
}
void ArgumentsBasisSpecification::addEngineerBasisSpecificationArgs()
{
addEngineerBasisSpecificationGroup();
og_engineer_basis->add_flag("--spline-fit", fitSplinesToTheBasisBreakpoints,
"Fit splines instead of step functions.");
og_engineer_basis->add_option(
"--basis-time-shift", basisTimeShift,
"Time shift applied to the basis functions relative to the requested time of evaluation.");
}
Subproject commit 75b87d6df46b03edb39e11e7cb126df02d4aa5d6
Subproject commit 4def9045b8796d3fb3be5092aed2e8262acaafec
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