seung-lab / kimimaro

Skeletonize densely labeled 3D image segmentations with TEASAR. (Medial Axis Transform)
GNU General Public License v3.0
136 stars 23 forks source link

Skeleton Has Local Hollow for Stochastic Structure #30

Closed Hailey-Liu closed 5 years ago

Hailey-Liu commented 5 years ago

Hello kimimaro users,

I am very new to kimimaro. I am trying to use the kimimaro.skeletonize() to skeletonize my stochastic structure. I didn't specify any of theteasar_params and it returns the skeleton with hollow inside, as the screenshot showed. I tried to tune scale and const, but it still not solve the issue. Could I have some suggestions from you? Screen Shot 2019-08-13 at 5 20 19 PM

william-silversmith commented 5 years ago

Hi HaominIsMe!

I think this is a bit difficult to answer without seeing a representation of the space you are trying to skeletonize. Can you post what scale and const values you tried? Is your data isotropic (meaning all axes have the same dimension)?

Thanks! Will

william-silversmith commented 5 years ago

Also, if you haven't seen them, check out these tutorials that might help you understand what's going on:

https://github.com/seung-lab/kimimaro/wiki/Intuition-for-Setting-Parameters-const-and-scale https://github.com/seung-lab/kimimaro/wiki/A-Pictorial-Guide-to-TEASAR-Skeletonization

Hailey-Liu commented 5 years ago

The space is generated with small shape(64, 64, 64), and I would like to skeleton the voxels with label 1. I check the tutorials explaining scale and const, which I set scale=10, const=0 based on my understanding. Here is how I did:

import kimimaro
labels = np.load('structure.npy')
labels = labels.astype(int)
skels = kimimaro.skeletonize(
  labels, 
  teasar_params={
    'scale': 10,
    'const': 0, # physical units
    }
)

Please unzip the attachment for the structure file. structure.npy.zip

william-silversmith commented 5 years ago

Thanks for the data, that's very helpful!

I ran the following code and got this output:

import numpy as np 
from cloudvolume import * 
import kimimaro

img = np.load('structure.npy')
img = img.astype(np.uint8)

skels = kimimaro.skeletonize(
  img, 
  teasar_params={
    'scale': 1.5,
    'const': 3,
  },
  anisotropy=(1,1,1),
  fix_branching=True,
  fix_borders=True,
)

skels[1].viewer()

Is this more what you're looking for?

image

william-silversmith commented 5 years ago

You can also visualize your data a bit better like this:

from cloudvolume import view
import numpy as np

img = img.astype(np.bool)
view(img)
Hailey-Liu commented 5 years ago

Hi @william-silversmith

Yes. This is exactly what I am looking for. Thanks for your help.

william-silversmith commented 5 years ago

Awesome! Glad I could help.