Skip to content

scikit-shapes/scikit-shapes

Repository files navigation

To know more about scikit-shapes, check out the documentation and the gallery of examples

Scikit-Shapes

codecov

Shape processing in Python

Presentation

Scikit-shapes is a python package for the analysis of 2D and 3D shape data. It gathers tools for:

  • Compute features for shapes such as curvature
  • Preprocess shapes with downscaling or landmarks setting
  • Register shapes with or without landmarks
  • Population Analysis : distance matrices

Philosophy

Scikit-shapes is thinked to be intuitive and user-friendly, our am is to provide a library that is

  • Task-oriented: basic objects are high-level tasks, such as Registration or Multiscaling. The mathematical details as loss function, deformation model, are defined as hyperparameters.
  • Modular: workflows can be designed following a plug-and-play approach, allowing comparison across different methods for the same task. In addition, it is possible to implement new modules such as deformation model or loss function and integrate them in existing pipelines.
  • Efficient: skshapes relies mostly on pyTorch and pyKeOps for computations. It allows to speed-up numerical intensive part of the analysis with parallelization on CPU or GPU.

Here is a code snippet illustrating how a registration model is build by combining a loss function and a deformation model:

import skshapes as sks

shape1 = sks.read("data/shape1.vtk")
shape2 = sks.read("data/shape2.vtk")

registration = sks.Registration(
    model=sks.ExtrinsicDeformation(n_steps=5, kernel="gaussian", blur=0.5),
    loss=sks.NearestNeighborLoss(),
    gpu=True,
)

registration.fit(source=shape1, target=shape2)
transformed_shape = registration.transform(source=shape1)

Connection to other open-source projects

Scikit-shapes relies on other open-source software, our main dependencies are :

  • PyTorch and KeOps : skshapes uses pytorch tensors as basic array structure and take benefits of the pytorch ecosystem to let the possibility to accelerate computations on GPU.
  • PyVista and Vedo : skshapes relies on PyVista for data loading and visualization, and on vedo for creating interactive visualization. Skshapes objects are exportable to vedo or pyvista through .to_vedo() and .to_pyvista() methods.
  • Jaxtyping and Beartype : scikit-shapes is a runtime type checked library. Types are documented with annotations and error are raised if a function is called with a wrong argument's type. This prevents silent errors due to common mistakes such as bad numerical type. Our runtime type checking engine is build around Beartype and annotations for numerical arrays are based on Jaxtyping.

Installation

At the moment, scikit-shapes is available on linux and macOS only

From pip

Scikit-shapes version can be installed directly from pip with

pip install skshapes

From source

If you consider contrinuting to the codebase, you can also install scikit-shapes locally from a clone of the repository. On a terminal, navigate to the scikit-shapes directory and run :

pip install .

Then you can :

  • run the pre-commit hooks:
pip install -e requirements_dev.txt
pre-commit install
pre-commit run --all-files
  • run the tests:
pip install -e requirements_dev.txt
pytest
  • build the documentation (and serve it locally)
pip install -r requirement_docs.txt
mkdocs serve

Contributing

We warmly welcome all contribution, if you found a bug, a typo or want to contribute with a new feature, please open an issue.

You can also open a discussion if you have any question regarding the project.

For more information about contributing with new code, see the dedicated section of the documentation.