Skip to content

Specify default markers in watershed docstring.#7154

Merged
soupault merged 8 commits intoscikit-image:mainfrom
mkcor:fix-docs-watershed
Oct 27, 2023
Merged

Specify default markers in watershed docstring.#7154
soupault merged 8 commits intoscikit-image:mainfrom
mkcor:fix-docs-watershed

Conversation

@mkcor
Copy link
Copy Markdown
Member

@mkcor mkcor commented Sep 26, 2023

Description

Closes #7117.

Checklist

Release note

Summarize the introduced changes in the code block below in one or a few sentences. The
summary will be included in the next release notes automatically:

...

@mkcor mkcor added the 📄 type: Documentation Updates, fixes and additions to documentation label Sep 26, 2023
such a way that it is equivalent to applying
:func:`skimage.morphology.local_minima` onto ``image`` followed by
:func:`skimage.morphology.label` onto the result
only if setting ``connectivity=2``.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I personally find this really difficult to comprehend. Perhaps, it might be better to simplify this description as much as possible and encourage users to provide their own markers to improve reproducibility?
Otherwise, the PR looks great!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for reviewing, @soupault! How about changing the above into:

None (no markers provided), the (default) markers are determined as the local
minima of the image. Note that the computation of the latter may follow
various assumptions (conventions); users are thus encouraged to pass markers
explicitly. For information, the computation of the default markers is
equivalent to applying :func:`skimage.morphology.local_minima` onto ``image``,
followed by :func:`skimage.morphology.label` onto the result, with
``connectivity=2``.

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That reads better! I think there is a possibility to go even further:

None, the (default) markers are determined as the local minima
 of ``image``. Specifically, the computation is equivalent
 to applying :func:`skimage.morphology.local_minima` onto 
``image``, followed by :func:`skimage.morphology.label` (with 
``connectivity=2``) onto the result. Generally, users are 
encouraged to pass markers explicitly. 

Please, let me know what you think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@soupault I think it reads well, thanks. Now, I'm wondering:

  • I forget whether we want to encourage using skimage.morphology.label or skimage.measure.label (or maybe there's no preference?);
  • I guess connectivity=2 should be replaced with connectivity=image.ndim?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

skimage.morphology.label or skimage.measure.label

They refer to the same function in code, which is under skimage.measure., so I would point to that.

I guess connectivity=2 should be replaced with connectivity=image.ndim?

I have checked the code in details - the correct way seems to be to just say that the functions are called with the specified connectivity.

In the original issue, the local minima are calculated via locMin = label(local_minima(im)), with both functions using default connectivity=im.ndim, thus the confusion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for checking, @soupault! 🙏

They refer to the same function in code, which is under skimage.measure., so I would point to that.

👍 👌

I have checked the code in details - the correct way seems to be to just say that the functions are called with the specified connectivity [...] default connectivity=im.ndim, thus the confusion.

Oh, right, right.

mkcor and others added 2 commits October 27, 2023 13:44
Co-authored-by: Egor Panfilov <egor.v.panfilov@gmail.com>
Copy link
Copy Markdown
Member

@soupault soupault left a comment

Choose a reason for hiding this comment

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

Thanks!

markers explicitly.
connectivity : ndarray, optional
An array with the same number of dimensions as `image` whose
An array with the same number of dimensions as ``image`` whose
Copy link
Copy Markdown
Member

@lagru lagru Oct 27, 2023

Choose a reason for hiding this comment

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

I actually thing it should be

Suggested change
An array with the same number of dimensions as ``image`` whose
An array with the same number of dimensions as `image` whose

as this references the parameter. At least that is what numpydoc recommends and uses.

Otherwise, I approve. :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see: "Enclose variables in single backticks." I was convinced of the opposite, because single backticks render just italic, whereas double backticks render like this:
double_backticks
Then I must update this elsewhere as well; and our documentation is full of variables enclosed in double backticks... 😬

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using single backticks in rST corresponds to emphasis rather than italics. Italics just happens to be what it is formatted as. At least that is how I explain that convention to myself.

and our documentation is full of variables enclosed in double backticks... 😬

As with many other inconsistencies. 😅

Copy link
Copy Markdown
Member Author

@mkcor mkcor Oct 28, 2023

Choose a reason for hiding this comment

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

emphasis rather than italics. Italics just happens to be what it is formatted as.

Yes, yes, I know. I wrote the comment quickly and I actually thought to myself "I should be semantic and write 'emphasis' but, oh, well" 😅 But I find this consideration unrelated:

At least that is how I explain that convention to myself.

What does it explain? It's not intuitive to me at all that variables would be, by (any) convention, represented with emphasis style. To me, that 'steals' the emphasis use away from its original/natural/intuitive purpose: I would emphasize a word in a (plain English) sentence, in a docstring just like I would in any text. Now, if emphasis is used (by convention) to mean 'variable...' what can I use to emphasize a word or a group of words in a sentence? Conversely, I find that the label-like rendering of the double backticks is quite suitable/intuitive to mean 'this is a variable, not just any word in the sentence.'

As with many other inconsistencies. 😅

For sure...

Copy link
Copy Markdown
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.

Approving on the condition of a passing CI. Thanks Marianne. :)

@soupault soupault merged commit 8bebbbc into scikit-image:main Oct 27, 2023
@stefanv stefanv added this to the 0.23 milestone Oct 27, 2023
@mkcor mkcor deleted the fix-docs-watershed branch October 27, 2023 20:46
@stefanv
Copy link
Copy Markdown
Member

stefanv commented Oct 29, 2023

The CI never passed, but this was merged nonetheless.

@lagru
Copy link
Copy Markdown
Member

lagru commented Oct 29, 2023

I guess because the error was unrelated? That is what I meant and could have described anyway.

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.

<Watershed not using local minima as markers by default, contradicting documentation.>

4 participants