Chapter 1. BrainVISA/Anatomist libraries API documentation

The Cartograph project

The "Soma" (formerly "Cartograph") project includes several C/C++ and Python libraries and commandlines sets, and the two main programs: BrainVISA and Anatomist. You can see it as the whole bundle BrainVisa/Anatomist plus all the programs released in the binary packages. Some of the algorithms are not open source (yet?) but the core libraries and programs are released under the GPL public licence. All components needed for the "environment" part (core libraries, data structures, IO systems, GUI parts including all Anatomist and BrainVISA) are open source. The different public libraries and projects are listed here, and their API is more or less documented using Doxygen and Epydoc automatic documentation software. The aimsalgo project has now been open-sourced in version 3.1.

List of projects

project:language:description:
aimsalgoC++ Image processing algorithms layer based on aimsdata, now open-source since version 3.1.
aimsdataC++ Data types, IO system, miscelaneous manipulation and basic algorithms on: 4D volumes, meshes, textures, "buckets" (voxels lists), graphs, ...
anatomistC++ Visualization: display layers on Aims objects, 3D rendering, GUI, ...
brainvisaPythonProcessing and pipelining infrastructure, GUI, database
brainrat-gplPython Toolbox BrainVISA dedicated to ex-vivo 3D reconstruction and analysis.
cartobaseC++ Base utility classes and functions: files/streams, smart pointers, exceptions, type identifiers, threads, character strings manipulation, generic object, beginning of new IO system, ...
cartodataC++ Future base types and "clean" API that will replace those from AimsData: for instance 3D/4D volumes will move from AimsData to carto::Volume. CartoBase and CartoData will be the core of all new development.
datamindPython/Rstats, data mining. Datamind GUI will still not be released in our distributions in 3.1 packages because it lacks documentation and we don't want to be submerged by questions. But as datamind libraries are now used in other projects, the libraries will be distributed.
ecatC Ecat format IO library, taken from the University of Louvain with a few fixes added.
ecat+CSHFJ layer on top of ecat
fffC/Python/Matlab Math, stats, registration, functional imaging applications
graphC++Graphs and trees
neurospyC/PythonFunctional processing toolbox: fff (fMRI) and HRF port to brainvisa
pyaimsC++/PythonAIMS API bindings for Python
pyaimsalgoC++/PythonPython bindings for AIMS algorithms (still beginning)
pyanatomistC++/PythonAnatomist API bindings for Python
shared  Shared data that are needed by several projects
somaPython Miscelaneous base libraries in python. This project will probably merge with cartobase and its python bindings (part of pyaims) to represent all the low-level or miscelaneous utility libraries in either C++ or python. Soma is also the new generic name for all the core public libraries released in our packages: it will include aims, aimsalgo, and all needed parts (graph, cartodata).
utilsh and Python scriptsCompilation tools
vidaIOCVida format IO library

Dependencies

The following dependecy graph shows which project library is used by other ones (and so shouled be compiled before). The base, lowest-level, of our libraries is CartoBase, and cartobase itself now relies on two external "standard" freeware libraries: libsigc++ and libxml2. Several other external libraries are used by various packages of our software, mainly for GUI and 3D rendering, and also for some IO formats plugins.

sigc++ libxml2 [boost]                           netcdf
    |    |    /                                    |
    |    |   / [blitz++]                           |
    |    |  / /                                    |
   cartobase / shared [vidaIO]  [ecat]  [DCMTK]  [minc]  OpenGL
    |     |  |    |       |       |        |       |       |
  graph cartodata |       |     [ecat+]    |       |       Qt      Python
     \____|_______|_______|________|_______|_______|______/ \______/    |
                              |                                |        |
                            aimsdata ________________         SIP   GSL |
                          /       \                  \      /  |     | /
    ______________aimsalgo   Qwt   anatomist____      pyaims  PyQt  fff
   |    neuron     /   |  \____|___|            \      |    /  |     |
   |         \    /   vip          |             pyanatomist   |  neurospy
   |         sigraph               |                           |
   |   nmr          \              |                           |
   |\____________   [anatomist modules]                        |
   |           | \                   \_________________________|
 bioprocessing | nuclearprocessing                |
              / \                            brainvisa
  connectomist   cortical_surface
Python layers:
soma      aimsdata ___           datamind
    \     |     |     \             :
     \    | anatomist   aimsalgo    :
      \   |     |        |    |     :
      pyaims    |        |  sigraph :
         |   \  |        |    |     :
         | pyanatomist   |    |     :
         |_______________|    |     :
         |               |    |     :
         |         pyaimsalgo |     :
         |____________________|     :
                              |     :
                             pysigraph
[library] are optional parts.
pink components are external freeware software.
grayed components are "private" (closed-source) projects.

As you see there is a number of different projects with quite complex dependencies... Don't panic, the build system manages all this for you.

