LarSurf.jl

Import 3D structures to LARLIB
Author mjirik
Popularity
3 Stars
Updated Last
4 Years Ago
Started In
September 2017

LarSurf.jl

Build Status Coveralls

Package for surface extraction using Linear Algebraic Representation theory by Alberto Paoluzzi. See original Julia repository for more details.

Install

] add https://github.com/mjirik/LarSurf.jl

Install extra

The package is prepared for pure Julia however for reading various file formats and the visualization we use additional packages.

Read 3D data support

To read the Computed Tomography data in DICOM and other formats we use Pio3d.jl package. This package is wrapper for python io3d.

Install python packages with conda

conda install -c simpleitk -c mjirik -c conda-forge io3d simpleitk pandas

Run Julia and install wrappers for python packages:

ENV["PYTHON"] = strip(split(read(`$((Sys.iswindows() ? "where" : "which")) python`, String), "\n")[1])
using Pkg; Pkg.add("PyCall") ; Pkg.build("PyCall")
] add Pandas
] add https://github.com/mjirik/Pio3d.jl

using Pandas, Pio3d

Visualization tools

ViewerGL can be used to perform the visualization.

] add http://github.com/cvdlab/LinearAlgebraicRepresentation.jl#julia-1.0
] add http://github.com/cvdlab/ViewerGL.jl

There might be some problems with DataStructures package version or with the Triangle build.

For developers

] develop https://github.com/mjirik/LarSurf.jl

Examples

Truncated sphere example

Do the surface extraction on simple shape. Source code

using ViewerGL
using Distributed
addprocs(3)
using LarSurf

block_size = [20, 20, 20]
LarSurf.lsp_setup(block_size)

segmentation = LarSurf.generate_truncated_sphere(10)
V, FV = LarSurf.lsp_get_surface(segmentation)
FVtri = LarSurf.triangulate_quads(FV)

Vs = LarSurf.Smoothing.smoothing_FV_taubin(V, FV, 0.4, -0.3, 50)

ViewerGL.VIEW([
  ViewerGL.GLGrid(Vs,FVtri,ViewerGL.Point4d(1,1,1,0.1))
  ViewerGL.GLAxis(ViewerGL.Point3d(-1,-1,-1),ViewerGL.Point3d(1,1,1))
])

objlines = LarSurf.Lar.lar2obj(Vs, FVtri, "tetris_tri_taubin.obj")

tetris

Tetris example

Do the surface extraction on simple shape. Source code

using ViewerGL
using Distributed
if nprocs() == 1
    addprocs(3)
	@info "adding 3 more CPUs"
end
using Logging
using SparseArrays
@everywhere using LarSurf

block_size = [2, 2, 2]
segmentation = LarSurf.tetris_brick()
LarSurf.lsp_setup(block_size)
larmodel = LarSurf.lsp_get_surface(segmentation)
V, FV = larmodel
FVtri = LarSurf.triangulate_quads(FV)
objlines = LarSurf.Lar.lar2obj(V, FVtri, "tetris_tri.obj")

ViewerGL.VIEW([
  ViewerGL.GLGrid(V,FVtri,ViewerGL.Point4d(1,1,1,0.1))
  ViewerGL.GLAxis(ViewerGL.Point3d(-1,-1,-1),ViewerGL.Point3d(1,1,1))
])

tetris

Vs = LarSurf.Smoothing.smoothing_FV_taubin(V, FV, 0.4, -0.2, 2)

ViewerGL.VIEW([
    ViewerGL.GLGrid(Vs,FVtri,ViewerGL.Point4d(1,1,1,0.1))
	ViewerGL.GLAxis(ViewerGL.Point3d(-1,-1,-1),ViewerGL.Point3d(1,1,1))
])

objlines = LarSurf.Lar.lar2obj(V, FVtri, "tetris_tri_taubin.obj")

tetris

Corrosion cast experiment in pure Julia

Run experiment with corrosion cast data. Measure all statistics.

Data can be downloaded here

julia experiments\surface_extraction_parallel.jl --crop 50 -i nrn10.jld2 --show

tetris

To have more information about options use

julia experiments\surface_extraction_parallel.jl --help

Corrosion cast example with PyCall

Data can be downloaded here

julia experiments\surface_extraction_parallel.jl --crop 100 -i nrn10.pklz --show

Liver extraction experiment

Run experiment with extraction of CT data. Measure all statistics.

Get data

We are using dataset 3D-IRCADb 01 | IRCAD France.

using Pio3d
Pio3d.datasets_download("3Dircadb1.1")
datap = Pio3d.read3d(Pio3d.datasets_join_path("medical/orig/sample-data/nrn4.pklz"))

Data can be also manually downloaded from dataset website

Run experiment

Due to long run time the experiment is divided into smaller parts. The extracted data are stored into .jld2 files.

All measured times are recorded into .csv file (exp_surface_extraction_ircad_times.csv)

smooth liver

Get 3D model of portal vein

julia experiments\surface_extraction_parallel.jl -d medical/orig/3Dircadb1.1/MASKS_DICOM/portalvein --show --taubin_n 10 --taubin_lambda 0.5 --taubin_mu -0.2 --n_procs 4 --threshold 0 --color 1. 1. 0. 1.0

Convert volumetric data to jld2 data

julia experiments\to_jld2.jl -i "..\..\..\lisa_data\nrn10.pklz"

Troubleshooting

PyCall

Problems with install are often caused by PyCall package heck the python path

which python

DataStructures version problem

There can be some problem with DataStructures package version. It is caused by ViewerGl. It require DataStructures with version 0.15.0 only. You will probably need to remove JLD2 package and then install DataStructures again.

] remove ExSup
] remove JLD2
] remove DataStructures
] add DataStructures@0.15.0
] add ExSup

Missing nmake

On windows you will need Windows SDK. Then you need to start julia in x64 Native Tools Command Prompt for VS 2017 and build the package.

] add Triangle
] build Triangle

Then you can start julia from cmd.

Used By Packages

No packages found.