Skip to content

Commit

Permalink
help text updates and merge twins seed updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungbq committed Oct 18, 2023
1 parent dcc41d2 commit c3cdece
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Parameters AddBadDataFilter::parameters() const
params.insertSeparator(Parameters::Separator{"Seeded Randomness"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseSeed_Key, "Use Seed for Random Generation", "When true the user will be able to put in a seed for random generation", false));
params.insert(std::make_unique<NumberParameter<uint64>>(k_SeedValue_Key, "Seed", "The seed fed into the random generator", std::mt19937::default_seed));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "", "_Add_Bad_Data_Seed_Value_"));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_Add_Bad_Data_Seed_Value_"));

params.insertSeparator(Parameters::Separator{"Optional Variables"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_PoissonNoise_Key, "Add Random Noise", "If true the user may set the poisson volume fraction", false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Parameters FindFeatureClusteringFilter::parameters() const
params.insertLinkableParameter(
std::make_unique<BoolParameter>(k_SetRandomSeed_Key, "Set Random Seed", "When checked, allows the user to set the seed value used to randomly generate the points in the RDF", true));
params.insert(std::make_unique<UInt64Parameter>(k_SeedValue_Key, "Seed Value", "The seed value used to randomly generate the points in the RDF", std::mt19937::default_seed));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "", "_Find_Feature_Clustering_Seed_Value_"));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_Find_Feature_Clustering_Seed_Value_"));

params.insertSeparator(Parameters::Separator{"Cell Feature Data"});
params.insert(std::make_unique<ArraySelectionParameter>(k_EquivalentDiametersArrayPath_Key, "Equivalent Diameters", "Diameter of a sphere with the same volume as the Feature", DataPath{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Parameters KMeansFilter::parameters() const
params.insertSeparator(Parameters::Separator{"Seeded Randomness"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseSeed_Key, "Use Seed for Random Generation", "When true the user will be able to put in a seed for random generation", false));
params.insert(std::make_unique<NumberParameter<uint64>>(k_SeedValue_Key, "Seed", "The seed fed into the random generator", std::mt19937::default_seed));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "", "_K_Means_Seed_Value_"));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_K_Means_Seed_Value_"));

params.insertSeparator(Parameters::Separator{"Input Parameters"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseMask_Key, "Use Mask", "Specifies whether or not to use a mask array", false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Parameters KMedoidsFilter::parameters() const
params.insertSeparator(Parameters::Separator{"Seeded Randomness"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseSeed_Key, "Use Seed for Random Generation", "When true the user will be able to put in a seed for random generation", false));
params.insert(std::make_unique<NumberParameter<uint64>>(k_SeedValue_Key, "Seed", "The seed fed into the random generator", std::mt19937::default_seed));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "", "_K_Medoids_Seed_Value_"));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_K_Medoids_Seed_Value_"));

params.insertSeparator(Parameters::Separator{"Input Parameters"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseMask_Key, "Use Mask", "Specifies whether or not to use a mask array", false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Parameters UncertainRegularGridSampleSurfaceMeshFilter::parameters() const
params.insertSeparator(Parameters::Separator{"Seeded Randomness"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseSeed_Key, "Use Seed for Random Generation", "When true the user will be able to put in a seed for random generation", false));
params.insert(std::make_unique<NumberParameter<uint64>>(k_SeedValue_Key, "Seed", "The seed fed into the random generator", std::mt19937::default_seed));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "", "_Uncertain_Regular_Grid_Sample_Surface_Mesh_Seed_Value_"));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_Uncertain_Regular_Grid_Sample_Surface_Mesh_Seed_Value_"));

Check warning on line 62 in src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

[clang-format] reported by reviewdog 🐶 Raw Output: src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp:62:- params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_Uncertain_Regular_Grid_Sample_Surface_Mesh_Seed_Value_")); src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp:62:+ params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp:63:+ "_Uncertain_Regular_Grid_Sample_Surface_Mesh_Seed_Value_"));

Check failure on line 62 in src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]

