Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,11 @@
"value": "DataContainer",
"version": 1
},
"nearest_neighbors_array_name": {
"value": "NearestNeighbors",
"version": 1
},
"parameters_version": 1,
"q_pdistances_array_name": {
"value": "QPManhattanDistances",
"version": 1
},
"save_nearest_neighbors": {
"value": false,
"version": 1
},
"t_jdistances_array_name": {
"value": "TJManhattanDistances",
"version": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,19 +823,11 @@
"value": "fw-ar-IF1-aptr12-corr",
"version": 1
},
"nearest_neighbors_array_name": {
"value": "NearestNeighbors",
"version": 1
},
"parameters_version": 1,
"q_pdistances_array_name": {
"value": "QPManhattanDistances",
"version": 1
},
"save_nearest_neighbors": {
"value": false,
"version": 1
},
"t_jdistances_array_name": {
"value": "TJManhattanDistances",
"version": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,19 +823,11 @@
"value": "fw-ar-IF1-avtr12-corr",
"version": 1
},
"nearest_neighbors_array_name": {
"value": "NearestNeighbors",
"version": 1
},
"parameters_version": 1,
"q_pdistances_array_name": {
"value": "QPManhattanDistances",
"version": 1
},
"save_nearest_neighbors": {
"value": false,
"version": 1
},
"t_jdistances_array_name": {
"value": "TJManhattanDistances",
"version": 1
Expand Down
8 changes: 4 additions & 4 deletions src/Plugins/SimplnxCore/docs/ComputeEuclideanDistMapFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ This **Filter** calculates the distance of each **Cell** from the nearest **Feat
3. For each of the three *EuclideanDistace* maps, iteratively "grow" out from the **Cells** identified to have a distance of *0* by the following sub-steps:

- Determine the **Cells** that neighbor a **Cell** of distance *0* in the current map.
- Assign a distance of *1* to those **Cells** and list the *0* **Cell** neighbor as their *nearest neighbor*
- Repeat previous two sub-steps, increasing the distances by *1* each iteration, until no **Cells** remain without a distance and *nearest neighbor* assigned.
- Assign a distance of *1* to those **Cells** and track the *0* **Cell** neighbor internally as their *nearest neighbor*
- Repeat previous two sub-steps, increasing the distances by *1* each iteration, until no **Cells** remain without a distance assigned.

*Note:* the distances calculated at this point are "city-block" distances and not "shortest distance" distances.
*Note:* the distances calculated at this point are "city-block" distances and not "shortest distance" distances. The nearest neighbor information is used internally by the algorithm but is not saved as an output array.

4. If the option *Calculate Manhattan Distance* is *false*, then the "city-block" distances are overwritten with the *Euclidean Distance* from the **Cell** to its *nearest neighbor* **Cell** and stored in a *float* array instead of an *integer* array.
4. If the option *Calculate Manhattan Distance* is *false*, then the "city-block" distances are overwritten with the *Euclidean Distance* from the **Cell** to its internally tracked *nearest neighbor* **Cell** and stored in a *float* array instead of an *integer* array.

% Auto generated parameter table will be inserted here

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ struct SIMPLNXCORE_EXPORT ComputeEuclideanDistMapInputValues
bool DoBoundaries;
bool DoTripleLines;
bool DoQuadPoints;
bool SaveNearestNeighbors;
DataPath FeatureIdsArrayPath;
DataPath GBDistancesArrayName;
DataPath TJDistancesArrayName;
DataPath QPDistancesArrayName;
DataPath NearestNeighborsArrayName;
DataPath GBDistancesArrayPath;
DataPath TJDistancesArrayPath;
DataPath QPDistancesArrayPath;
DataPath InputImageGeometry;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Parameters ComputeEuclideanDistMapFilter::parameters() const
std::make_unique<BoolParameter>(k_DoTripleLines_Key, "Calculate Distance to Triple Lines", "Whether the distance of each Cell to a triple line between Features is calculated", true));
params.insertLinkableParameter(
std::make_unique<BoolParameter>(k_DoQuadPoints_Key, "Calculate Distance to Quadruple Points", "Whether the distance of each Cell to a quadruple point between Features is calculated", true));
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_SaveNearestNeighbors_Key, "Store the Nearest Boundary Cells", "Whether to store the nearest neighbors of Cell", false));

