Skip to content

mjirik/skelet3d

Repository files navigation

Build Status Coverage Status

skelet3d

Package is constructed to analyse vessel tree structures. Length, radius and branching angles can be computed. Skeletonization algorithm is based on ITKThinningImageFilter3D. There is dynamic linked library installed by cmake. Python and Matlab scripts call this library.

1D simplified model

Example

Simple example with donut shape

import skelet3d
import numpy as np

# Create donut shape
data = np.ones([3,7,9])
data [:, 3, 3:6] = 0

skelet = skelet3d.skelet3d(data)

print(skelet)

Result:

array([[[0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0]],

        [[0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 1, 1, 1, 1, 1, 0, 0],
        [0, 1, 0, 0, 0, 0, 0, 1, 0],
        [0, 1, 0, 0, 0, 0, 0, 1, 0],
        [0, 1, 0, 0, 0, 0, 0, 1, 0],
        [0, 0, 1, 1, 1, 1, 1, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0]],

        [[0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0]]], dtype=uint8)

For more examples with skeleton analysis or visualisation see example directory

Installation

conda install -c mjirik -c conda-forge skelet3d

Prerequisites

  • Python (2.7, 3.x)
  • CMake
  • ITK
  • Numpy
  • InsightToolkit

Ubuntu

Tested on Ubuntu 12.04, 14.04 and 16.04. Check install notes for more information.

Install prerequisites

sudo apt-get install cmake python-numpy libinsighttoolkit3-dev libpng12-dev libgdcm2-dev python-pip

Install python package

pip install skelet3d

To build .so libraries you will need download skelet3d sources:

cd build
cmake ..
make
make install

Windows

Installation with pip should be enough.

pip install skelet3d

In case of any problems you can download dll or build it.

Manual download and build

Tested on Windows 10 64-bit

  • Install numpy. Recommended is installation with Anaconda

  • Download DLL libraries into directory in environment PATH (e.g. c:\Windows\System32 ) or build it yourself

  • Install skelet3d

      pip install skelet3d
    

Matlab - deprecated

For matlab wrapper run src/compile.m

matlab -nodesktop -nosplash -r "cd src;compile;exit"

Then there is binaryThhinningMex.mexa64 file. It is used by skelet3d.m.

Troubleshooting

Problems with build

In case of any problems You can use binary files and manually copy it into expected paths. BinaryThinningCxxShared library should be in /usr/local/lib on Linux or somewhere in system PATH on windows. Python module skelet3d.py can be used directly.

Cannot find library

libBinaryThinningCxxShared.so: cannot open shared object file: No such file or directory

Probably there is a problem in Ubuntu with LD_LIBRARY_PATH. libBinaryThinningCxxShared.so and ITK libraries are expected to be in LD_LIBRARY_PATH

Solution 1 (for conda)

Download libraries to home directory, unzip and put into correct directory

cd ~
curl -O http://home.zcu.cz/~mjirik/lisa/install/Skelet3D_so.zip
unzip Skelet3D_so.zip
cp Skelet3D_so/* $CONDA_PREFIX/lib/

Solution 2

Download the libraries and set LD_LIBRARY_PATH to new dir

cd ~
curl -O http://home.zcu.cz/~mjirik/lisa/install/Skelet3D_so.zip
unzip Skelet3D_so.zip
export LD_LIBRARY_PATH=$HOME/Skelet3D_so:$LD_LIBRARY_PATH

Solution 3 (Ubuntu)

If you do want to add correct library paths:

echo "include /usr/local/lib" | sudo tee -a /etc/ld.so.conf
sudo ldconfig -v

More information on:

http://bugs.python.org/issue18502

http://ubuntuforums.org/showthread.php?t=1498755

OSError

OSError: /home/.../lib-dynload/../../libBinaryThinningCxxShared.so: undefined symbol: _ZN3itk15ExceptionObject11SetLocationERKSs

WindowsError:[Error193]

You are probably using 32-bit skeleton build with 64-bit python

ld cannot find -lz and -lpng

Problem is probabli in 32-bit compiling in 64-bit system. You need install fallowing packages.

sudo apt-get install lib32z1-dev libpng12-dev

Windows: missing mscvp140.dll and vcruntime140.dll

Install Visual C++ 2015 Redistributable

About

Skeletonize algorithm based on ITKThinningImageFilter3D

Resources

License

Stars

Watchers

Forks

Packages

No packages published