Skip to content

Commit

Permalink
ENH: Refactor the Parameter Keys to make them consistent and easy to …
Browse files Browse the repository at this point in the history
…learn

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Mar 15, 2024
1 parent e9f0542 commit c73b711
Show file tree
Hide file tree
Showing 177 changed files with 1,218 additions and 1,200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ Parameters ITKAbsImage::parameters() const
Parameters params;

params.insertSeparator(Parameters::Separator{"Required Input Cell Data"});
params.insert(std::make_unique<GeometrySelectionParameter>(k_SelectedImageGeomPath_Key, "Image Geometry", "Select the Image Geometry Group from the DataStructure.", DataPath({"Image Geometry"}),
params.insert(std::make_unique<GeometrySelectionParameter>(k_InputImageGeomPath_Key, "Image Geometry", "Select the Image Geometry Group from the DataStructure.", DataPath({"Image Geometry"}),
GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Image}));
params.insert(std::make_unique<ArraySelectionParameter>(k_SelectedImageDataPath_Key, "Input Image Data Array", "The image data that will be processed by this filter.", DataPath{},
params.insert(std::make_unique<ArraySelectionParameter>(k_InputImageDataPath_Key, "Input Image Data Array", "The image data that will be processed by this filter.", DataPath{},
nx::core::ITK::GetScalarPixelAllowedTypes()));

params.insertSeparator(Parameters::Separator{"Created Cell Data"});
params.insert(
std::make_unique<DataObjectNameParameter>(k_OutputImageDataPath_Key, "Output Image Data Array", "The result of the processing will be stored in this Data Array.", "Output Image Data"));
params.insert(std::make_unique<DataObjectNameParameter>(k_OutputImageArrayName_Key, "Output Image Array Name",
"The result of the processing will be stored in this Data Array inside the same group as the input data.", "Output Image Data"));

return params;
}
Expand All @@ -89,9 +89,9 @@ IFilter::UniquePointer ITKAbsImage::clone() const
//------------------------------------------------------------------------------
IFilter::PreflightResult ITKAbsImage::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const
{
auto imageGeomPath = filterArgs.value<DataPath>(k_SelectedImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_SelectedImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageDataPath_Key);
auto imageGeomPath = filterArgs.value<DataPath>(k_InputImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_InputImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageArrayName_Key);
const DataPath outputArrayPath = selectedInputArray.getParent().createChildPath(outputArrayName);

Result<OutputActions> resultOutputActions = ITK::DataCheck<cxITKAbsImage::ArrayOptionsType>(dataStructure, selectedInputArray, imageGeomPath, outputArrayPath);
Expand All @@ -103,9 +103,9 @@ IFilter::PreflightResult ITKAbsImage::preflightImpl(const DataStructure& dataStr
Result<> ITKAbsImage::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto imageGeomPath = filterArgs.value<DataPath>(k_SelectedImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_SelectedImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageDataPath_Key);
auto imageGeomPath = filterArgs.value<DataPath>(k_InputImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_InputImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageArrayName_Key);
const DataPath outputArrayPath = selectedInputArray.getParent().createChildPath(outputArrayName);

const cxITKAbsImage::ITKAbsImageFunctor itkFunctor = {};
Expand All @@ -131,9 +131,9 @@ Result<Arguments> ITKAbsImage::FromSIMPLJson(const nlohmann::json& json)

std::vector<Result<>> results;

results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataContainerSelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_SelectedImageGeomPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_SelectedImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::StringFilterParameterConverter>(args, json, SIMPL::k_NewCellArrayNameKey, k_OutputImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataContainerSelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_InputImageGeomPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_InputImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::StringFilterParameterConverter>(args, json, SIMPL::k_NewCellArrayNameKey, k_OutputImageArrayName_Key));

Result<> conversionResult = MergeResults(std::move(results));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class ITKIMAGEPROCESSING_EXPORT ITKAbsImage : public IFilter
ITKAbsImage& operator=(ITKAbsImage&&) noexcept = delete;

// Parameter Keys
static inline constexpr StringLiteral k_SelectedImageGeomPath_Key = "selected_image_geom_path";
static inline constexpr StringLiteral k_SelectedImageDataPath_Key = "input_image_data_path";
static inline constexpr StringLiteral k_OutputImageDataPath_Key = "output_image_data_path";
static inline constexpr StringLiteral k_InputImageGeomPath_Key = "input_image_geom_path";
static inline constexpr StringLiteral k_InputImageDataPath_Key = "input_image_data_path";
static inline constexpr StringLiteral k_OutputImageArrayName_Key = "output_array_name";

/**
* @brief Reads SIMPL json and converts it simplnx Arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ Parameters ITKAcosImage::parameters() const
Parameters params;

params.insertSeparator(Parameters::Separator{"Required Input Cell Data"});
params.insert(std::make_unique<GeometrySelectionParameter>(k_SelectedImageGeomPath_Key, "Image Geometry", "Select the Image Geometry Group from the DataStructure.", DataPath({"Image Geometry"}),
params.insert(std::make_unique<GeometrySelectionParameter>(k_InputImageGeomPath_Key, "Image Geometry", "Select the Image Geometry Group from the DataStructure.", DataPath({"Image Geometry"}),
GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Image}));
params.insert(std::make_unique<ArraySelectionParameter>(k_SelectedImageDataPath_Key, "Input Image Data Array", "The image data that will be processed by this filter.", DataPath{},
params.insert(std::make_unique<ArraySelectionParameter>(k_InputImageDataPath_Key, "Input Image Data Array", "The image data that will be processed by this filter.", DataPath{},
nx::core::ITK::GetScalarPixelAllowedTypes()));

params.insertSeparator(Parameters::Separator{"Created Cell Data"});
params.insert(
std::make_unique<DataObjectNameParameter>(k_OutputImageDataPath_Key, "Output Image Data Array", "The result of the processing will be stored in this Data Array.", "Output Image Data"));
params.insert(std::make_unique<DataObjectNameParameter>(k_OutputImageArrayName_Key, "Output Image Array Name",
"The result of the processing will be stored in this Data Array inside the same group as the input data.", "Output Image Data"));

return params;
}
Expand All @@ -89,9 +89,9 @@ IFilter::UniquePointer ITKAcosImage::clone() const
//------------------------------------------------------------------------------
IFilter::PreflightResult ITKAcosImage::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const
{
auto imageGeomPath = filterArgs.value<DataPath>(k_SelectedImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_SelectedImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageDataPath_Key);
auto imageGeomPath = filterArgs.value<DataPath>(k_InputImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_InputImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageArrayName_Key);
const DataPath outputArrayPath = selectedInputArray.getParent().createChildPath(outputArrayName);

Result<OutputActions> resultOutputActions = ITK::DataCheck<cxITKAcosImage::ArrayOptionsType>(dataStructure, selectedInputArray, imageGeomPath, outputArrayPath);
Expand All @@ -103,9 +103,9 @@ IFilter::PreflightResult ITKAcosImage::preflightImpl(const DataStructure& dataSt
Result<> ITKAcosImage::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto imageGeomPath = filterArgs.value<DataPath>(k_SelectedImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_SelectedImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageDataPath_Key);
auto imageGeomPath = filterArgs.value<DataPath>(k_InputImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_InputImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageArrayName_Key);
const DataPath outputArrayPath = selectedInputArray.getParent().createChildPath(outputArrayName);

const cxITKAcosImage::ITKAcosImageFunctor itkFunctor = {};
Expand All @@ -131,9 +131,9 @@ Result<Arguments> ITKAcosImage::FromSIMPLJson(const nlohmann::json& json)

std::vector<Result<>> results;

results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataContainerSelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_SelectedImageGeomPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_SelectedImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::StringFilterParameterConverter>(args, json, SIMPL::k_NewCellArrayNameKey, k_OutputImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataContainerSelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_InputImageGeomPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_InputImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::StringFilterParameterConverter>(args, json, SIMPL::k_NewCellArrayNameKey, k_OutputImageArrayName_Key));

Result<> conversionResult = MergeResults(std::move(results));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class ITKIMAGEPROCESSING_EXPORT ITKAcosImage : public IFilter
ITKAcosImage& operator=(ITKAcosImage&&) noexcept = delete;

// Parameter Keys
static inline constexpr StringLiteral k_SelectedImageGeomPath_Key = "selected_image_geom_path";
static inline constexpr StringLiteral k_SelectedImageDataPath_Key = "input_image_data_path";
static inline constexpr StringLiteral k_OutputImageDataPath_Key = "output_image_data_path";
static inline constexpr StringLiteral k_InputImageGeomPath_Key = "input_image_geom_path";
static inline constexpr StringLiteral k_InputImageDataPath_Key = "input_image_data_path";
static inline constexpr StringLiteral k_OutputImageArrayName_Key = "output_array_name";

/**
* @brief Reads SIMPL json and converts it simplnx Arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ Parameters ITKAdaptiveHistogramEqualizationImage::parameters() const
"Set/Get the value of beta. If beta = 1 (and alpha = 1), then the output image matches the input image. As beta approaches 0, the filter behaves as an unsharp mask. Default is 0.3.", 0.3f));

params.insertSeparator(Parameters::Separator{"Required Input Cell Data"});
params.insert(std::make_unique<GeometrySelectionParameter>(k_SelectedImageGeomPath_Key, "Image Geometry", "Select the Image Geometry Group from the DataStructure.", DataPath({"Image Geometry"}),
params.insert(std::make_unique<GeometrySelectionParameter>(k_InputImageGeomPath_Key, "Image Geometry", "Select the Image Geometry Group from the DataStructure.", DataPath({"Image Geometry"}),
GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Image}));
params.insert(std::make_unique<ArraySelectionParameter>(k_SelectedImageDataPath_Key, "Input Image Data Array", "The image data that will be processed by this filter.", DataPath{},
params.insert(std::make_unique<ArraySelectionParameter>(k_InputImageDataPath_Key, "Input Image Data Array", "The image data that will be processed by this filter.", DataPath{},
nx::core::ITK::GetScalarPixelAllowedTypes()));

params.insertSeparator(Parameters::Separator{"Created Cell Data"});
params.insert(
std::make_unique<DataObjectNameParameter>(k_OutputImageDataPath_Key, "Output Image Data Array", "The result of the processing will be stored in this Data Array.", "Output Image Data"));
params.insert(std::make_unique<DataObjectNameParameter>(k_OutputImageArrayName_Key, "Output Image Array Name",
"The result of the processing will be stored in this Data Array inside the same group as the input data.", "Output Image Data"));

return params;
}
Expand All @@ -113,9 +113,9 @@ IFilter::UniquePointer ITKAdaptiveHistogramEqualizationImage::clone() const
IFilter::PreflightResult ITKAdaptiveHistogramEqualizationImage::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto imageGeomPath = filterArgs.value<DataPath>(k_SelectedImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_SelectedImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageDataPath_Key);
auto imageGeomPath = filterArgs.value<DataPath>(k_InputImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_InputImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageArrayName_Key);
auto radius = filterArgs.value<VectorUInt32Parameter::ValueType>(k_Radius_Key);

auto alpha = filterArgs.value<float32>(k_Alpha_Key);
Expand All @@ -131,9 +131,9 @@ IFilter::PreflightResult ITKAdaptiveHistogramEqualizationImage::preflightImpl(co
Result<> ITKAdaptiveHistogramEqualizationImage::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto imageGeomPath = filterArgs.value<DataPath>(k_SelectedImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_SelectedImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageDataPath_Key);
auto imageGeomPath = filterArgs.value<DataPath>(k_InputImageGeomPath_Key);
auto selectedInputArray = filterArgs.value<DataPath>(k_InputImageDataPath_Key);
auto outputArrayName = filterArgs.value<DataObjectNameParameter::ValueType>(k_OutputImageArrayName_Key);
const DataPath outputArrayPath = selectedInputArray.getParent().createChildPath(outputArrayName);

auto radius = filterArgs.value<VectorUInt32Parameter::ValueType>(k_Radius_Key);
Expand Down Expand Up @@ -171,9 +171,9 @@ Result<Arguments> ITKAdaptiveHistogramEqualizationImage::FromSIMPLJson(const nlo
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::UInt32Vec3FilterParameterConverter>(args, json, SIMPL::k_RadiusKey, k_Radius_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::FloatFilterParameterConverter<float32>>(args, json, SIMPL::k_AlphaKey, k_Alpha_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::FloatFilterParameterConverter<float32>>(args, json, SIMPL::k_BetaKey, k_Beta_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataContainerSelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_SelectedImageGeomPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_SelectedImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::StringFilterParameterConverter>(args, json, SIMPL::k_NewCellArrayNameKey, k_OutputImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataContainerSelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_InputImageGeomPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedCellArrayPathKey, k_InputImageDataPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::StringFilterParameterConverter>(args, json, SIMPL::k_NewCellArrayNameKey, k_OutputImageArrayName_Key));

Result<> conversionResult = MergeResults(std::move(results));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class ITKIMAGEPROCESSING_EXPORT ITKAdaptiveHistogramEqualizationImage : public I
ITKAdaptiveHistogramEqualizationImage& operator=(ITKAdaptiveHistogramEqualizationImage&&) noexcept = delete;

// Parameter Keys
static inline constexpr StringLiteral k_SelectedImageGeomPath_Key = "selected_image_geom_path";
static inline constexpr StringLiteral k_SelectedImageDataPath_Key = "input_image_data_path";
static inline constexpr StringLiteral k_OutputImageDataPath_Key = "output_image_data_path";
static inline constexpr StringLiteral k_InputImageGeomPath_Key = "input_image_geom_path";
static inline constexpr StringLiteral k_InputImageDataPath_Key = "input_image_data_path";
static inline constexpr StringLiteral k_OutputImageArrayName_Key = "output_array_name";
static inline constexpr StringLiteral k_Radius_Key = "radius";
static inline constexpr StringLiteral k_Alpha_Key = "alpha";
static inline constexpr StringLiteral k_Beta_Key = "beta";
Expand Down
Loading

0 comments on commit c73b711

Please sign in to comment.