Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional hole-filling step to the mask2stl conversion pipeline and introduces basic integration tests (using committed test data) to validate mesh output, alongside some Ruff configuration refactoring.
Changes:
- Add
fill_holes_in_mask()and a--fill-holes/-fCLI flag to optionally fill holes in binary masks before meshing. - Add integration tests and
_datafixtures to compare generated meshes against expected STL outputs. - Introduce
ruff_defaults.tomland wire it intopyproject.toml; update README with the new CLI option.
Reviewed changes
Copilot reviewed 6 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/stl2mask/mask2stl.py |
Implements hole-filling + CLI flag wiring; updates mask2stl signature. |
tests/test_mask2stl.py |
Adds mesh-based integration tests and updates existing unit tests for new parameter. |
tests/conftest.py |
Adds a data_path fixture for locating tests/_data. |
tests/_data/sphere.nii.gz |
Adds binary mask fixture for sphere conversion tests. |
tests/_data/hollow_sphere.nii.gz |
Adds binary mask fixture for hollow-sphere conversion tests. |
README.md |
Documents --fill-holes option. |
ruff_defaults.toml |
Adds shared Ruff defaults/config presets. |
pyproject.toml |
Configures Ruff to extend ruff_defaults.toml and adds a Hatch static-analysis env. |
Comments suppressed due to low confidence (2)
src/stl2mask/mask2stl.py:44
fill_holes_in_maskcomputesforeground_valueby converting the whole image to a NumPy view and taking.max(), which adds another full pass over the volume. Sincemask2stlalready computesmask_valuesfor validation, consider reusingmask_values.max()(or passing the foreground value in) to avoid the extra scan when--fill-holesis enabled.
foreground_value = float(sitk.GetArrayViewFromImage(mask).max())
return sitk.BinaryFillhole(mask, fullyConnected=False, foregroundValue=foreground_value)
tests/test_mask2stl.py:275
- The comment says hole filling is enabled, but the call passes
fill_holes=False. Please fix the comment (or the argument) so the test intent matches the behavior being exercised.
# Convert the mask to STL with hole filling enabled
mask2stl_module.mask2stl(mask_path=mask_path, image_path=None, output_path=output_path, fill_holes=False)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
--fill-holesflag to fill holes in the binary mask before converting it to a mesh.I also added basic tests for the results of
mask2stl.