diff --git a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.cpp b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.cpp index ed81c15514..6dbfc1a061 100644 --- a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.cpp +++ b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.cpp @@ -6,6 +6,11 @@ using namespace complex; +bool ITK::DoTuplesMatch(const IDataStore& dataStore, const ImageGeom& imageGeom) +{ + return imageGeom.getNumberOfCells() == dataStore.getNumberOfTuples(); +} + bool ITK::DoDimensionsMatch(const IDataStore& dataStore, const ImageGeom& imageGeom) { // Stored fastest to slowest i.e. X Y Z diff --git a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp index 05ca97a4be..2bb4960393 100644 --- a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp +++ b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp @@ -108,6 +108,20 @@ inline constexpr int32 k_ImageComponentDimensionMismatch = -2001; } // namespace Constants +/** + * @brief Compares the total number of cells of the image geometry and the total number of tuples from the data store + * @param dataStore + * @param imageGeom + * @return True if the Image Geometry's numCells() == the DataStore's numberOfTuples() + */ +bool DoTuplesMatch(const IDataStore& dataStore, const ImageGeom& imageGeom); + +/** + * @brief Checks to see if the dimensions of the Image Geometry and the DataStore are the same. + * @param dataStore + * @param imageGeom + * @return + */ bool DoDimensionsMatch(const IDataStore& dataStore, const ImageGeom& imageGeom); /** @@ -466,10 +480,8 @@ Result ArraySwitchFuncDimsImpl(const IDataStore& dataStore, const Image { return ArraySwitchFuncComponentImpl(nComp, errorCode, args...); } - else - { - return ArraySwitchFuncComponentImpl(nComp, errorCode, args...); - } + + return ArraySwitchFuncComponentImpl(nComp, errorCode, args...); } template @@ -484,11 +496,13 @@ Result DataCheckImpl(const DataStructure& dataStructure, const Da const IDataStore& dataStore = dataArray.getIDataStoreRef(); - if(!complex::ITK::DoDimensionsMatch(dataStore, imageGeom)) + if(!complex::ITK::DoDimensionsMatch(dataStore, imageGeom) && !complex::ITK::DoTuplesMatch(dataStore, imageGeom)) { - std::string errMessage = fmt::format("DataArray '{}' tuple dimensions '{}' do not match Image Geometry '{}' dimensions '{}'", inputArrayPath.toString(), fmt::join(dataStore.getTupleShape(), ", "), - imageGeomPath.toString(), fmt::join(imageGeom.getDimensions(), ", ")); + std::string errMessage = fmt::format("DataArray '{}' tuple dimensions '{}' do not match Image Geometry '{}' with dimensions 'XYZ={}' and the total number of ImageGeometry Cells {} does not match " + "the total number of DataArray tuples {}.", + inputArrayPath.toString(), fmt::join(dataStore.getTupleShape(), ", "), imageGeomPath.toString(), fmt::join(imageGeom.getDimensions(), ", "), + imageGeom.getNumberOfCells(), dataStore.getNumberOfTuples()); return MakeErrorResult(complex::ITK::Constants::k_ImageGeometryDimensionMismatch, errMessage); } @@ -497,7 +511,8 @@ Result DataCheckImpl(const DataStructure& dataStructure, const Da if(cDims != inputPixelDims) { - std::string errMessage = fmt::format("DataArray component dimensions of '{}' do not match output image component dimensions of '{}'", fmt::join(inputPixelDims, ", "), fmt::join(cDims, ", ")); + const std::string errMessage = + fmt::format("DataArray component dimensions of '{}' do not match output image component dimensions of '{}'", fmt::join(inputPixelDims, ", "), fmt::join(cDims, ", ")); return MakeErrorResult(complex::ITK::Constants::k_ImageComponentDimensionMismatch, errMessage); }