External libraries

  • libsigc++: signal/slot library and callbacks system
    http://libsigc.sourceforge.net.
    libsigc++ 2.x is needed: 1.x will not work, and 2.0.6 or newer is recommended.
  • libxml2: XML parser library, part of most Unix systems
    http://xmlsoft.org
    A quite recent version of libxml2 is needed
  • OpenGL: 3D graphics - should be part of your system
    http://www.opengl.org
    OpenGL 1.1 or newer will work, but some features of OpenGL 1.2 and 1.3 may be used if available.
  • DCMTK (DICOM Toolkit):
    http://dicom.offis.de/dcmtk.php
    We are using DcmTk 3.5.x.
  • Ecat:
    Ecat format IO library is provided as sources on our ftp site, it is a reorganized version of tools from the University of Louvain (Belgium): http://www.topo.ucl.ac.be/ecat_Clib.html on top of which we made an interface layer to our C++ structures: the ecat+ library. As we made a couple of bugfixes to the original ecat code, changed the include locations and the makefiles system, we suggest to take the sources from our ftp site.
    However this version of Ecat does not compile on Windows. For Windows, please use the official new version of Ecat library which now supports Windows and MinGW.
  • Minc:
    http://www.bic.mni.mcgill.ca/software
    Minc is both a volume image file format, and an image processing library. They are developped in the Montreal Neurological Institute (MNI), McGill University in Montreal. The Minc library needs the netcdf library.
  • NetCDF: Network Common Data Form
    http://www.unidata.ucar.edu/software/netcdf
    machine-independent format for representing array data
  • Qt (user interface):
    http://www.trolltech.com
    Qt 3.x is recommended.
    Qt 2.x is not supported anymore.
    Anatomist may be OK with Qt 2.3.
    Qt 4 is not supported yet in BrainVISA, but Anatomist 3.1 (including python bindings) can now build and run using Qt 4. Porting BrainVISA will still take a little bit of time.
  • Python (script programming, object oriented language):
    http://www.python.org
    See below for versions indications.
  • SIP and PyQt (link between C++/Qt and python):
    http://www.riverbankcomputing.co.uk
    SIP 4.7+ is strongly recommended. 4.5 will allow to compile PyAims and PyAnatomist bindings right now but has bugs which will cause some functions to crash.
  • GSL: Gnu Scientific Library
    http://www.gnu.org/software/gsl
    Numeric, matrix and math library
  • Boost C++
    http://boost.org
    C++ general libraries
    Warning: boost is an optional dependency of cartobase: cartobase will compile and run without it, but some features will be disabled, especially the thread safety in smart pointers, so we very strongly encourage the use boost in cartobase.
  • Blitz++
    http://www.oonumerics.org/blitz
    Object oriented scientific computing library
    Warning: blitz++ is an optional dependency of cartodata: cartodata will compile and run without it, but some features will be disabled, namely the array accessors optimized implementation in Volume classes (expect a factor 5 in performances in this part) and the possibility to support strides, so we strongly encourage the use blitz++ in cartodata.

Compilation instructions

Remarks and prerequisites

Compilers

Some of our C++ libraries fully use the C++ language, including complex templates, but most C++ compilers are buggy. We experienced bugs on every compiler we tried. Up to now only GNU gcc/g++ compilers could build all sources (with appropriate workarounds from place to place in our sources) without crashing or giving inappropriate errors.

We used to provide here a list of compilers which are known not to work, but as we have not recently tried any other compiler than gcc, we have removed this outdated list.

We have tested and successfully compiled the version 3.1 of our software using various gcc 3.x and 4.x versions:

  • gcc 3.2, 3.3, 3.4 and 4.0 and 4.1 should work to compile sources of the pack 3.1.
  • We have not tested the 3.1 sources using older compilers (gcc 3.1 and earlier).
Other versions might work but have not been tested.

Supported platforms

  • Linux. It is our main development system, so everything should compile and run fine on most Linux distributions
  • MacOS 10.4.
    MacOS 10.3 used to be OK but after a system update, Qt could not compile anymore on my laptop. This was several years ago, and my laptop is dead now, so 10.3 will not be supported anymore.
  • Windows XP. We have ported all programs to Windows using the MinGW environment and gcc 3.2 compiler, and the MSys shell (bash unix-like shell). Using cygwin may work too.
    However, either using MinGW or Cygwin, we had to downgrade gcc to 3.2 because the later releases of gcc/windows introduced some linker problems with advanced C++ templates (they say it is not a bug but rather a "known side effect").
  • We used to maintain a Sun/Solaris version but it is currently broken. We don't know if the problem is due to the compiler or to our programs, but as this platform is not widely used anymore and is difficult for us to maintain (because we don't have Sun machines on our desks anymore), repairing this platform is now clearly a waste of time, so it will not be supported anymore.
    Compiling from sources with gcc 3.3 on Solaris 9 ends up with programs that crash, at least if compiled with optilization flags on ("release" mode). They seem to work better in debug mode...
  • Similarly, we used to maintain a SGI/Irix version, but we don't have a working system anymore, so cannot maintain and test this version.
    Compiling from sources on Irix has reasonable chances to work.
  • Other Unix systems have never been tested.

Python language

  • BrainVISA is written in Python language and certainly needs python 2.4 at least. Our binary distributions are shipped with a copy of python 2.4 or 2.5 (depending on the systems) which also includes several add-on modules.
  • Our configuration tools, build-config, configure and maker, are needed to write the Makefiles. They are also written in Python language and also need python 2.0 or newer (or perhaps even 2.3 or 2.4 ?).
  • Python 2 must be the default python unix command to be properly called by our scripts (it must be the fist python command in the path)

Compiling

As we could not manage with the standard building tools ("./configure; make; make install"), as we usually do, we have made our own building tools... They consist in three python programs: build-config, configure and maker.

build-config is the only tool that you need to know about to be able to compile: the two other tools are called by build-config, they must reside within the PATH directories search list but you don't call them directly.

The use of the compilation tools is documented in a dedicated chapter of this documentation. Try the quick start instructions first if you like.