Skip to content

MRG: 3D skeletonization - #1923

Merged
jni merged 39 commits into
scikit-image:masterfrom
ev-br:skel3d
Feb 22, 2016
Merged

jni merged 39 commits into
scikit-image:masterfrom
ev-br:skel3d

Conversation

@ev-br

@ev-br ev-br commented Feb 2, 2016

Copy link
Copy Markdown
Contributor

Add a skeletonization algorithm for 2D and 3D images, based on the ImageJ Skeletonize3D plugin, http://fiji.sc/Skeletonize3D

As suggested by Stefan, this PR is a continuation of https://github.com/scikit-image/skeleton_3D/pull/3.
(b00c6be and further commits were added after the review in https://github.com/scikit-image/skeleton_3D/pull/3).

This is WIP, as it needs at least

  • documentation
  • some more tests
  • possibly some better name for the algorithm :-).

Since this is my first scikit-image contribution, I'm sure there are lots of issues :-). For starters, I'm adding several data files for testing --- what is the policy here?

This PR also includes a tweak to the build system, which I'll submit as a separate PR in a minute for the ease of reviewing. If that other PR is merged separately, I'll rebase this one.

Comment thread skimage/morphology/_skeletonize_3d.py Outdated

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.

img = img[np.newaxis, ...]

@soupault

soupault commented Feb 2, 2016

Copy link
Copy Markdown
Member

@ev-br thanks for the contribution! This looks really interesting!

Regarding tests: I'm not sure that adding binaries and extra images is a good option. Couldn't the tests be re-implemented using the images we already provide? BTW, code for the testing is really hard to read and will be a pain to support. I'd suggest to remove visualization feature from it and make it as planar as possible.

I haven't review the Cython code, leaving it to the more experienced devs.

Comment thread skimage/morphology/_skeletonize_3d.py Outdated

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.

Hmm, it appears that not so many things are happening in _prepare_image and _postprocess_image. I would prefer to put all processing in a single function.

@ev-br

ev-br commented Feb 2, 2016

Copy link
Copy Markdown
Contributor Author

Tests: sure, the plotting will go (was useful when debugging, not needed anymore). Sure, if there are some images already, it'd be good to reuse --- can you point me to where they are?

