-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[WIP] Adding @eldad-a's ridge directed ring detector #4847
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
base: main
Are you sure you want to change the base?
Conversation
Hello @alexdesiqueira! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-06-13 23:18:54 UTC |
The following is based on the discussion I had with @clementkng on Slack during the SciPy 2020 sprint, and what I think we need to pursue for this PR. What we have:
I'd like to: |
Hello @alexdesiqueira Many thanks for moving forward with this PR, and sorry for my losing track of the process. I should have a draft which is If that's helpful, please let me know where to push it to. Thanking you, |
Hey @eldad-a ,
That would be great, thank you! I will add you as a contributor, please feel free to push it here when you can. |
|
||
from skimage.transform import ring_detector | ||
from skimage import data | ||
from scipy import ndimage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import ndimage
before skimage
using 2d microscope imaging. | ||
|
||
Here's a quick description of the parameters. The explanations refer to the | ||
terms as introduced in [Afik 2015](https://www.nature.com/articles/srep13584) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're using Markdown syntax. In my experience, it should be reStructuredText.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can take a look at existing gallery scripts for examples of rst syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that @mkcor @emmanuelle, but this is too raw for a review yet. 😄 I asked @clementkng to move the code from a notebook to this file, starting the documentation process. We'll take care of it 🙂
skimage/transform/ring_detector.py
Outdated
@@ -0,0 +1,30 @@ | |||
from ._ring_detector import RidgeHoughTransform | |||
|
|||
import matplotlib.pyplot as plt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please swap import order.
Reference: https://www.python.org/dev/peps/pep-0008/#imports
Thank you @mkcor! This is still very raw, not ready for a review, though. |
@alexdesiqueira sure, no worries! Your PR title says 'WIP' indeed :) |
Thank you all for your patience with me!
Noticed that I've been exploring the outcome on the use-case for which this code was developed originally (an example was provided in EA NOTES
EA TO-Consider
|
Hey @eldad-a,
Thank you very much, we appreciate your help!
I'd ask your help to determine that technical features, Eldad. I still don't understand the algorithm that much, so please feel free to check what you consider doable on that subject — I would take a time to understand 🙂
I'd like to structure the example on the lines of the examples we have already — hence
I like this! I'd need to understand the other points better, though; what would be their implications, you know... I need to read your paper again 🙂 |
Hi @alexdesiqueira :-)
It is my pleasure;
Sure, I will.
Which data image to use... Why not both? My understanding of licensing goes a very short distance (well, maybe none...).
If you have questions, please let me know; may be easier than going over the paper. Below there's a TODO list I created for my future reference; some are added features, so I guess aren't a must. EA TODO:
In case
|
I think this one is slipping again. |
@stefanv I have this in my mind for a while, now. 🙂 I'll come back to that next week. |
b3814ac
to
8451718
Compare
Alright, (cracking knuckles 🤜🤛 )
Of course 🙂 I'd like to see a well-structured example, though. Maybe using these images to show different aspects of the algorithm? Would that be feasible?
The link says that the license is CC-BY, Eldad;
I would be happy if we have, for this PR:
We can implement the TODO's you proposed in subsequent PRs, Eldad. How does that sound? |
Is this for an image that lives inside skimage.data? We only add CC0 and public domain images there, I think, since we cannot easily have our users display the correct copyright otherwise. |
Oh, sorry @stefanv; you're right! Do you have any images you didn't use in that paper — and you would consider donating — by any chance, @eldad-a? |
Also, @scikit-image/core may I ask some help on "beautifying" the cython code here? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is super random. High level, I think mostly that the parameter handling should maybe be hidden away (either into the init or as function parameters to the second function). And some of the others, like the derivatives should probably just be cdef class
attributes, so nobody can mess with them.
skimage/transform/_ring_detector.pyx
Outdated
#cdef: | ||
# DTYPE_t trH | ||
# DTYPE_t discriminant | ||
# DTYPE_t curvature | ||
#trH = Lrr+Lcc | ||
# numerically stabilising for the cases of extrimly small Lrc: | ||
#discriminant = (Lrr-Lcc)**2 + 4*Lrc*Lrc | ||
#curvature = 0.5*(trH - sqrt( discriminant )) | ||
#return curvature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like some unnecessary performance tries. I guess just delete (or use this instead of the actual one).
skimage/transform/_ring_detector.pyx
Outdated
kernel = np.empty((ksize),DTYPE) | ||
scale2x = -0.5/sigma**2 | ||
|
||
for i in xrange(ksize): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i in xrange(ksize): | |
for i in range(ksize): |
Use range
throughout. Do you use the cython language level? Might set it to 3...
skimage/transform/_ring_detector.pyx
Outdated
assert Lrr is not None and Lcc is not None and Lrc is not None and\ | ||
curv is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong to me. If this is exposed to python, we probably need more than that. Even f it works, it would give a weird error i think?
I am not sure what the best option is here, maybe even create one cdef
version, and then a very brief def ...
version for Python that uses DType_t[:, :] Lrr not None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, there is probably no use for the cdef
here, so just using def
is maybe the best way.
skimage/transform/_ring_detector.pyx
Outdated
RIJ_t [:,:,:] sparse_3d_Hough | ||
RIJ_t [:,:] voted4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RIJ_t [:,:,:] sparse_3d_Hough | |
RIJ_t [:,:] voted4 | |
RIJ_t[:, :, ::1] sparse_3d_Hough | |
RIJ_t[:, ::1] voted4 |
It can be typed as contiguous.
(I prefer that spacing, but I never really coded reviewed cython, so I am not sure, whats typical.)
skimage/transform/_ring_detector.pyx
Outdated
DTYPE_t [:,:,:] smoothed_hough_array | ||
DTYPE_t [:] kernel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTYPE_t [:,:,:] smoothed_hough_array | |
DTYPE_t [:] kernel | |
DTYPE_t[:, :, ::1] smoothed_hough_array | |
DTYPE_t[::1] kernel |
skimage/transform/_ring_detector.pyx
Outdated
ring_mask[row_min-i+r+thickness:r+thickness+row_max-i,\ | ||
col_min-j+r+thickness:r+thickness+col_max-j] | ||
)) | ||
if False: # eccentricity: ## excluding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never used branch? Should this be around?
skimage/transform/_ring_detector.pyx
Outdated
RIJ_t [:,:,:] hough_slice # a.k.a. sparse_3d_Hough | ||
DTYPE_t [:,:,:] smoothed_slice # a.k.a. smoothed_hough_array | ||
RIJ_t [:,:,:] hough_hotspots, hough_modified | ||
RIJ_t [:] hough_counter, hotspots_counter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem all allocated (and some below as well), so it probably makes sense to type them as RIJ_t[:, :, ::1] ...
(i.e. end with ::1
to tell cython that they are contiguous).
skimage/transform/_ring_detector.pyx
Outdated
#from collections import defaultdict | ||
|
||
import numpy as np | ||
cimport numpy as np |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use this or cimport numpy as npc
? My guess is, there is only a few things that would need changing (mainly the typedefs ending with _t
)
skimage/transform/_ring_detector.pyx
Outdated
return 1./denominator, tangent / denominator | ||
|
||
|
||
#@cython.profile(False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete these, at least when they are commented out?
skimage/transform/_ring_detector.pyx
Outdated
|
||
dr = Rmax - Rmin | ||
sr=1 | ||
coords = np.empty((dr+1,2), dtype=INDX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go so far as to inline this function... this function should just not return anything (or if it can error int
, but I don't think it can). And coord
should be an input and modified in-place.
The empty
call should be early on (before the loop) in the function where it is used. (Also type coord
as [:, ::1]
so cython can optimize it as being contiguous.
Could you please guide me through the following:
python setup.py build_ext -i results in : ValueError: '.../scikit-image/skimage/transform/_ring_detector.pyx' doesn't match any files Any suggestions? Should I test using my original PR and commit the test files here? |
Hey @eldad-a,
It would be best to add these in our GitLab repo.
Sorry about that, Eldad 😅 I broke the PR while converting from procedural to OO, and I didn't have time to fix it properly yet. We need to think on an API that could agree with the other transforms, so we can write the tests on that scheme. Minimally, what do you think that the function would need as input and output? |
@alexdesiqueira thanks!
We need to think on an API that could agree with the other transforms, so
we can write the tests on that scheme.
Could you suggest your favorite transform on `skimage`, so I'll have a
better idea? Would skimage circle_hough transform be a good reference?
…On Wed, Jun 16, 2021, 09:28 Alexandre de Siqueira ***@***.***> wrote:
Hey @eldad-a <https://github.com/eldad-a>,
sorry about the silence.
1. Where should example images be added to (folder)?
It would be best to add these in our GitLab repo
<https://gitlab.com/scikit-image/data>.
1. Attempting to compile commit cbab232
<cbab232>
using the command...
Any suggestions? Should I test using my original PR and commit the
test files here?
Sorry about that, Eldad 😅 I broke the PR while converting from
procedural to OO, and I didn't have time to fix it properly yet. We need to
think on an API that could agree with the other transforms, so we can write
the tests on that scheme. Minimally, what do you think that the function
would need as input and output?
Thank you!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4847 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5OFP63QBOM23CHIMV2WADTTDGKZANCNFSM4OX72ZJA>
.
|
Hey @eldad-a,
Sure! I think all our |
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
1. Replace OpenCV Hessian estimation by skimage ones 2. Comment-out 'eccentricity', which relies on OpenCV for EllipseFit 3. Rename, following skimage conventions: Lxx -> Lrr , Lyy -> Lcc , Lxy -> Lrc 3. Add performance observations and TODO to consider
5c37a30
to
ad5d7b4
Compare
Description
Continues #1706, by @eldad-a:
Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.