Skip to content

Comments

Further document use of regionprops function and fix terms.#7518

Merged
jni merged 15 commits intoscikit-image:mainfrom
mkcor:improve-regionprops-docs
Apr 25, 2025
Merged

Further document use of regionprops function and fix terms.#7518
jni merged 15 commits intoscikit-image:mainfrom
mkcor:improve-regionprops-docs

Conversation

@mkcor
Copy link
Member

@mkcor mkcor commented Aug 30, 2024

Description

The main addition here is b0cbf30 + 7617fbd.

Along the way, I proofread the entire docstring. I'm not entirely sure I should have replaced type ndarray with array but I have a vague memory along these lines with @grlee77 ...

I'm pretty confident about all the other changes. @lagru I updated the imports under Examples.

@stefanv I used the term "label image" consistently and according to the conversation we had on Monday.

I made sure regions were referred to as "regions" or "image regions" throughout the text.

For the record, since I cannot apply a second label: I created this PR during the EuroSciPy 2024 sprint following a discussion with @lagru and @stefanv! 🚀

Checklist

Release note

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

...

@mkcor mkcor added the 📄 type: Documentation Updates, fixes and additions to documentation label Aug 30, 2024
@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/handling-coords-output-in-regionprops-table/75770/4

Comment on lines 938 to 939
The table is "tidy" [1]_; it is a dictionary mapping property names to
value arrays. See Notes section below for details.
Copy link
Member

Choose a reason for hiding this comment

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

I would say:

The return value is a dictionary mapping property names to value arrays. This dictionary can be used as input to pandas.DataFrame to result in a "tidy" [1]_ table with one region per row and one property per column.

Copy link
Member Author

Choose a reason for hiding this comment

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

I love it, thank you! 0c92394

@mkcor
Copy link
Member Author

mkcor commented Aug 31, 2024

I'm not entirely sure I should have replaced type ndarray with array but I have a vague memory along these lines with @grlee77 ...

My mistake, ndarray is dominant in our codebase:

$ ack ": ndarray" | wc -l
602
$ ack ": array" | wc -l
254

I'll revert my changes from "ndarray" to "array" then!

mkcor and others added 3 commits August 31, 2024 17:35
@mkcor mkcor mentioned this pull request Nov 19, 2024
3 tasks
@mkcor
Copy link
Member Author

mkcor commented Feb 18, 2025

I'm not entirely sure I should have replaced type ndarray with array but I have a vague memory along these lines with @grlee77 ...

@lagru iirc docstub parses ndarray and array differently...

Co-authored-by: Juan Nunez-Iglesias <[email protected]>
@mkcor mkcor requested review from jni and lagru February 18, 2025 21:58
@mkcor
Copy link
Member Author

mkcor commented Apr 8, 2025

@jni @lagru pinging you for review 🙏

Came back to this because we are currently mentioning regionprops at the GloBIAS + Data Carpentry workshop: We want to include image measurements in the Bioimage analysis with Python lesson-to-be.

Comment on lines +946 to +948
The return value is a dictionary mapping property names to value arrays.
This dictionary can be used as input to ``pandas.DataFrame`` to result in
a "tidy" [1]_ table with one region per row and one property per column.
Copy link
Member

Choose a reason for hiding this comment

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

This seems a bit redundant with the description in "Returns", no? Since the first line already implies pandas I'd remove this section in favor of highlighting the rest of the docstring.

Suggested change
The return value is a dictionary mapping property names to value arrays.
This dictionary can be used as input to ``pandas.DataFrame`` to result in
a "tidy" [1]_ table with one region per row and one property per column.

Copy link
Member

Choose a reason for hiding this comment

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

(Not a blocker though!)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree it's slightly redundant... Would you mind if I replaced "a pandas-compatible table" by "tabular data" in the first line?

Copy link
Member

Choose a reason for hiding this comment

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

I'd like the tidy reference to remain somewhere. It's not present in the Return section currently.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't mean that this is verbatim included in returns. But I thought addressing this aspect in detail would make more sense in the return section where Pandas' DataFrame is already referenced.

columns; for example, the region centroids of a 3D image end up in three
different columns, one per dimension. If you need to do complex
computations with the region properties, using
:func:`skimage.measure.regionprops` might be more fitting.
Copy link
Member

Choose a reason for hiding this comment

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

This could also go into the "Notes" section but since it's very useful context I'm totally fine with keeping it here. :) Nice improvement!

lagru
lagru previously approved these changes Apr 8, 2025
Copy link
Member

@lagru lagru left a comment

Choose a reason for hiding this comment

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

Lot's of opportunity for bikeshedding here. 😅 Knowing that, I made a few suggestions on a take it or leave it basis.

The added paragraphs are very nice, the rest doesn't seem like a big game changer to me but I'm fine with it. :)

@lagru lagru dismissed their stale review April 8, 2025 12:13

On second thoughts, probably should give Juan time to chime in as well.

Co-authored-by: Juan Nunez-Iglesias <[email protected]>
spacing=None,
):
"""Compute image properties and return them as a pandas-compatible table.
"""Compute region properties and return them as a pandas-compatible table.
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
"""Compute region properties and return them as a pandas-compatible table.
"""Compute region properties and return them as tabular data.

@jni jni added this to the 0.26 milestone Apr 25, 2025
@jni jni merged commit d480b0e into scikit-image:main Apr 25, 2025
23 checks passed
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jul 7, 2025
* origin/main:
  Deprecate estimate method in favor of class constructor (scikit-image#7771)
  Temporary fix for Visual Studio & Clang incompatibility in Windows image (scikit-image#7835)
  Address deprecations in Pillow 11.3 (scikit-image#7828)
  Remove unused & obsolete `legacy_datasets`, `legacy_registry` vars (scikit-image#7677)
  Draft migration guide for skimage2 (scikit-image#7785)
  Do not report failure in wheels sub-recipe (scikit-image#7806)
  Use consistent wording in property description. (scikit-image#7804)
  Add intensity_median to regionprops (scikit-image#7745)
  CI: Update pypa/gh-action-pypi-publish to v1.12.4 for attestations on PyPI (scikit-image#7793)
  Document output dtype for transform.resize. (scikit-image#7792)
  Use `cibuildwheel` to build WASM/Pyodide wheels for `scikit-image`, push nightlies to Anaconda.org (scikit-image#7440)
  DOC: Include missing gain parameter in adjust_gamma equation (scikit-image#7763)
  Temporarily pin to `pyodide-build==0.30.0`, and ensure that the correct xbuildenvs are used (scikit-image#7788)
  Deprecate old names & attributes in RegionProperties (scikit-image#7778)
  Pin JasonEtco/create-an-issue action to SHA for v2.9.2 (scikit-image#7787)
  Make doctest-plus work with spin (scikit-image#7786)
  Report failures on main via issue (scikit-image#7752)
  Use `workers` instead of alternate parameter names (scikit-image#7302)
  Fix f-string in otsu plot (scikit-image#7780)
  Further document use of regionprops function and fix terms. (scikit-image#7518)
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.

4 participants