params.insertSeparator(Parameters::Separator{"Input Cell Data"});
params.insert(std::make_unique<GeometrySelectionParameter>(k_SelectedImageGeometryPath_Key, "Selected Image Geometry", "The target geometry", DataPath{},
Expand All @@ -79,15 +78,11 @@ Parameters ComputeEuclideanDistMapFilter::parameters() const
"The name of the array with the distance the cells are from a triple junction of Features.", "TJManhattanDistances"));
params.insert(std::make_unique<DataObjectNameParameter>(k_QPDistancesArrayName_Key, "Quadruple Point Distances",
"The name of the array with the distance the cells are from a quadruple point of Features.", "QPManhattanDistances"));
params.insert(std::make_unique<DataObjectNameParameter>(k_NearestNeighborsArrayName_Key, "Nearest Boundary Cells",
"The name of the array with the indices of the closest cell that touches a boundary, triple and quadruple point for each cell.",
"NearestNeighbors"));

// Associate the Linkable Parameter(s) to the children parameters that they control
params.linkParameters(k_DoBoundaries_Key, k_GBDistancesArrayName_Key, std::make_any<bool>(true));
params.linkParameters(k_DoTripleLines_Key, k_TJDistancesArrayName_Key, std::make_any<bool>(true));
params.linkParameters(k_DoQuadPoints_Key, k_QPDistancesArrayName_Key, std::make_any<bool>(true));
params.linkParameters(k_SaveNearestNeighbors_Key, k_NearestNeighborsArrayName_Key, std::make_any<bool>(true));

