Project-MONAI / Project-MONAI/MONAI
nuclick transforms: min_area and do_reconstruction are documented but never used
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.7k
- Forks
- 1.6k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 20
Description
Describe the bug
Two documented parameters in monai/apps/nuclick/transforms.py are accepted and stored but never used, so setting them has no effect.
1. SplitLabeld.min_area
Documented as "min_area: The smallest allowable object size.", assigned in __init__, and then never referenced again — __call__ uses mask_value, others_value and to_binary_mask, but nothing filters by area.
$ grep -rn "\.min_area\b" monai/
monai/apps/nuclick/transforms.py:157: self.min_area = min_area
That single line is the only occurrence in the package.
2. PostFilterLabeld.do_reconstruction
Documented as "do_reconstruction: Boolean Flag, Perform a morphological reconstruction of an image...", assigned in __init__, never read. __call__ runs
masks = self.post_processing(label, self.thresh, self.min_size, self.min_hole)
and post_processing does not accept the flag at all:
def post_processing(self, preds, thresh=0.33, min_size=10, min_hole=30):
masks = preds > thresh
for i in range(preds.shape[0]):
masks[i] = morphology.remove_small_objects(masks[i], min_size=min_size)
masks[i] = morphology.remove_small_holes(masks[i], area_threshold=min_hole)
return masks
so there is no morphological-reconstruction step anywhere in the class. nuc_points is likewise stored and unused, which is consistent with the reconstruction path (which is what would need the click points) never having been wired up.
To Reproduce
grep -rn "\.min_area\b" monai/ # 1 hit: the assignment
grep -rn "\.do_reconstruction\b" monai/ # 1 hit: the assignment
Expected behavior
Either the parameters take effect, or they are not offered.
Why I am filing this rather than sending a PR
Both plausible fixes involve a judgement call I would rather not make for you:
- implement them — filtering by
min_area, and adding a reconstruction branch usingnuc_points— is writing new behaviour, and I do not know what the NuClick reference implementation expects here; - remove them — accurate, but they are public keyword arguments on two transforms, so it is a breaking change that probably wants a deprecation cycle.
Happy to send a PR for whichever direction you prefer.
Environment
Verified against the current dev branch; the parameters are present and unused there.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in monai/apps/nuclick/transforms.py by reading SplitLabeld.init/call and PostFilterLabeld.init/call/post_processing, then consult the NuClick reference implementation for the intended behavior. Decide whether to implement or deprecate the unused parameters, and verify that the chosen behavior is covered without leaving documented arguments ineffective.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100