Skip to content

Improve docstring for rolling_ball function.#7682

Merged
jarrodmillman merged 8 commits intoscikit-image:mainfrom
mkcor:improve-rolling-docstring
Jan 30, 2025
Merged

Improve docstring for rolling_ball function.#7682
jarrodmillman merged 8 commits intoscikit-image:mainfrom
mkcor:improve-rolling-docstring

Conversation

@mkcor
Copy link
Member

@mkcor mkcor commented Jan 29, 2025

Description

As I started tackling #7680, I had to refresh my memory and remember what the rolling-ball algorithm was about. I found there was room for improvement with the function's docstring, in spite of the multiple reviews back in the days! This PR is an attempt at providing clearer descriptions. Then I'll go through the gallery example.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

Improve docstring of `skimage.restoration.rolling_ball`.

kernel : ndarray, optional
The kernel to be rolled/translated in the image. It must have the
same number of dimensions as ``image``. Kernel is filled with the
intensity of the kernel at that position.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FirefoxMetzger I originally tried fixing the sentence "Kernel is filled with the intensity of the kernel" but then I thought these details would fit better in the Notes.

@jarrodmillman jarrodmillman added the 📄 type: Documentation Updates, fixes and additions to documentation label Jan 29, 2025
Copy link
Member

@stefanv stefanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mkcor!

I started reading the docstring, and was immediately confused by things you explain later in the notes. I think it would be helpful to give a short, intuitive explanation as part of the function description (it doesn't require that much!). But also fine to add a forward reference to the notes, if you prefer.

Comment on lines 10 to 13
This function estimates the background intensity of an n-dimensional
image. Typically, it is useful for background subtraction in case of
uneven exposure. It is a generalization of the well-known rolling-ball
algorithm [1]_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This function estimates the background intensity of an n-dimensional
image. Typically, it is useful for background subtraction in case of
uneven exposure. It is a generalization of the well-known rolling-ball
algorithm [1]_.
This function is a generalization of the rolling-ball algorithm [1]_
to estimate the background intensity of an N-dimensional
image. This is useful for background subtraction in case of
uneven exposure. Think of the image as a landscape
(where altitude is determined by intensity), under which
a ball of given radius is rolled. At each position, the ball's
apex determines the resulting background intensity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefanv I included this in 13eeb19. I wrote "n-dimensional" instead of "N-dimensional" although we use both conventions throughout the codebase; in this case, I think it's better to differentiate it from the "N" used in the Notes when referring to the algorithm's polynomial complexity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem; we should strive to get it uniform eventually, either n/N fine.

Co-authored-by: Stefan van der Walt <[email protected]>
@stefanv
Copy link
Member

stefanv commented Jan 29, 2025

Totally fine to hyphenate however you see fit, by the way!

@stefanv
Copy link
Member

stefanv commented Jan 30, 2025

Sorry @mkcor, I had to cancel your CI checks on macos because I need the runners. But, I will have that situation under control soon. Happy to merge your changes when you're ready (wasn't sure whether you had addressed my comments or not 😅).

@stefanv
Copy link
Member

stefanv commented Jan 30, 2025

(Added new GH runners and restarted tests; but the rolling ball is the culprit in making them so slow!)

@mkcor
Copy link
Member Author

mkcor commented Jan 30, 2025

wasn't sure whether you had addressed my comments or not 😅

Not entirely yet! 🙏

@mkcor
Copy link
Member Author

mkcor commented Jan 30, 2025

I used the term 'doctest' in a commit message although no check is performed in these docstring examples. They just illustrate how the function may be used.

Btw, this is now ready for final review!


def rolling_ball(image, *, radius=100, kernel=None, nansafe=False, num_threads=None):
"""Estimate background intensity by rolling/translating a kernel.
"""Estimate background intensity using the rolling ball algorithm.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Estimate background intensity using the rolling ball algorithm.
"""Estimate background intensity using the rolling-ball algorithm.

As long as its consistent :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gallery example will soon be consistent :)

Comment on lines 10 to 13
This function estimates the background intensity of an n-dimensional
image. Typically, it is useful for background subtraction in case of
uneven exposure. It is a generalization of the well-known rolling-ball
algorithm [1]_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem; we should strive to get it uniform eventually, either n/N fine.

@stefanv
Copy link
Member

stefanv commented Jan 30, 2025

Looks good! The failure is related, however.

@jarrodmillman jarrodmillman merged commit c473ca0 into scikit-image:main Jan 30, 2025
25 checks passed
@mkcor mkcor deleted the improve-rolling-docstring branch January 30, 2025 21:55
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Feb 4, 2025
…ailure

* origin/main:
  Add zizmor to pre-commit; address GH workflow issues raised (scikit-image#7662)
  Reenable test marked as flaky on Azure. (scikit-image#7694)
  Simultaneously resolve all dependencies; add pip caching (scikit-image#7690)
  Copy keypoints if necessary to preserve contiguity (scikit-image#7692)
  CI cleanup (scikit-image#7693)
  Port CI testing from Azure to GitHub (scikit-image#7687)
  Lower CI build verbosity
  Use pytest config in pyproject.toml in CI (scikit-image#7555)
  Improve docstring for rolling_ball function. (scikit-image#7682)
@stefanv stefanv added this to the 0.25.2 milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📄 type: Documentation Updates, fixes and additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants