Skip to content

Commit 59dadac

Browse files
nyoungbqimikejackson
authored andcommitted
Oim patches and Oina intial filter [broken]
1 parent 8089b99 commit 59dadac

File tree

4 files changed

+121
-71
lines changed

4 files changed

+121
-71
lines changed

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OimDataFilter.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ Parameters ReadH5OimDataFilter::parameters() const
107107
//------------------------------------------------------------------------------
108108
IFilter::VersionType ReadH5OimDataFilter::parametersVersion() const
109109
{
110-
return 1;
110+
return 2;
111+
112+
// Version 1 -> 2
113+
// Change 1:
114+
// Added - k_CombineScans_Key = "combine_scans";
115+
// Solution - default parameter value 'true' preserves backwards functionality;
111116
}
112117

113118
//------------------------------------------------------------------------------
@@ -121,7 +126,7 @@ IFilter::PreflightResult ReadH5OimDataFilter::preflightImpl(const DataStructure&
121126
const std::atomic_bool& shouldCancel) const
122127
{
123128
auto pSelectedScanNamesValue = filterArgs.value<OEMEbsdScanSelectionParameter::ValueType>(k_SelectedScanNames_Key);
124-
auto pCombineScansValue = filterArgs.value<bool>(k_CombineScans_Key);
129+
auto pCombineScansValue = filterArgs.value<bool>(k_CombineScans_Key); // V2 Param
125130
auto pZSpacingValue = filterArgs.value<float32>(k_ZSpacing_Key);
126131
auto pOriginValue = filterArgs.value<VectorFloat32Parameter::ValueType>(k_Origin_Key);
127132
auto pReadPatternDataValue = filterArgs.value<bool>(k_ReadPatternData_Key);
@@ -135,16 +140,13 @@ IFilter::PreflightResult ReadH5OimDataFilter::preflightImpl(const DataStructure&
135140
nx::core::Result<OutputActions> resultOutputActions;
136141
std::vector<PreflightValue> preflightUpdatedValues;
137142

138-
if(pCombineScansValue)
143+
if(pZSpacingValue <= 0)
139144
{
140-
if(pZSpacingValue <= 0)
141-
{
142-
return MakePreflightErrorResult(-9580, "The Z Spacing field contains a value that is non-positive. The Z Spacing field must be set to a positive value.");
143-
}
144-
if(pSelectedScanNamesValue.scanNames.empty())
145-
{
146-
return MakePreflightErrorResult(-9581, "At least one scan must be chosen. Please select a scan from the list.");
147-
}
145+
return MakePreflightErrorResult(-9580, "The Z Spacing field contains a value that is non-positive. The Z Spacing field must be set to a positive value.");
146+
}
147+
if(pSelectedScanNamesValue.scanNames.empty())
148+
{
149+
return MakePreflightErrorResult(-9581, "At least one scan must be chosen. Please select a scan from the list.");
148150
}
149151

150152
// read in the necessary info from the input h5 file

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.cpp

Lines changed: 92 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,41 @@ Parameters ReadH5OinaDataFilter::parameters() const
6666
params.insert(std::make_unique<OEMEbsdScanSelectionParameter>(k_SelectedScanNames_Key, "Scan Names", "The name of the scan in the .h5oina file. Oxford can store multiple scans in a single file",
6767
OEMEbsdScanSelectionParameter::ValueType{}, OEMEbsdScanSelectionParameter::EbsdReaderType::H5Oina,
6868
OEMEbsdScanSelectionParameter::ExtensionsType{".h5oina"}));
69+
params.insertLinkableParameter(std::make_unique<BoolParameter>(
70+
k_CombineScans_Key, "Combine Scans", "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true));
6971
params.insert(std::make_unique<BoolParameter>(k_EdaxHexagonalAlignment_Key, "Convert Hexagonal X-Axis to EDAX Standard",
7072
"Whether or not to convert a Hexagonal phase to the EDAX standard for x-axis alignment", true));
7173
params.insert(std::make_unique<BoolParameter>(k_ConvertPhaseToInt32_Key, "Convert Phase Data to Int32", "Native Phases data value is uint8. Convert to Int32 for better filter compatibility", true));
7274
params.insert(std::make_unique<VectorFloat32Parameter>(k_Origin_Key, "Origin", "The origin of the volume", std::vector<float32>{0.0F, 0.0F, 0.0F}, std::vector<std::string>{"x", "y", "z"}));
7375
params.insert(std::make_unique<Float32Parameter>(k_ZSpacing_Key, "Z Spacing (Microns)", "The spacing in microns between each layer.", 1.0f));
7476
params.insert(std::make_unique<BoolParameter>(k_ReadPatternData_Key, "Import Pattern Data", "Whether or not to import the pattern data", false));
77+
7578
params.insertSeparator(Parameters::Separator{"Output Image Geometry"});
7679
params.insert(std::make_unique<DataGroupCreationParameter>(k_CreatedImageGeometryPath_Key, "Image Geometry", "The path to the created Image Geometry", DataPath({ImageGeom::k_TypeName})));
80+
7781
params.insertSeparator(Parameters::Separator{"Output Cell Attribute Matrix"});
7882
params.insert(std::make_unique<DataObjectNameParameter>(k_CellAttributeMatrixName_Key, "Cell Attribute Matrix", "The name of the cell data attribute matrix for the created Image Geometry",
7983
ImageGeom::k_CellAttributeMatrixName));
8084
params.insertSeparator(Parameters::Separator{"Output Ensemble Attribute Matrix"});
8185
params.insert(std::make_unique<DataObjectNameParameter>(k_CellEnsembleAttributeMatrixName_Key, "Ensemble Attribute Matrix", "The Attribute Matrix where the phase information is stored.",
8286
"Cell Ensemble Data"));
8387

88+
// Link Parameters
89+
params.linkParameters(k_CombineScans_Key, k_Origin_Key, true);
90+
params.linkParameters(k_CombineScans_Key, k_CreatedImageGeometryPath_Key, true);
91+
8492
return params;
8593
}
8694

8795
//------------------------------------------------------------------------------
8896
IFilter::VersionType ReadH5OinaDataFilter::parametersVersion() const
8997
{
90-
return 1;
98+
return 2;
99+
100+
// Version 1 -> 2
101+
// Change 1:
102+
// Added - k_CombineScans_Key = "combine_scans";
103+
// Solution - default parameter value 'true' preserves backwards functionality;
91104
}
92105

93106
//------------------------------------------------------------------------------
@@ -101,6 +114,7 @@ IFilter::PreflightResult ReadH5OinaDataFilter::preflightImpl(const DataStructure
101114
const std::atomic_bool& shouldCancel) const
102115
{
103116
auto pSelectedScanNamesValue = filterArgs.value<OEMEbsdScanSelectionParameter::ValueType>(k_SelectedScanNames_Key);
117+
auto pCombineScansValue = filterArgs.value<bool>(k_CombineScans_Key); // V2 Param
104118
auto pZSpacingValue = filterArgs.value<float32>(k_ZSpacing_Key);
105119
auto pOriginValue = filterArgs.value<VectorFloat32Parameter::ValueType>(k_Origin_Key);
106120
auto pReadPatternDataValue = filterArgs.value<bool>(k_ReadPatternData_Key);
@@ -109,10 +123,9 @@ IFilter::PreflightResult ReadH5OinaDataFilter::preflightImpl(const DataStructure
109123
auto pCellEnsembleAttributeMatrixNameValue = filterArgs.value<std::string>(k_CellEnsembleAttributeMatrixName_Key);
110124
auto pConvertPhaseData = filterArgs.value<bool>(k_ConvertPhaseToInt32_Key);
111125

112-
DataPath cellEnsembleAMPath = pImageGeometryNameValue.createChildPath(pCellEnsembleAttributeMatrixNameValue);
113-
DataPath cellAMPath = pImageGeometryNameValue.createChildPath(pCellAttributeMatrixNameValue);
126+
DataPath cellEnsembleAMPath = {};
127+
DataPath cellAMPath = {};
114128

115-
PreflightResult preflightResult;
116129
nx::core::Result<OutputActions> resultOutputActions;
117130
std::vector<PreflightValue> preflightUpdatedValues;
118131

@@ -135,65 +148,86 @@ IFilter::PreflightResult ReadH5OinaDataFilter::preflightImpl(const DataStructure
135148
return MakePreflightErrorResult(-9582, fmt::format("An error occurred while reading the header data\n{} : {}", err, reader.getErrorMessage()));
136149
}
137150

138-
// create the Image Geometry and it's attribute matrices
139-
const CreateImageGeometryAction::DimensionType dims = {static_cast<usize>(reader.getXDimension()), static_cast<usize>(reader.getYDimension()), pSelectedScanNamesValue.scanNames.size()};
140-
const std::vector<usize> tupleDims = {dims[2], dims[1], dims[0]};
151+
for(const auto& name : pSelectedScanNamesValue.scanNames)
141152
{
153+
reader.setHDF5Path(name);
154+
142155
CreateImageGeometryAction::SpacingType spacing = {reader.getXStep(), reader.getYStep(), pZSpacingValue};
156+
CreateImageGeometryAction::DimensionType dims = {static_cast<usize>(reader.getXDimension()), static_cast<usize>(reader.getYDimension()),
157+
pCombineScansValue ? pSelectedScanNamesValue.scanNames.size() : static_cast<usize>(1)};
158+
const std::vector<usize> tupleDims = {dims[2], dims[1], dims[0]};
143159

144-
auto createDataGroupAction = std::make_unique<CreateImageGeometryAction>(pImageGeometryNameValue, dims, pOriginValue, spacing, pCellAttributeMatrixNameValue);
145-
resultOutputActions.value().appendAction(std::move(createDataGroupAction));
146-
}
147-
const auto phases = reader.getPhaseVector();
148-
std::vector<usize> ensembleTupleDims{phases.size() + 1};
149-
{
150-
auto createAttributeMatrixAction = std::make_unique<CreateAttributeMatrixAction>(cellEnsembleAMPath, ensembleTupleDims);
151-
resultOutputActions.value().appendAction(std::move(createAttributeMatrixAction));
152-
}
160+
if(pCombineScansValue)
161+
{
162+
cellEnsembleAMPath = pImageGeometryNameValue.createChildPath(pCellEnsembleAttributeMatrixNameValue);
163+
cellAMPath = pImageGeometryNameValue.createChildPath(pCellAttributeMatrixNameValue);
153164

154-
// create the cell ensemble arrays
155-
{
156-
auto createArrayAction = std::make_unique<CreateArrayAction>(DataType::uint32, ensembleTupleDims, std::vector<usize>{1}, cellEnsembleAMPath.createChildPath(EbsdLib::CtfFile::CrystalStructures));
157-
resultOutputActions.value().appendAction(std::move(createArrayAction));
158-
}
159-
{
160-
auto createArrayAction = std::make_unique<CreateArrayAction>(DataType::float32, ensembleTupleDims, std::vector<usize>{6}, cellEnsembleAMPath.createChildPath(EbsdLib::CtfFile::LatticeConstants));
161-
resultOutputActions.value().appendAction(std::move(createArrayAction));
162-
}
163-
{
164-
auto createArrayAction = std::make_unique<CreateStringArrayAction>(ensembleTupleDims, cellEnsembleAMPath.createChildPath(EbsdLib::CtfFile::MaterialName));
165-
resultOutputActions.value().appendAction(std::move(createArrayAction));
166-
}
165+
auto createDataGroupAction = std::make_unique<CreateImageGeometryAction>(pImageGeometryNameValue, dims, pOriginValue, spacing, pCellAttributeMatrixNameValue);
166+
resultOutputActions.value().appendAction(std::move(createDataGroupAction));
167+
}
168+
else
169+
{
170+
DataPath imagePath = DataPath({name});
171+
cellEnsembleAMPath = imagePath.createChildPath(pCellEnsembleAttributeMatrixNameValue);
172+
cellAMPath = imagePath.createChildPath(pCellAttributeMatrixNameValue);
173+
CreateImageGeometryAction::OriginType origin = {reader.getXStar(), reader.getYStar(), reader.getZStar()};
167174

168-
// create the cell data arrays
169-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::BandContrast)));
170-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::BandSlope)));
171-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Bands)));
172-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Error)));
173-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{3}, cellAMPath.createChildPath(EbsdLib::H5OINA::Euler)));
174-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::MeanAngularDeviation)));
175-
if(pConvertPhaseData)
176-
{
177-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::int32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Phase)));
178-
}
179-
else
180-
{
181-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Phase)));
182-
}
183-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::X)));
184-
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Y)));
175+
auto createDataGroupAction = std::make_unique<CreateImageGeometryAction>(imagePath, dims, origin, spacing, pCellAttributeMatrixNameValue);
176+
resultOutputActions.value().appendAction(std::move(createDataGroupAction));
177+
}
185178