params.insertSeparator(Parameters::Separator{"Input Parameters"});
params.insert(std::make_unique<VectorUInt64Parameter>(k_Dimensions_Key, "Number of Cells per Axis", "The dimensions of the created Image geometry", std::vector<uint64>{128, 128, 128},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "EbsdLib/Core/Quaternion.hpp"
#include "EbsdLib/LaueOps/LaueOps.h"

#include <chrono>
#include <random>

using namespace complex;
Expand Down Expand Up @@ -54,7 +53,7 @@ int MergeTwins::getSeed(int32 newFid)
double rangeMax = 1;
std::random_device randomDevice; // Will be used to obtain a seed for the random number engine
std::mt19937_64 generator(randomDevice()); // Standard mersenne_twister_engine seeded with rd()
generator.seed(static_cast<std::mt19937_64::result_type>(std::chrono::steady_clock::now().time_since_epoch().count()));
generator.seed(m_InputValues->Seed);
std::uniform_real_distribution<> distribution(rangeMin, rangeMax);
randfeature = int32(float(distribution(generator)) * float(totalFMinus1));
while(seed == -1 && counter < numfeatures)
Expand Down Expand Up @@ -181,8 +180,7 @@ Result<> MergeTwins::operator()()
// Generate all the numbers up front
const int32 rangeMin = 1;
const int32 rangeMax = numParents - 1;
std::mt19937_64::result_type seed = static_cast<std::mt19937_64::result_type>(std::chrono::steady_clock::now().time_since_epoch().count());
std::mt19937_64 generator(seed); // Standard mersenne_twister_engine seeded with milliseconds
std::mt19937_64 generator(m_InputValues->Seed); // Standard mersenne_twister_engine seeded with milliseconds
std::uniform_int_distribution<int32_t> distribution(rangeMin, rangeMax);

size_t nParents = static_cast<size_t>(numParents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct ORIENTATIONANALYSIS_EXPORT MergeTwinsInputValues
DataPath FeatureParentIdsArrayName;
DataPath ActiveArrayName;
bool RandomizeParentIds = true;
uint64 Seed;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "complex/Parameters/NeighborListSelectionParameter.hpp"
#include "complex/Parameters/NumberParameter.hpp"

#include <random>

using namespace complex;

namespace complex
Expand Down Expand Up @@ -53,8 +55,12 @@ Parameters MergeTwinsFilter::parameters() const
Parameters params;

// Create the parameter descriptors that are needed for this filter
params.insertSeparator(Parameters::Separator{"Input Parameters"});
params.insertSeparator(Parameters::Separator{"Seeded Randomness"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseSeed_Key, "Use Seed for Random Generation", "When true the user will be able to put in a seed for random generation", false));
params.insert(std::make_unique<NumberParameter<uint64>>(k_SeedValue_Key, "Seed", "The seed fed into the random generator", std::mt19937::default_seed));
params.insert(std::make_unique<DataObjectNameParameter>(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "_Merge_Twins_Seed_Value_"));

params.insertSeparator(Parameters::Separator{"Input Parameters"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseNonContiguousNeighbors_Key, "Use Non-Contiguous Neighbors",
"Whether to use a list of non-contiguous or contiguous neighbors for each feature when merging", false));

Expand Down Expand Up @@ -123,6 +129,7 @@ IFilter::PreflightResult MergeTwinsFilter::preflightImpl(const DataStructure& da
auto pNewCellFeatureAttributeMatrixNameValue = cellFeatureDataPath.getParent().createChildPath(filterArgs.value<std::string>(k_NewCellFeatureAttributeMatrixName_Key));
auto pFeatureParentIdsArrayNameValue = cellFeatureDataPath.createChildPath(filterArgs.value<std::string>(k_FeatureParentIdsArrayName_Key));
auto pActiveArrayNameValue = pNewCellFeatureAttributeMatrixNameValue.createChildPath(filterArgs.value<std::string>(k_ActiveArrayName_Key));
auto pSeedArrayNameValue = filterArgs.value<std::string>(k_SeedArrayName_Key);

PreflightResult preflightResult;
complex::Result<OutputActions> resultOutputActions;
Expand Down Expand Up @@ -192,13 +199,27 @@ IFilter::PreflightResult MergeTwinsFilter::preflightImpl(const DataStructure& da

dataStructure.validateNumberOfTuples(dataArrayPaths);

{
auto createAction = std::make_unique<CreateArrayAction>(DataType::uint64, std::vector<usize>{1}, std::vector<usize>{1}, DataPath({pSeedArrayNameValue}));
resultOutputActions.value().appendAction(std::move(createAction));
}

return {std::move(resultOutputActions), std::move(preflightUpdatedValues)};
}

//------------------------------------------------------------------------------
Result<> MergeTwinsFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto seed = filterArgs.value<std::mt19937_64::result_type>(k_SeedValue_Key);
if(!filterArgs.value<bool>(k_UseSeed_Key))
{
seed = static_cast<std::mt19937_64::result_type>(std::chrono::steady_clock::now().time_since_epoch().count());
}

// Store Seed Value in Top Level Array
dataStructure.getDataRefAs<UInt64Array>(DataPath({filterArgs.value<std::string>(k_SeedArrayName_Key)}))[0] = seed;

MergeTwinsInputValues inputValues;
GroupFeaturesInputValues groupInputValues;

Expand All @@ -216,6 +237,7 @@ Result<> MergeTwinsFilter::executeImpl(DataStructure& dataStructure, const Argum
inputValues.NewCellFeatureAttributeMatrixName = cellFeatureDataPath.getParent().createChildPath(filterArgs.value<std::string>(k_NewCellFeatureAttributeMatrixName_Key));
inputValues.FeatureParentIdsArrayName = cellFeatureDataPath.createChildPath(filterArgs.value<std::string>(k_FeatureParentIdsArrayName_Key));
inputValues.ActiveArrayName = inputValues.NewCellFeatureAttributeMatrixName.createChildPath(filterArgs.value<std::string>(k_ActiveArrayName_Key));
inputValues.Seed = seed;

return MergeTwins(dataStructure, messageHandler, shouldCancel, &inputValues, &groupInputValues)();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ORIENTATIONANALYSIS_EXPORT MergeTwinsFilter : public IFilter
static inline constexpr StringLiteral k_NewCellFeatureAttributeMatrixName_Key = "new_cell_feature_attribute_matrix_name";
static inline constexpr StringLiteral k_FeatureParentIdsArrayName_Key = "feature_parent_ids_array_name";
static inline constexpr StringLiteral k_ActiveArrayName_Key = "active_array_name";
static inline constexpr StringLiteral k_UseSeed_Key = "use_seed";
static inline constexpr StringLiteral k_SeedValue_Key = "seed_value";
static inline constexpr StringLiteral k_SeedArrayName_Key = "seed_array_name";

/**
* @brief Returns the name of the filter.
Expand Down

0 comments on commit c3cdece

Please sign in to comment.