return params;
}
Expand All @@ -109,18 +104,13 @@ IFilter::PreflightResult ComputeEuclideanDistMapFilter::preflightImpl(const Data
const std::atomic_bool& shouldCancel, const ExecutionContext& executionContext) const
{
auto pCalcManhattanDistValue = filterArgs.value<bool>(k_CalcManhattanDist_Key);
auto pSaveNearestNeighborsValue = filterArgs.value<bool>(k_SaveNearestNeighbors_Key);
auto pCalculateDistToBoundaries = filterArgs.value<bool>(k_DoBoundaries_Key);
auto pCalculateDistToTripleLines = filterArgs.value<bool>(k_DoTripleLines_Key);
auto pCalculateDistToQuadPoints = filterArgs.value<bool>(k_DoQuadPoints_Key);

auto pFeatureIdsArrayPathValue = filterArgs.value<DataPath>(k_CellFeatureIdsArrayPath_Key);
DataPath parentGroup = pFeatureIdsArrayPathValue.getParent();

// Interesting thing about this parameter: The Default VALUE must be at the root level of the Data Structure. This is because the
// user may not actually want to keep that created array in which case we then try to delete the array. The DeleteDataAction
// will fail in preflight because the Array was never actually created at its default location and so if fails. If the user
// does in fact want to keep this array, then the user would have actually set the DataPaths to something that will actually get created.
auto pNearestNeighborsArrayNameValue = filterArgs.value<std::string>(k_NearestNeighborsArrayName_Key);
DataPath pNearestNeighborsArrayPath = pSaveNearestNeighborsValue ? parentGroup.createChildPath(pNearestNeighborsArrayNameValue) : DataPath::FromString(pNearestNeighborsArrayNameValue).value();

PreflightResult preflightResult;

nx::core::Result<OutputActions> resultOutputActions;
Expand All @@ -139,36 +129,35 @@ IFilter::PreflightResult ComputeEuclideanDistMapFilter::preflightImpl(const Data
outputDataType = DataType::float32;
}

if(!pCalculateDistToBoundaries && !pCalculateDistToTripleLines && !pCalculateDistToQuadPoints)
{
return {MakeErrorResult<OutputActions>(
-12802, fmt::format("There is no output. One of the following options must be selected: Calculate Distance To Boundaries, Calculate Distance to Triple Lines, or Calculate "
"Distance to Quadruple Points.",
pFeatureIdsArrayPathValue.toString()))};
}

// Create the GBDistancesArray
if(pCalculateDistToBoundaries)
{
auto arrayPath = parentGroup.createChildPath(filterArgs.value<std::string>(k_GBDistancesArrayName_Key));
auto action = std::make_unique<CreateArrayAction>(outputDataType, tupleShape, std::vector<usize>{1ULL}, arrayPath);
resultOutputActions.value().appendAction(std::move(action));
}
// Create the TJDistancesArray
if(pCalculateDistToTripleLines)
{
auto arrayPath = parentGroup.createChildPath(filterArgs.value<std::string>(k_TJDistancesArrayName_Key));
auto action = std::make_unique<CreateArrayAction>(outputDataType, tupleShape, std::vector<usize>{1ULL}, arrayPath);
resultOutputActions.value().appendAction(std::move(action));
}
// Create the QPDistancesArray
if(pCalculateDistToQuadPoints)
{
auto arrayPath = parentGroup.createChildPath(filterArgs.value<std::string>(k_QPDistancesArrayName_Key));
auto action = std::make_unique<CreateArrayAction>(outputDataType, tupleShape, std::vector<usize>{1ULL}, arrayPath);
resultOutputActions.value().appendAction(std::move(action));
}
// Create the NearestNeighborsArray
{
auto action = std::make_unique<CreateArrayAction>(DataType::int32, tupleShape, std::vector<usize>{3ULL}, pNearestNeighborsArrayPath);
resultOutputActions.value().appendAction(std::move(action));
}

// If we are NOT saving the nearest neighbors then we need to delete this array that gets created.
if(!pSaveNearestNeighborsValue)
{
auto action = std::make_unique<DeleteDataAction>(pNearestNeighborsArrayPath, DeleteDataAction::DeleteType::JustObject);
resultOutputActions.value().appendDeferredAction(std::move(action));
}

std::vector<PreflightValue> preflightUpdatedValues;

Expand All @@ -186,14 +175,11 @@ Result<> ComputeEuclideanDistMapFilter::executeImpl(DataStructure& dataStructure
inputValues.DoBoundaries = filterArgs.value<bool>(k_DoBoundaries_Key);
inputValues.DoTripleLines = filterArgs.value<bool>(k_DoTripleLines_Key);
inputValues.DoQuadPoints = filterArgs.value<bool>(k_DoQuadPoints_Key);
inputValues.SaveNearestNeighbors = filterArgs.value<bool>(k_SaveNearestNeighbors_Key);
inputValues.FeatureIdsArrayPath = filterArgs.value<DataPath>(k_CellFeatureIdsArrayPath_Key);
DataPath parentGroupPath = inputValues.FeatureIdsArrayPath.getParent();
inputValues.GBDistancesArrayName = parentGroupPath.createChildPath(filterArgs.value<std::string>(k_GBDistancesArrayName_Key));
inputValues.TJDistancesArrayName = parentGroupPath.createChildPath(filterArgs.value<std::string>(k_TJDistancesArrayName_Key));
inputValues.QPDistancesArrayName = parentGroupPath.createChildPath(filterArgs.value<std::string>(k_QPDistancesArrayName_Key));
auto nearestNeighborName = filterArgs.value<std::string>(k_NearestNeighborsArrayName_Key);
inputValues.NearestNeighborsArrayName = inputValues.SaveNearestNeighbors ? parentGroupPath.createChildPath(nearestNeighborName) : DataPath::FromString(nearestNeighborName).value();
inputValues.GBDistancesArrayPath = parentGroupPath.createChildPath(filterArgs.value<std::string>(k_GBDistancesArrayName_Key));
inputValues.TJDistancesArrayPath = parentGroupPath.createChildPath(filterArgs.value<std::string>(k_TJDistancesArrayName_Key));
inputValues.QPDistancesArrayPath = parentGroupPath.createChildPath(filterArgs.value<std::string>(k_QPDistancesArrayName_Key));
inputValues.InputImageGeometry = filterArgs.value<DataPath>(k_SelectedImageGeometryPath_Key);

return ComputeEuclideanDistMap(dataStructure, messageHandler, shouldCancel, &inputValues)();
Expand All @@ -207,12 +193,10 @@ constexpr StringLiteral k_CalcManhattanDistKey = "CalcManhattanDist";
constexpr StringLiteral k_DoBoundariesKey = "DoBoundaries";
constexpr StringLiteral k_DoTripleLinesKey = "DoTripleLines";
constexpr StringLiteral k_DoQuadPointsKey = "DoQuadPoints";
constexpr StringLiteral k_SaveNearestNeighborsKey = "SaveNearestNeighbors";
constexpr StringLiteral k_FeatureIdsArrayPathKey = "FeatureIdsArrayPath";
constexpr StringLiteral k_GBDistancesArrayNameKey = "GBDistancesArrayName";
constexpr StringLiteral k_TJDistancesArrayNameKey = "TJDistancesArrayName";
constexpr StringLiteral k_QPDistancesArrayNameKey = "QPDistancesArrayName";
constexpr StringLiteral k_NearestNeighborsArrayNameKey = "NearestNeighborsArrayName";
} // namespace SIMPL
} // namespace