186-
if(pReadPatternDataValue)
187-
{
188-
std::array<int32, 2> patternDims = {{0, 0}};
189-
reader.getPatternDims(patternDims);
190-
if(patternDims[0] == 0 || patternDims[1] == 0)
179+
const auto phases = reader.getPhaseVector();
180+
std::vector<usize> ensembleTupleDims{phases.size() + 1};
181+
{
182+
auto createAttributeMatrixAction = std::make_unique<CreateAttributeMatrixAction>(cellEnsembleAMPath, ensembleTupleDims);
183+
resultOutputActions.value().appendAction(std::move(createAttributeMatrixAction));
184+
}
185+
186+
// create the cell ensemble arrays
187+
{
188+
auto createArrayAction = std::make_unique<CreateArrayAction>(DataType::uint32, ensembleTupleDims, std::vector<usize>{1}, cellEnsembleAMPath.createChildPath(EbsdLib::CtfFile::CrystalStructures));
189+
resultOutputActions.value().appendAction(std::move(createArrayAction));
190+
}
191+
{
192+
auto createArrayAction = std::make_unique<CreateArrayAction>(DataType::float32, ensembleTupleDims, std::vector<usize>{6}, cellEnsembleAMPath.createChildPath(EbsdLib::CtfFile::LatticeConstants));
193+
resultOutputActions.value().appendAction(std::move(createArrayAction));
194+
}
195+
{
196+
auto createArrayAction = std::make_unique<CreateStringArrayAction>(ensembleTupleDims, cellEnsembleAMPath.createChildPath(EbsdLib::CtfFile::MaterialName));
197+
resultOutputActions.value().appendAction(std::move(createArrayAction));
198+
}
199+
200+
// create the cell data arrays
201+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::BandContrast)));
202+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::BandSlope)));
203+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Bands)));
204+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Error)));
205+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{3}, cellAMPath.createChildPath(EbsdLib::H5OINA::Euler)));
206+
resultOutputActions.value().appendAction(
207+
std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::MeanAngularDeviation)));
208+
if(pConvertPhaseData)
209+
{
210+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::int32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Phase)));
211+
}
212+
else
213+
{
214+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::uint8, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Phase)));
215+
}
216+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::X)));
217+
resultOutputActions.value().appendAction(std::make_unique<CreateArrayAction>(DataType::float32, tupleDims, std::vector<usize>{1}, cellAMPath.createChildPath(EbsdLib::H5OINA::Y)));
218+
219+
if(pReadPatternDataValue)
191220
{
192-
return MakePreflightErrorResult(-9583, fmt::format("The parameter 'Read Pattern Data' has been enabled but there does not seem to be any pattern data in the file for the scan name selected"));
221+
std::array<int32, 2> patternDims = {{0, 0}};
222+
reader.getPatternDims(patternDims);
223+
if(patternDims[0] == 0 || patternDims[1] == 0)
224+
{
225+
return MakePreflightErrorResult(-9583, fmt::format("The parameter 'Read Pattern Data' has been enabled but there does not seem to be any pattern data in the file for the scan name selected"));
226+
}
227+
auto createArrayAction = std::make_unique<CreateArrayAction>(DataType::uint16, tupleDims, std::vector<usize>{static_cast<usize>(patternDims[0]), static_cast<usize>(patternDims[1])},
228+
cellAMPath.createChildPath(EbsdLib::H5OINA::UnprocessedPatterns));
229+
resultOutputActions.value().appendAction(std::move(createArrayAction));
193230
}
194-
auto createArrayAction = std::make_unique<CreateArrayAction>(DataType::uint16, tupleDims, std::vector<usize>{static_cast<usize>(patternDims[0]), static_cast<usize>(patternDims[1])},
195-
cellAMPath.createChildPath(EbsdLib::H5OINA::UnprocessedPatterns));
196-
resultOutputActions.value().appendAction(std::move(createArrayAction));
197231
}
198232