I'd also appreciate an advice on how to deal with Bento: 0b7de82 can't be correct since .pyx file is an implementation detail. I note that scipy bento.info only lists .c files (and numpy's bento.info is gone as of this Fall).

I'm also a bit baffled by the test failure on python 2.7 on Travis. It barfs on the typed tuple which should be supported by a recent enough cython, while there is no problem on python 2.6 on Travis or locally on python 2.7 / cython 0.23.4

@soupault

soupault commented Feb 2, 2016

Copy link
Copy Markdown
Member

@ev-br sure, there are plenty of images provided by the package - https://github.com/scikit-image/scikit-image/tree/master/skimage/data .
Although, I think for this algorithm we may consider adding couple of general purpose 3D images as stored numpy arrays (.npy, .npz).

@stefanv

stefanv commented Feb 2, 2016 via email

Copy link
Copy Markdown
Member

@ev-br
ev-br force-pushed the skel3d branch 3 times, most recently from 77cf385 to 146be23 Compare February 3, 2016 20:57
@ev-br

ev-br commented Feb 5, 2016

Copy link
Copy Markdown
Contributor Author

I believe I addressed all review comments, so from my end this is ready.

The Bat Cochlea dataset is gone because the license is unclear. Ad hoc datasets are gone too. To have some testing for actual 3D case, I dropped an ad hoc image to the data_dir. An in-place processing option seems to complicate and slow down the code, so I left it out: skeletonize_3d(img) always copies once.
Will update the narrative docs in a separate PR.

@ev-br ev-br changed the title 3D skeletonization MRG: 3D skeletonization Feb 5, 2016
* @version 1.0 11/13/2015 (unique BSD licensed version for scikit-image)
* @author Ignacio Arganda-Carreras (iargandacarreras at gmail.com)

Porting to Cython was done by Evgeni Burovski ([email protected]).

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.

Would you mind adding your name to CONTRIBUTORS.txt?

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.

Seconding this. In scikit-image, we keep track of all contributors in CONTRIBUTORS.txt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@stefanv

stefanv commented Feb 6, 2016

Copy link
Copy Markdown
Member

This is excellent work, thank you Evgeni.

I'd like @ahojnnes to look over this before it goes in, but I think it is ready to go.

if img[p, r, c] != 1:
continue

is_border_pt = (curr_border == 1 and img[p, r, c-1] <= 0 or #N

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.

Why <= and not ==?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks! Was just a leftover from semi-automated transition from Java code (and no idea why it is there). Changed.

@soupault

soupault commented Feb 6, 2016

Copy link
Copy Markdown
Member

Thanks @ev-br, I've only left couple of minor comments.

int[::1] lut):
"""Check if a point is Euler invariant.

Calculate Euler characteristc for each octant and sum up.

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.

characteristic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I started thinking "ugh, a text editor plugin for spell checking the comments only would be nice" --- only to discover that my text editor (gedit) does have exactly this plugin. Thanks for nudging me to look for it! Done, here and elsewhere.

@ahojnnes

ahojnnes commented Feb 6, 2016

Copy link
Copy Markdown
Member

I have a few very minor comments. Other than that this looks very good!

I would love to see an example in the gallery for this.

ev-br added 11 commits February 20, 2016 17:29
Remove ad-hoc images from morphology/tests/data folder.
Add a FIJI generated image to skimage/data.

The image was generated via
>>> img = binary_blobs(32, 0.05, n_dim=3, seed=1234)
>>> img = img.astype(np.uint8)*255
>>> img = img[:-2, ...]

then saved as a sequence of png frames, read into FIJI as an image sequence,
and skeletonized via Plugins -> Skeletonize (2D/3D).
* typos in comments
* handle the corner case of width-1 2D image
* vanity
* change up leftover <= to correct ==
Use recommended idioms in the .py wrapper
@ev-br

ev-br commented Feb 20, 2016

Copy link
Copy Markdown
Contributor Author

Rebased.

@ev-br

ev-br commented Feb 20, 2016

Copy link
Copy Markdown
Contributor Author

@ivoflipse I guess extra branches can be at least to some extent taken care of by some postprocessing heuristics. W.r.t. runtime, I believe there are no major bottlenecks left, even though there is definitely room to improve the runtime, possibly quite significantly.

@JDWarner

Copy link
Copy Markdown
Contributor

Mayavi is what I used during my PhD for 3d viz. Today I'd take a hard look at VisPy, which is reaching the point of maturity.

@ivoflipse

Copy link
Copy Markdown
Contributor

Mayavi is just a Pythonic wrapper around VTK, not sure if they already updated to VTK 7 which finally brings Python 3 support. VisPy looks nice, but doesn't aim to support the web.
VTK also offers a lot of functionality for 3D data that doesn't have a nice alternative either. So I'm stuck using it until something better comes around

@stefanv

stefanv commented Feb 20, 2016

Copy link
Copy Markdown
Member

I'm +1 on merging.
On Feb 20, 2016 11:49 AM, "Ivo Flipse" [email protected] wrote:

Mayavi is just a Pythonic wrapper around VTK, not sure if they already
updated to VTK 7 which finally brings Python 3 support. VisPy looks nice,
but doesn't aim to support the web.
VTK also offers a lot of functionality for 3D data that doesn't have a
nice alternative either. So I'm stuck using it until something better comes
around

—
Reply to this email directly or view it on GitHub
#1923 (comment)
.

@jni

jni commented Feb 21, 2016

Copy link
Copy Markdown
Member

@ev-br looks like there's some build issues with the templating in the rebased version...

It got botched sometime around reviewing/merging/rebasing of scikit-imagegh-1924
@ev-br

ev-br commented Feb 22, 2016

Copy link
Copy Markdown
Contributor Author

@jni should be fixed now.

@jni

jni commented Feb 22, 2016

Copy link
Copy Markdown
Member

Sweet! Awesome, thank you for this great addition, @ev-br! =)

jni added a commit that referenced this pull request Feb 22, 2016
MRG: 3D skeletonization
@jni
jni merged commit 1ab275e into scikit-image:master Feb 22, 2016
@stefanv

stefanv commented Feb 23, 2016

Copy link
Copy Markdown
Member

Good stuff, thanks Evgeni!

@ev-br

ev-br commented Feb 25, 2016

Copy link
Copy Markdown
Contributor Author

Fantastic code review -- thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⏩ type: Enhancement Improve existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants