Repository navigation
BUG: Fix wrong output and invalid input handling in 19 filters #1765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
imikejackson
merged 18 commits into
BlueQuartzSoftware:develop
from
imikejackson:topic/batch2_defect_fixes
Oct 9, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
02e2b75
BUG: Fix DataPath::attemptRename for prefixes of different depth
imikejackson 472a3a0
BUG: Fix child DataPath renaming by substring in 7 places
imikejackson 050b3ca
BUG: Fix physical crop at the Image Geometry upper bound
imikejackson 057cb38
BUG: Fix ReadImage physical crop below the origin
imikejackson a9f8a5d
BUG: Fix ReadImageStack Z crop and grayscale input check
imikejackson e526e01
BUG: Fix ComputeFeatureBounds edge geometry and bounds buffer size
imikejackson 063b88b
BUG: Fix ComputeLargestCrossSections Feature Ids location check
imikejackson 6bd77b6
BUG: Fix Silhouette sparse ids, mask check and cluster 0 mean
imikejackson 741a457
BUG: Fix RegularGridSampleSurfaceMesh custom output type and -1 labels
imikejackson f77d7dc
BUG: Fix QuickSurfaceMesh feature DataArray tuple check
imikejackson 922437b
BUG: Fix WriteASCIIData overwrite of DataArrays with the same name
imikejackson 96961e3
BUG: Fix SurfaceNets input checks and feature DataArray bound
imikejackson d17b0e9
BUG: Fix CropEdgeGeometry shared clip vertices and String/NeighborLis…
imikejackson edd7173
BUG: Accept a physical Z crop maximum at the ReadImageStack upper bound
imikejackson 2822a87
BUG: Check cell DataArray tuple counts instead of their parent
imikejackson 1c992e6
TEST: Check CopyDataObject created paths when Use New Parent is on
imikejackson 56b940a
STY: Move ReadImageStackCropping helpers out of an anonymous namespace
imikejackson 8ad6cf4
STY: Remove a redundant comparison in the RegularGridSampleSurfaceMes…
imikejackson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...Plugins/ImageProcessing/src/ImageProcessing/Filters/Algorithms/ReadImageStackCropping.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #pragma once | ||
|
|
||
| #include "simplnx/Common/Result.hpp" | ||
| #include "simplnx/Parameters/VectorParameter.hpp" | ||
| #include "simplnx/Utilities/ImageIO/ImageStackCropping.hpp" | ||
|
|
||
| #include <fmt/format.h> | ||
|
|
||
| #include <cmath> | ||
|
|
||
| namespace nx::core | ||
| { | ||
| /** | ||
| * @struct ZRange | ||
| * @brief Stores inclusive slice indices in the full input file list. | ||
| */ | ||
| struct ZRange | ||
| { | ||
| usize zMin; | ||
| usize zMax; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Computes the same full-stack slice range for preflight and execution. | ||
| * @param croppingOptions Specifies voxel or physical Z bounds. | ||
| * @param zDim Gives the number of input files before cropping. | ||
| * @param origin Specifies the origin override. | ||
| * @param spacing Specifies the spacing override. | ||
| * @param shouldChangeOrigin Enables the origin override. | ||
| * @param shouldChangeSpacing Enables the spacing override. | ||
| * @param originSpacingProcessing Selects whether overrides apply before cropping. | ||
| * @return Inclusive slice indices, or an error for an invalid crop range. | ||
| */ | ||
| inline Result<ZRange> ComputeCroppedZRange(const CropGeometryParameter::CropValues& croppingOptions, usize zDim, const VectorFloat32Parameter::ValueType& origin, | ||
| const VectorFloat32Parameter::ValueType& spacing, bool shouldChangeOrigin, bool shouldChangeSpacing, OriginSpacingProcessing originSpacingProcessing) | ||
| { | ||
| if(zDim == 0) | ||
| { | ||
| return MakeErrorResult<ZRange>(-64511, "Input file list is empty; nothing to read."); | ||
| } | ||
|
|
||
| ZRange range{0, zDim - 1}; | ||
| if(croppingOptions.cropZ && croppingOptions.type == CropGeometryParameter::CropValues::TypeEnum::VoxelSubvolume) | ||
| { | ||
| range = {static_cast<usize>(croppingOptions.zBoundVoxels[0]), static_cast<usize>(croppingOptions.zBoundVoxels[1])}; | ||
| } | ||
| else if(croppingOptions.cropZ && croppingOptions.type == CropGeometryParameter::CropValues::TypeEnum::PhysicalSubvolume) | ||
| { | ||
| const auto dimensionResult = ComputeCroppedZDimension(croppingOptions, zDim, origin, spacing, shouldChangeOrigin, shouldChangeSpacing, originSpacingProcessing); | ||
| if(dimensionResult.invalid()) | ||
| { | ||
| return {nonstd::make_unexpected(dimensionResult.errors())}; | ||
| } | ||
|
|
||
| // Physical bounds refer to the full stack before cropping or deferred spatial overrides. | ||
| const float64 originZ = (shouldChangeOrigin && originSpacingProcessing == OriginSpacingProcessing::Preprocessed) ? origin[2] : 0; | ||
| const float64 spacingZ = (shouldChangeSpacing && originSpacingProcessing == OriginSpacingProcessing::Preprocessed) ? spacing[2] : 1; | ||
| range.zMin = static_cast<usize>(std::floor((croppingOptions.zBoundPhysical[0] - originZ) / spacingZ)); | ||
| range.zMax = range.zMin + dimensionResult.value() - 1; | ||
| } | ||
|
|
||
| if(range.zMin > range.zMax || range.zMax >= zDim) | ||
| { | ||
| return MakeErrorResult<ZRange>(-64514, fmt::format("Computed Z slice range [{}, {}] is invalid for {} input files.", range.zMin, range.zMax, zDim)); | ||
| } | ||
| return {range}; | ||
| } | ||
| } // namespace nx::core | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.