Chapter 9. Programming with Anatomist in Python language

Table of Contents

Description of the API
Implementation
Using the API
Run Anatomist
Load an object
View an object
Windows block
Move the cursor
Camera
View header information
Change the color palette
View meshes
Superimposing
Change mesh material
Fusion between 2 volumes
Load a transformation
Load an existing referential
Load referential information from file header
Display a ROI graph
Sending a command to Anatomist
Using direct implementation

Anatomist is written in C++ language but has also a python API: PyAnatomist. This python API enables to drive Anatomist application through python scripts : using Anatomist, loading volumes, meshes, graphs, viewing them in windows, merging objects, changing color palettes, etc... It can be useful in order to automate a repetitive visualization task or to add features to Anatomist application by developping a python plugin, which is much more easier than developping directly in Anatomist C++ library. Actually, several features in Anatomist have been added via a python plugin like the gradient palette for example. The python API is also used by several viewers in BrainVISA.

Description of the API

The main entry point is the Anatomist class which must be instantiated before any operation can be performed. It represents Anatomist application. This class contains a number of nested classes: AObject, AWindow... that represent the elements of Anatomist application.

The entry point of this API is the module anatomist.api, you can import it as below :

import anatomist.api as anatomist

And then create an instance of Anatomist :

a=anatomist.Anatomist()

So you can send commands to Anatomist application, for example creating a window :

window=a.createWindow('3D')