Expand All @@ -226,14 +210,12 @@ Result<Arguments> ComputeEuclideanDistMapFilter::FromSIMPLJson(const nlohmann::j
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::BooleanFilterParameterConverter>(args, json, SIMPL::k_DoBoundariesKey, k_DoBoundaries_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::BooleanFilterParameterConverter>(args, json, SIMPL::k_DoTripleLinesKey, k_DoTripleLines_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::BooleanFilterParameterConverter>(args, json, SIMPL::k_DoQuadPointsKey, k_DoQuadPoints_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::BooleanFilterParameterConverter>(args, json, SIMPL::k_SaveNearestNeighborsKey, k_SaveNearestNeighbors_Key));
results.push_back(
SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionToGeometrySelectionFilterParameterConverter>(args, json, SIMPL::k_FeatureIdsArrayPathKey, k_SelectedImageGeometryPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_FeatureIdsArrayPathKey, k_CellFeatureIdsArrayPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::LinkedPathCreationFilterParameterConverter>(args, json, SIMPL::k_GBDistancesArrayNameKey, k_GBDistancesArrayName_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::LinkedPathCreationFilterParameterConverter>(args, json, SIMPL::k_TJDistancesArrayNameKey, k_TJDistancesArrayName_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::LinkedPathCreationFilterParameterConverter>(args, json, SIMPL::k_QPDistancesArrayNameKey, k_QPDistancesArrayName_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::LinkedPathCreationFilterParameterConverter>(args, json, SIMPL::k_NearestNeighborsArrayNameKey, k_NearestNeighborsArrayName_Key));

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ class SIMPLNXCORE_EXPORT ComputeEuclideanDistMapFilter : public IFilter
static constexpr StringLiteral k_DoBoundaries_Key = "do_boundaries";
static constexpr StringLiteral k_DoTripleLines_Key = "do_triple_lines";
static constexpr StringLiteral k_DoQuadPoints_Key = "do_quad_points";
static constexpr StringLiteral k_SaveNearestNeighbors_Key = "save_nearest_neighbors";
static constexpr StringLiteral k_CellFeatureIdsArrayPath_Key = "feature_ids_path";
static constexpr StringLiteral k_GBDistancesArrayName_Key = "g_bdistances_array_name";
static constexpr StringLiteral k_TJDistancesArrayName_Key = "t_jdistances_array_name";
static constexpr StringLiteral k_QPDistancesArrayName_Key = "q_pdistances_array_name";
static constexpr StringLiteral k_NearestNeighborsArrayName_Key = "nearest_neighbors_array_name";

/**
* @brief Reads SIMPL json and converts it simplnx Arguments.
Expand Down
Loading
Loading