Axon python API modules

This part of the API is in the Python path, it may be imported without running Brainvisa.

Modules organization

brainvisa.configuration

This module contains the classes that manage BrainVisa set of options, accessible throught the menu BrainVISA -> Preferences.

brainvisa.processing

brainvisa.processing.qt4gui: GUI Modules

The classes related to the graphical user interface are located in qt4gui modules. They use PyQt API, a set of Python bindings for Qt application framework:

Some qtgui modules also exist but are mainly just redirections to the corresponding qt4gui module. It was useful when we maintained the compatibility with qt3 but is no more the case.

Note that the qt4gui modules do work for both Qt4 and Qt5.

brainvisa.shelltools

brainvisa.anatomist: a specialized wrapper for Anatomist

class brainvisa.anatomist.AWindowChoice(noSelectionLabel=None, aslist=False)[source]

Bases: brainvisa.data.neuroData.Choice

A process parameter to choose an Anatomist window. This parameter is a choice between several anatomist windows. By default, if anatomist isn’t started or if there’s no opened windows, the choice offer the possibility to create any type of anatomist window.

If anatomist is started, the set of opened window is added to the choices list.

The list of choices is not updated automatically, to refresh the choices it is necessary to open a new instance of the process.

refreshChoices(*args)[source]

Updates choice list. Adds to default choices curently opened anatomist windows.

brainvisa.toolboxes

class brainvisa.toolboxes.Toolbox(name, toolboxDirectory, icon=None, description=None)[source]

Bases: object

@type name: string @ivar name: toolbox name. It can be the name given in the constructor, or the userName specified in the toolbox .py file. @type id: string @ivar id: identifier for the toolbox. @type processTree: ProcessTree @ivar processTree: content of the toolbox

@type name: string @param name: toolbox name. @type toolboxDirectory: string @param toolboxDirectory: main directory for this toolbox. @type description: string @param description: short text describing the toolbox. It’s optional, it can be set in init file. It will be printed in a tooltip.

Gets the links between this toolbox and other toolboxes reading the minf file of the toolbox (if there is one). Must be called only after having loaded all toolboxes to be sure that all referenced processes are loaded. @rtype: list of ProcessTree @return : links to other toolboxes. each process tree represents another toolbox and contains part of current toolbox that must be added in the other toolbox.

brainvisa.toolboxes.allToolboxes()[source]

@rtype: iterator of Toolbox @return: all loaded toolboxes.

brainvisa.toolboxes.getToolbox(id)[source]

@rtype: Toobox @return: the toolbox whose id is given. The id of a toolbox is its directory name (lowercase) or if it doesn’t have a named directory, the toolbox’s name in lowercase.

brainvisa.toolboxes.readToolboxes(toolboxesDir, homeBrainVISADir)[source]

Search for toolboxes directory in neuroConfig.toolboxesDir (brainvisa/toolboxes) and in brainvisaHomeDir (.brainvisa).

brainvisa.workflow

brainvisa.validation

exception brainvisa.validation.ValidationError[source]

Bases: exceptions.RuntimeError

This class inherits from RuntimeError and defines an exception that will be raised by processes validation functions.

brainvisa.history

class brainvisa.history.HistoricalEvent(uuid=None)[source]

Bases: object

class brainvisa.history.HistoryBook(directory=None, database=None, dirBvsession=None, compression=False)[source]

Bases: object

An L{HistoryBook} contains some L{HistoricalEvent}.

class brainvisa.history.ProcessExecutionEvent(uuid=None, content={})[source]

Bases: brainvisa.history.HistoricalEvent

This object enables to store the state of a Process instance in a dictionary format.

brainvisa.history.sessionId(database)[source]

Manage an id / database in order to give an id for each bvsession.

brainvisa.multipleExecfile

This module defines the class MultipleExecfile that is used to read Brainvisa ontology files.

class brainvisa.multipleExecfile.MultipleExecfile(localDict=None, globalDict=None)[source]

Bases: object

This object enables to execute several python files that can have dependencies between us. One file can include another to indicate that it needs something defined in this other file.

Attributes:
fileExtensions

list of string indicating the possible file extensions for the files that can be executed via this object.

includePath

Set of paths where the files to execute are searched.

globalDict

Global dictionary that will be used to execute the files.

localDict

Local dictionary that will be used to execute the files.

Methods:
execute(*args, **kwargs)[source]

Executes the files listed in args if they are found in the includePath passing globalDict and localDict as global and local namespaces.

kwargs may contain a parameter continue_on_error. If it is True, the execution won’t be stopped by the first exception, the exceptions will be stored in a list and returned at the end of the method.

Returns:The list of exception that occured during files execution.
executedFiles()[source]

Returns the list of executed files.

findFile(localFileName)[source]

Finds the file in includePath trying to append the fileExtensions to its name.

Parameters:localFileName (string) – name of the searched file, possibly wihtout extension, relative to the include path.
Return type:string
Returns:absolute path to the found file, else None.

brainvisa.registration

class brainvisa.registration.DatabasesTransformationManager[source]

Bases: object

TransformationsManager linked with BrainVISA database system.

copyReferential(sourceDiskItem, destinationDiskItem)[source]

Copy the referential of sourceDiskItem to the one of destinationDiskItem. The minf file of destinationDiskItem is saved by this function.

createNewReferential(referential)[source]

Creates the file for the referential diskitem and add it to the database and to the transformation manager.

createNewReferentialFor(diskItem, name=None, description=None, dimension_count=3, referentialType=None, simulation=False, output_diskitem=None)[source]

Create a new referential for an object stored in a DiskItem and record it in the database. Returns None if the referential has not been created because its location in the database cannot be found with ReadDiskItem( ‘Referential’, ‘Referential’ ).findValue( diskItem ).

findOrCreateReferential(referentialType, diskItem, name=None, description=None, dimension_count=3, simulation=False, assign=False, output_diskitem=None)[source]

Search a referential of type referentialType for the data diskitem. if simulation is false, the referential will be created and added to the database and transformation manager. if assign is True, the referential will be assign to the diskitem.

findPaths(source_referential, destination_referential, maxLength=None, bidirectional=False, extensive=True)[source]

Return a generator object that iterate over all the transformation paths going from source_referential to destination_referential. A transformation path is a list of transformation objects. The paths are returned in increasing length order. If maxlength is set to a non null positive value, it limits the size of the paths returned. Source and destination referentials can be given either as string uuid or as referential object.

If extensive is False, not all paths will be searched, and a faster algorithm will be used which may stop when at least one matching path is found. But ambiguous paths will not necessarily be detected.

findReferentialNeighbours(ref, bidirectional=True, flat_output=False)[source]

From one referential, find all referentials directly linked by transforms and return a tuple (referentials, paths), where paths is a dictionary which contains a list of transforms that leads to each referential (key of the dictionary) from the source_referential (a transform is a triplet (uuid_transform, uuid_from, uuid_to))

If flat_output is True, the output is a list of tuples (transform, source, dest).

referential(diskItemOrId)[source]

Return the referential object corresponding to the given diskItem or uuid. Return None if the diskItem has no referential or the referential is not in the manager.

removeReferential(db, diskItem, uuid, eraseFiles=False)[source]

Test if there is no transformation with uuid then remove the diskItem

setReferentialTo(diskItem, referential)[source]

Assign to the given diskItem the given referential (as Referential object or uuid)