199233
return {std::move(resultOutputActions), std::move(preflightUpdatedValues)};
@@ -206,10 +240,11 @@ Result<> ReadH5OinaDataFilter::executeImpl(DataStructure& dataStructure, const A
206240
ReadH5DataInputValues inputValues;
207241

208242
inputValues.SelectedScanNames = filterArgs.value<OEMEbsdScanSelectionParameter::ValueType>(k_SelectedScanNames_Key);
243+
inputValues.CombineScans = filterArgs.value<bool>(k_CombineScans_Key);
209244
inputValues.ReadPatternData = filterArgs.value<bool>(k_ReadPatternData_Key);
210245
inputValues.ImageGeometryPath = filterArgs.value<DataPath>(k_CreatedImageGeometryPath_Key);
211-
inputValues.CellEnsembleAttributeMatrixPath = inputValues.ImageGeometryPath.createChildPath(filterArgs.value<std::string>(k_CellEnsembleAttributeMatrixName_Key));
212-
inputValues.CellAttributeMatrixPath = inputValues.ImageGeometryPath.createChildPath(filterArgs.value<std::string>(k_CellAttributeMatrixName_Key));
246+
inputValues.CellEnsembleAttributeMatrixName = filterArgs.value<std::string>(k_CellEnsembleAttributeMatrixName_Key);
247+
inputValues.CellAttributeMatrixName = filterArgs.value<std::string>(k_CellAttributeMatrixName_Key);
213248
inputValues.ConvertPhaseToInt32 = filterArgs.value<bool>(k_ConvertPhaseToInt32_Key);
214249
inputValues.EdaxHexagonalAlignment = filterArgs.value<bool>(k_EdaxHexagonalAlignment_Key);
215250

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ORIENTATIONANALYSIS_EXPORT ReadH5OinaDataFilter : public IFilter
2424
ReadH5OinaDataFilter& operator=(ReadH5OinaDataFilter&&) noexcept = delete;
2525

2626
// Parameter Keys
27+
// V1 Keys
2728
static inline constexpr StringLiteral k_SelectedScanNames_Key = "selected_scan_names";
2829
static inline constexpr StringLiteral k_ZSpacing_Key = "z_spacing";
2930
static inline constexpr StringLiteral k_Origin_Key = "origin";
@@ -34,6 +35,9 @@ class ORIENTATIONANALYSIS_EXPORT ReadH5OinaDataFilter : public IFilter
3435
static inline constexpr StringLiteral k_EdaxHexagonalAlignment_Key = "edax_hexagonal_alignment";
3536
static inline constexpr StringLiteral k_ConvertPhaseToInt32_Key = "convert_phase_to_int32";
3637

38+
// V2 Keys
39+
static inline constexpr StringLiteral k_CombineScans_Key = "combine_scans";
40+
3741
/**
3842
* @brief Returns the name of the filter.
3943
* @return

0 commit comments

Comments
 (0)