Axon python API modules¶
This part of the API is in the Python path, it may be imported without running Brainvisa.
Modules organization¶
brainvisa.axon
: loading Brainvisa in a Python script.brainvisa.processes
: classes about processes and pipelines.brainvisa.anatomist
: specialization of pyanatomist API for Brainvisa. Used by most of Brainvisa viewers.brainvisa.toolboxes
: Toolbox class representing a BrainVISA toolbox.brainvisa.shelltools
: functions to copy, move, delete files.brainvisa.workflow
: Conversion of a Process into a Workflow usable in Soma-workflow.brainvisa.validation
: Definition of an exception that can be raised by processes validation functions.brainvisa.history
: Framework to manage history of processes.brainvisa.multipleExecfile
: A class to load several inter-dependent python files.brainvisa.registration
: referentials and transformations management.
brainvisa.configuration¶
This module contains the classes that manage BrainVisa set of options, accessible throught the menu BrainVISA -> Preferences.
brainvisa.configuration.api
: Initialization of the configuration object that contains the user preferences.brainvisa.configuration.neuroConfig
: global variables describing configuration parameters and user preferences.brainvisa.configuration.anatomist_configuration
: options about Anatomist.brainvisa.configuration.brainvisa_configuration
: general options.brainvisa.configuration.databases_configuration
: options about the databases.brainvisa.configuration.fsl_configuration
: options about FSL.brainvisa.configuration.matlab_configuration
: options about Matlab.brainvisa.configuration.spm_configuration
: options about SPM.brainvisa.configuration.r_configuration
: options about R.brainvisa.configuration.qt4gui
: specific graphical user interface for options about databases and Matlab.brainvisa.configuration.soma_workflow_configuration
: Soma-Workflow-related configbrainvisa.configuration.qt4gui.neuroConfigGUI
: Bug report dialog.
brainvisa.data¶
brainvisa.data.neuroData
: classes defining the signature of a process, parameter types.brainvisa.data.neuroDiskItems
: class DiskItem that defines data and matching files.brainvisa.data.neuroHierarchy
: databases creation and initialization.brainvisa.data.fileSystemOntology
: classes to define a BrainVISA ontology.brainvisa.data.ftpDirectory
brainvisa.data.minfExtensions
: declaration of the type of objects that can be written in minf format.brainvisa.data.virtualDirectory
brainvisa.processing¶
brainvisa.processing.axon_fso_to_fom
: convert Axon File System Organization (hierarchies) to CAPSUL File Orgnaization Models.brainvisa.processing.axon_to_capsul
: convert Axon processes and pipelines CAPSUL processes or pipelines.brainvisa.processing.capsul_process
: wrapper class to make a CAPSUL process or pipeline available as an Axon process.brainvisa.processing.neuroException
: classes and functions defining error and warning messages.brainvisa.processing.neuroLog
: creation of BrainVISA log file.brainvisa.processing.process_based_viewer
: specialized viewer process, which works with a process or pipeline to get its parameters
brainvisa.tools¶
brainvisa.tools.aimsGlobals
: definition of named lists of formats.brainvisa.tools.mainthreadlife
: ensure an object is deleted in the main thread.brainvisa.tools.matlabValidation
: validation function that checks if matlab is enabled.
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:
brainvisa.processing.qtgui.backwardCompatibleQt
: it has been used to keep backward compatibility with old versions of PyQt.
brainvisa.processing.qt4gui.neuroProcessesGUI
: BrainVISA main window and processes windows.
brainvisa.processing.qt4gui.neuroExceptionGUI
: Error and warning messages window.
brainvisa.processing.qt4gui.neuroLogGUI
: Log window.
brainvisa.processing.qt4gui.command
: class CommandWithQProcess used to call commands in Brainvisa processes. This module is not related to the graphical user interface but it uses Qt, that’s why it is inqt4gui
module.
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.data.qt4gui: GUI Modules¶
brainvisa.data.qt4gui.neuroDataGUI
: Editor windows for the parameter types defined inbrainvisa.data.neuroData
.
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.
- Parameters
args (list) – list of possible value, each value can be a string or a tuple.
- class brainvisa.anatomist.Anatomist(*args, **kwargs)[source]¶
Bases:
anatomist.threaded.api.Anatomist
The __init__ method of
Singleton
derived class should do nothing. Derived classes must define__singleton_init__()
instead of __init__.- close(**kwargs)¶
Exits Anatomist application. if anatomist is closed, the singleton instance is deleted. So next time the constructor is called, a new instance will be created.
- createReferential(**kwargs)¶
Creates a new referential using the informations in the file.
- Parameters
fileref (string or Diskitem) – name or diskitem of a file (minf file, extension .referential) containing informations about the referential : its name and uuid
- Returns
Referential
- Return type
the newly created referential
- createWindow(**kwargs)¶
Creates a new window and opens it.
- Parameters
wintype (str) – Type of window to open (
"Axial"
,"Sagittal"
,"Coronal"
,"3D"
,"Browser"
,"Profile"
, …)geometry (int vector) – Position on screen and size of the new window (x, y, w, h)
block (
AWindowsBlock
or QWidget) – A parent block in which the new window must be added. In Anatomist 4.6.2 and later, the block may be a regular QWidget (this is only OK in direct implementation mode)no_decoration (bool) – Indicates if decorations (menus, buttons) can be painted around the view.
options (dict) – Internal advanced options.
- Returns
window – The newly created window
- Return type
AWindow
- createWindowsBlock(**kwargs)¶
Creates a window containing other windows.
An id is reserved for that block but the bound object isn’t created. It will be created first time a window is added to the block with createWindow method.
- Parameters
- Returns
block – A window which can contain several
AWindow
- Return type
AWindowsBlock
- loadObject(**kwargs)¶
Loads an object from a file (volume, mesh, graph, texture…)
- Parameters
fileref (string or Diskitem) – name of the file that contains the object to load or a Diskitem representing this file.
objectName (string) – object name
restrict_object_types (dictionary) – object -> accpepted types list. Ex:
{'Volume' : ['S16', 'FLOAT']}
forceReload (boolean) – if True the object will be loaded even if it is already loaded in Anatomist. Otherwise, the already loaded one is returned.
loadReferential (boolean) – if True, use brainvisa database informations to search referential and transformations associated to this object and load them.
- Returns
AObject
- Return type
the loaded object
- loadTransformations(**kwargs)¶
Search and load transformations between this referential and spm referential.
- Parameters
referential (Referential) – the referential for which searching transformations
- log(**kwargs)¶
This method is redefined to print logs in brainvisa log system.
- logEvent(**kwargs)¶
Log an event received from anatomist application.
- Parameters
event (string) – event name
params (string) – event parameters
- viewBias(**kwargs)¶
Loads an image, opens it in a new window in the object’s referential. A palette is assigned to the object (Rainbow2) in order to see the bias.
- Parameters
fileRef (string or ReadDiskItem) – file name for the bias corrected image
forceReload (boolean) – if True, the image is reloaded if already in memory.
wintype (string) – “Axial”, “Coronal”, “Sagittal”, “3D” (or other)
hanfile (string or ReadDiskItem) – optional file name for histogram analysis file. If present it will be used to set palette bounds.
parent (QWidget or anatomist block) – parent widget or block
- viewMaskOnMRI(**kwargs)¶
Fusions an irm image with a mask. A palette is associated to the mask to highlight it in the fusion. Fusion method is Fusion2DMethod. Resulting image is opened in a new window.
- Parameters
mriFile (Diskitem or string) – file containing the mri image
maskFile (Diskitem or string) – file containing the mask to apply
palette (APalette) – palette to use for the mask
mode (string) – mix color mode (geometric, linear, replace, decal, blend, add or combine)
rate (float) – mix rate in linear mode
wintype (string) – type of window to open
- viewMesh(**kwargs)¶
Loads a mesh and opens it in a 3D window. The window is assigned the object’s referential.
- viewObject(**kwargs)¶
Loads the image in anatomist, opens it in a new window and assigns the image’s referential to the window.
- Parameters
fileRef (string or DiskItem) – filename of the image to load.
- Returns
- Return type
dictionary
{"object" : the loaded object, "window" : the new window, "file" : the readed file}
- viewTextureOnMesh(**kwargs)¶
Load a mesh file and apply the texture with the palette
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.
- links()[source]¶
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.workflow¶
brainvisa.validation¶
- exception brainvisa.validation.ValidationError[source]¶
Bases:
RuntimeError
This class inherits from
RuntimeError
and defines an exception that will be raised by processes validation functions.
brainvisa.history¶
- 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.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
passingglobalDict
andlocalDict
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.
- findFile(localFileName)[source]¶
Finds the file in
includePath
trying to append thefileExtensions
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, copy_transformations=True)[source]¶
Copy the referential of sourceDiskItem to the one of destinationDiskItem. The minf file of destinationDiskItem is saved by this function.
- Parameters
- 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.