10000 Turn exclude_border off in peak_local_max by default by aomader · Pull Request #2447 · scikit-image/scikit-image · GitHub
[go: up one dir, main page]

Skip to content

Turn exclude_border off in peak_local_max by default #2447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

aomader
Copy link
Contributor
@aomader aomader commented Jan 12, 2017

Fixes #2407

@soupault soupault added the ⏩ type: Enhancement Improve existing features label Jan 12, 2017
@codecov-io
Copy link
codecov-io commented Jan 12, 2017

Current coverage is 90.69% (diff: 100%)

Merging #2447 into master will not change coverage

@@             master      #2447   diff @@
==========================================
  Files           304        304          
  Lines         21427      21427          
  Methods           0          0          
  Messages          0          0          
  Branches       1838       1838          
==========================================
  Hits          19433      19433          
  Misses         1654       1654          
  Partials        340        340          

Powered by Codecov. Last update 3e34e9d...5f931fe

@@ -48,9 +48,10 @@ def peak_local_max(image, min_distance=1, threshold_abs=None,
the minimum intensity of the image.
threshold_rel : float, optional
Minimum intensity of peaks, calculated as `max(image) * threshold_rel`.
exclude_border : int, optional
exclude_border : int | bool, optional
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@soupault Done

@sciunto
Copy link
Member
sciunto commented Jan 12, 2017

Shouldn't we follow a deprecation path?

@aomader
Copy link
Contributor Author
aomader commented Jan 12, 2017

I don't think so. First, there is nothing going to be removed nor added in place of it. Second, the change of the default value only might cause more peaks popping up for unaware users, which is most certainly better than the other way around.

So I think an appropriate remark in the change log is sufficient.

@sciunto
Copy link
Member
sciunto commented Jan 13, 2017

I'm hesitant. At least, I would not include this patch in 0.13 to have enough time to get feedbacks from users who test the dev version.

@jni
Copy link
Member
jni commented Jan 13, 2017

Uuuuh, other @scikit-image/core devs can chime in, but I'm pretty sure this requires a deprecation path. This is required whenever the output of a function will change for the exact same input. When people update their environment, they should not be left to wonder which of the updates changed their results (NumPy, SciPy, pandas, scikit-image could all be culprits in a complex pipeline).

@aomader
Copy link
Contributor Author
aomader commented Jan 15, 2017

@jni It's not the exact same input, since the default value changed and thus a different input.

Nonetheless, how should one proceed in case a deprecation path is required?

@JDWarner
Copy link
Contributor
JDWarner commented Jan 15, 2017

For the record, when I first combined two separate peak-finding functions into what is now peak_local_max back in 2013 or so, I thought this setting was the worst. It's very unintuitive, and IMO should absolutely be disabled by default. At the time, I didn't have the confidence to say so; the test suite assumed this behavior and there was no deprecation path.

What's changed in 4 years? Nothing, except we've led a lot of users astray who had peak(s) near the edge of their images and didn't change the default. Worse, our default links the blind edge to min_distance which is extremely unintuitive and problematic.

At issue, really, is this:

If a function saying "hey I find peaks!" which actually ignores any peaks in a large subset of the image with default settings hostile to users? I'd argue yes. Further, I'd argue that anyone who would be tripped up by changing this default in the vast majority of cases was assuming different behavior than what they got. Users who explicitly set this this False were reading the docs; probably everyone else has been getting wrong results.

Coming at this from another angle - can anyone think of a single common use case where the border exclusion would actually be desired? I can make up very niche reasons this would be nice, but none of them are good reasons. And all of them could be handled by doing peak finding on a sliced down input, e.g., passing im[4:-4, 4:-4].

In summary, I think this is user hostile behavior and a bug. It should be fixed. There's no easy deprecation pathway, so a documented breaking change is warranted. Frankly, I think removing the setting entirely would be reasonable.

@aomader
Copy link
Contributor Author
aomader commented Jan 15, 2017

That makes me wonder why it was included in the first place @JDWarner? If there were no legit reasons or use cases, it seems kinda odd to add a feature just for the feature.

@JDWarner
Copy link
Contributor

@b52 Can't say; I'm unsure of the history before that point, as harmonizing the peak finding was one of my earliest contributions. Maybe there's a decent reason for it I'm missing entirely.

@sciunto sciunto added this to the 0.14 milestone Jan 18, 2017
@stefanv
Copy link
Member
stefanv commented Apr 6, 2017

How about: removing the setting and raising a warning for two releases, unless it is specified and set to False.

@stefanv
Copy link
Member
stefanv commented May 1, 2018

@b52 Are you still interested in working on this issue? @JDWarner @jni Are you both happy with the removal of this option, as suggested above?

@jni
Copy link
Member
jni commented May 1, 2018

@stefanv et al

Actually I suggest closing this PR. Some points:

  • Sorry that I missed the discussion about why have that option at all, but exclude_border absolutely makes sense in many contexts. Here's a simple example:

screen shot 2018-05-01 at 8 15 23 pm

The point I'm trying to illustrate is that one cannot be sure whether a maximum on the border is actually a local maximum or rather a truncated upward slope. In fact, the second option is much more probable if you are sampling peaks that are wider than three pixels. So if you don't exclude the borders, you will mostly get junk on the borders, in proportion to how wide your peaks are. And @JDWarner, truncating the image does not actually alleviate this problem because then you will get junk on the inner border — and real peaks in the intervening space will be mis-localized!

In other examples, such as object counting that correctly accounts for edge effects, you do want peaks on the borders, but only half the borders.

To summarize my view:

a) the option should be maintained going forward
b) we can argue about the default value (this should take place in #3022 or #3016 probably), but I would argue that the default should be to exclude a 1 pixel border.
c) any change in behavior should follow the standard deprecation path. peak_local_max may have problems but based on help requests I predict it's among our most used functions.

@b52 thanks for your PR, and I apologize if I sound rude above... I just want to make my case clear and also not send you down the rabbit hole of deprecation procedures when the function itself might be deprecated soon.

@stefanv
Copy link
Member
stefanv commented May 1, 2018 via email

@aomader
Copy link
Contributor Author
aomader commented May 16, 2018

@jni No offense taken. This PR can be closed since I rolled my own implementation and I'm not using this function anymore.

Here are just my two cents on this:

  • To be honest, I don't understand the example @jni has given and how this applies to peak_local_max. If I know what I'm dealing with and how to derive maxima analytically, I will most certainly do that rather than running peak_local_max.
  • The assumption that you "don't wand maxima at the border" is in my opinion to strong and should most certainly not be a default value
  • Hiding information seems more bad than showing potentially superfluous information, the former one is easy to miss while the latter one is more obvious and easy to fix

But you can count me out from now.

@aomader aomader closed this May 16, 2018
@stefanv
Copy link
Member
stefanv commented May 16, 2018

I think @jni's point is that those points on the border that seem like maxima may very well not be, had we been able to sample "further afield". On the other hand, if you define a maximum as a pixel with no greater neighbor, then these count. So, yes, this should remain an option, and it is not clear what to make the default—either option seems fine, as long as it can easily be disabled.

The current status is just weird, since it defaults to "True", which doesn't seem right—should be 1 or 0. The docstring states:

exclude_border : int, optional
    If nonzero, `exclude_border` excludes peaks from
    within `exclude_border`-pixels of the border of the image.

So, what happens to True here? Does it become 1? If so, then your suggestion is already implemented, @jni, but should be clarified in the docstring.

@jni
Copy link
Member
jni commented May 20, 2018

@stefanv if True, then the value evaluates to min_distance! I thought we had merged a PR that made this clear, but clearly this is not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0