Chapter 5. PyAnatomist

API to access Anatomist with python scripts.

Includes Anatomist C++ API bindings.

API

Libraries

  • libpyanatomist

Main features

  • See the Sphinx documentation
  • Enables two means of communication with Anatomist application : exchanging messages on socket or using C++ API bindings
  • Allows access to Anatomist API and manipulation of Anatomist objects and state from python scripts and shells
  • Allows to write Anatomist plugins in python

Required environment variables

  • BRAINVISA_SHARE
  • PYTHONPATH

Tutorial and examples

See the programming part of Anatomist tutorial.

To execute these examples, use "ipython -q4thread" (They need that a QT event loop is running). And then, "%run <example>.py.

See the examples in the following order:

More advanced examples:
  • sphere.py: subclassing Anatomist objects
  • ellipsoid.py: Updating the size and shape of an object interactively.
  • control.py: plugging new conrols / actions in Anatomist views
  • addMenuEntry.py: customizing object-specific menus
  • fusion.py: registering new fusion types
  • customopenglobject.py: customizing OpenGl parameters for objects.
  • texturedrawing.py: drawing ROI on a mesh in a texture.
  • volumeMeasures.py: Complete example with a specific graphical interface that embeds an Anatomist window and a matplot lib widget. Shows a 4D volume and a curve of the values in a selected voxel or the mean of values in a selected region.
  • anaevensimplerviewer.py, which is as its name says, an even simplified of the anasimpleviewer application, which may also be used as a programming example. Its code is in the "bin/"" directory of the binary packages.
Using anatomist API in Brainvisa processes:

Figure 5.1. Volume Measures Example

Volume Measures Example

Figure 5.2. Ana Even Simpler Viewer Example

Volume Measures Example