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.
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
conda install -c mjirik -c conda-forge skelet3d
- Python (2.7, 3.x)
- CMake
- ITK
- Numpy
- InsightToolkit
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
Installation with pip
should be enough.
pip install skelet3d
In case of any problems you can download dll or build it.
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
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.
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.
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
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/
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
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: /home/.../lib-dynload/../../libBinaryThinningCxxShared.so: undefined symbol: _ZN3itk15ExceptionObject11SetLocationERKSs
You are probably using 32-bit skeleton build with 64-bit python
Problem is probabli in 32-bit compiling in 64-bit system. You need install fallowing packages.
sudo apt-get install lib32z1-dev libpng12-dev
Install Visual C++ 2015 Redistributable