Thread-safe implementation of the direct bindings

This module is an implementation of general interface anatomist.base. It is based on direct implementation (bindings of C++ Anatomist api) with adding thread-safe layer.

This implementation can be used in multi-threaded application. To load it, you can do :

>>> import anatomist
>>> anatomist.setDefaultImplementation(anatomist.THREADED)
>>> import anatomist.api as anatomist

or without changing default implementation :

>>> import anatomist.threaded.api as anatomist

This module redefines the Anatomist class from the direct implementation Anatomist class to make all methods execute in the main thread (qt thread). It uses methods of anatomist.threadedimpl.

Note that this thread-safe implementation is not actually multi-threaded: all calls to the Anatomist API are stacked for execution in the same thread, so it is actually a single-thread execution, but calls can be performed from various threads in a multi-threaded program, avoiding race conditions (provided the calling thread has not locked the main thread in any way).

All classes in the anatomist module are made thread-safe.

Objects returned by calls to the thread-safe API

Generally, objects created (or just returned) by calls to the Anatomist thread-safe API belong to the main thread. This means that they must be used, and importantly, destroyed, within the main thread.

Using objects

When returned objects are classes from the Anatomist API, they are subclasses of the thread-safe API, and are already made thread-safe when used.

When objects do not belong to the Anatomist API, like Qt widgets, then caution must be taken to use them from the main GUI thread only. You can use soma.qt_gui.qtThread.QtThreadCall to do so.

Destroying objects

Destruction of objects in python is somewhat tricky: when a variable is deleted, a reference to it is decremented, and when the last reference is dropped, the object is actually destroyed, indeed from the thread removing this last reference. If several threads hold a reference to a given object, who will actually delete it ? If a sensible (non-thread-safe) object is deleted within the wrong thread, program crashes may occur.

To manage this problem we use wrapper objects which will delegate the destruction of objects they contain to the main thread: soma.qt_gui.qtThread.MainThreadLife.

AItem subclasses in the threaded implementation (including AObject, AWindow etc) are already subclasses of MainThreadLife.

class anatomist.threaded.api.Anatomist(*args, **kwargs)[source]

The __init__ method of Singleton derived class should do nothing. Derived classes must define __singleton_init__() instead of __init__.

class AGraph(*args, **kwargs)

If internal rep is given as parameter, the corresponding anatomist object already exists: take a reference on it (to prevent its deletion).

addInWindows(**kwargs)

Adds the object in windows. Windows must already exist.

Parameters
  • windows (list of Anatomist.AWindow) – List of windows in which the object must be added

  • temporary (bool (optional)) – temporary object do not affect the view boundaries and camera settings

  • position (int (optional)) – insert objects as this order number

applyBuiltinReferential(**kwargs)

Extract information about referential and transformations from the header of the object and assign the found referential.

assignReferential(**kwargs)

Assign a referential to object. The referential must exist. To create a new Referential, execute createReferential, to assign the central referential, first get it with Anatomist.centralRef attribute.

Parameters

referential (Referential) – The referential to be assigned to the object

createNode(**kwargs)

Creates a new node with optionally an empty bucket inside and adds it in the graph.

Parameters
  • name (str) – node name. default is RoiArg.

  • syntax (str) – node syntax attribute. default is roi.

  • with_bucket (bool) – if True, creates an empty bucket in the node and returns it with the node. default is None, so the bucket is created but not returned

  • duplicate (bool) – enables duplication of nodes with the same name attribute.

Returns

node_def – (the created node, the created bucket) or only the created node if with_bucket is False

Return type

(AObject, AObject)

delete(**kwargs)

Deletes object

exportTexture(**kwargs)

Saves the texture of an object to a file

Parameters
  • filename (str) – File in which the texture must be written

  • time (float) – For temporal objects, if this parameter is mentionned the texture will be extracted at this time. if not mentionned, all times will be extracted and the texture will be a temporal object.

extractTexture(**kwargs)

Extract the object texture to create a new texture object.

Parameters

time (float) – For temporal objects, if this parameter is mentionned the texture will be extracted at this time. if not mentionned, All times will be extracted and the texture will be a temporal object. In socket implementation, it is necessary to get a new id for the texture object and to pass it to the command.

Returns

texture – The newly created texture object

Return type

AObject

generateTexture(**kwargs)

Generates an empty texture (value 0 everywhere) for a mesh object.

Parameters

dimension (int) – Texture dimension (1 or 2)

Returns

texture – The newly created texture object

Return type

AObject

getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

getWindows(**kwargs)

Gets windows that contain this object.

Returns

windows – Open windows that contain this object.

Return type

list of Anatomist.AWindow

loadReferentialFromHeader(**kwargs)

Extract information about referential and transformations from the header of the object and assign the found referential.

notifyObservers(**kwargs)

Update the observers views on the object (windows, or fusion objects etc will be re-calculated as needed)

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

reload(**kwargs)

Reload this object already in memory reading its file.

removeFromWindows(**kwargs)

Removes object from windows.

Parameters

windows (list of Anatomist.AWindow) – List of windows from which the object must be removed

save(**kwargs)

Saves object in a file.

Parameters

filename (str) – File in which the object will be written. If not mentionned, the object is saved in the file from which it has been loaded.

setChanged(**kwargs)

Mark the current object as changed, so that a view update will take it into account.

setMaterial(**kwargs)

Changes object material properties.

Parameters
  • material (Material) – Material characteristics, including render properties. The material may be specified as a Material object, or as its various properties (ambient, diffuse, etc.). If both a material parameter and other properties are specified, the material is used as a base, and properties are used to modify it

  • refresh (bool) – If True, force windows refreshing

  • ambient (list) – RGB[A] vector: float values between 0 and 1.

  • diffuse (list) – RGB[A] vector: float values between 0 and 1. This parameter corresponds to the “standard” notion of color

  • emission (list) – RGB[A] vector: float values between 0 and 1.

  • specular (list) – RGB[A] vector: float values between 0 and 1.

  • shininess (float) – 0-124

  • lighting (int) – enables (1) or disables (0) objects lighting/shading. Setting this value to -1 goes back to the default mode (globally set at the view/scene level).

  • smooth_shading (int) – (tristate: 0/1/-1) smooth or flat polygons mode

  • polygon_filtering (int) – (tristate: 0/1/-1) filtering (antialiasing) of lines/polygons

  • depth_buffer (int) – (tristate: 0/1/-1) enables/disables writing in the Z-buffer. You can disable it if you want to click “through” an object (but it may have strange effects on the rendering)

  • face_culling (int) – (tristate: 0/1/-1) don’t draw polygons seen from the back side. The best is to enable it for transparent objects, and to disable it for “open” (on which both sides may be seen) and opaque meshes. For objects both open and transparent, there is no perfoect setting…

  • polygon_mode (string) – polygons rendering mode: “normal”, “wireframe”, “outline” (normal + wireframe), “hiddenface_wireframe” (wireframe with hidden faces), “default” (use the global view settings), “ext_outlined” (thickened external boundaries + normal rendering).

  • unlit_color (RGB[A] vector: float values between 0 and 1.) – color used for lines when lighting is off. For now it only affects polygons boundaries in “outlined” or “ext_outlined” polygon modes.

  • line_width (float) – Lines thickness (meshes, segments, wireframe rendering modes). A null or negative value fallsback to default (1 in principle).

  • front_face (string) – Specifies if the mesh(es) polygons external face is the clockwise or counterclockwise side. Normally in Aims/Anatomist indirect referentials, polygons are in clockwise orientation. Values are “clockwise”, “counterclockwise”, or “neutral” (the default).

  • selectable_mode (string) –

    New in Anatomist 4.5. Replaces the ghost property.

    always_selectable:

    object is selecatble whatever its opacity.

    ghost:

    object is not selectable.

    selectable_when_opaque:

    object is selectable when totally opaque (this is the default in Anatomist).

    selectable_when_not_totally_transparent:

    object is selectable unless opacity is zero.

  • use_shader (int) – enable or disable the use of OpenGL shaders for this object.

  • shader_color_normals (int) – when shaders are enabled, normals can be represented as colors on the object.

  • normal_is_direction (int) – when shaders are enabled and shader_color_normals is set, normals may be pre-calculates as mesh direction, on a “line” mesh (polygons are lines, not triangles).

setPalette(**kwargs)

Assign a palette to object, or change its characteristics (scaling etc).

Parameters
  • palette (Anatomist.APalette or str (name)) – Principal palette to apply

  • minVal (float) – Minimum object texture value mapped to the lower bound of the palette, by default in relative proportional mode.

  • maxVal (float) –

    Minimum object texture value mapped to the lower bound of the palette.

    By default minVal, maxVal, minVal2 and maxVal2 are relative values expressed in proportion of object texture extrema: [0-1] corresponds to the whole object dynamics. If absoluteMode is True, then values are in object texture values space. The range [minVal-maxVal] is mapped to the while palette, thus any value below or over these extrema will get the first or last (resp.) color of the palette. Values outside [0-1] may be used, meaning that not all the palette colors range will be mapped to the texture values.

  • palette2 (APalette) – Second palette, for 2D textures

  • minVal2 (float (0 - 1)) – Second palette value to affect to object texture second component min value

  • maxVal2 (float (0 - 1)) – Second palette value to assign to object texture second component max value

  • mixMethod (string) – Method to mix two palettes in a 2D palette: linear or geometric

  • linMixFactor (float) – mix factor for the linear method

  • palette1Dmapping (string) – way of using 2D palette for 1D texture : FirstLine or Diagonal

  • absoluteMode (bool) – if True, min/max values are supposed to be absolute values (in regard to objects texture) rather than proportions

  • zeroCentered1 (bool) – min/max should be updated to keep absolute value 0 at the center of the palette (for palette 1).

  • zeroCentered2 (bool) – min/max should be updated to keep absolute value 0 at the center of the palette (for palette 2).

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

toAimsObject(**kwargs)

Converts AObject to aims object.

class AItem(*args, **kwargs)
getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

class AObject(*args, **kwargs)

If internal rep is given as parameter, the corresponding anatomist object already exists: take a reference on it (to prevent its deletion).

addInWindows(**kwargs)

Adds the object in windows. Windows must already exist.

Parameters
  • windows (list of Anatomist.AWindow) – List of windows in which the object must be added

  • temporary (bool (optional)) – temporary object do not affect the view boundaries and camera settings

  • position (int (optional)) – insert objects as this order number

applyBuiltinReferential(**kwargs)

Extract information about referential and transformations from the header of the object and assign the found referential.

assignReferential(**kwargs)

Assign a referential to object. The referential must exist. To create a new Referential, execute createReferential, to assign the central referential, first get it with Anatomist.centralRef attribute.

Parameters

referential (Referential) – The referential to be assigned to the object

delete(**kwargs)

Deletes object

exportTexture(**kwargs)

Saves the texture of an object to a file

Parameters
  • filename (str) – File in which the texture must be written

  • time (float) – For temporal objects, if this parameter is mentionned the texture will be extracted at this time. if not mentionned, all times will be extracted and the texture will be a temporal object.

extractTexture(**kwargs)

Extract the object texture to create a new texture object.

Parameters

time (float) – For temporal objects, if this parameter is mentionned the texture will be extracted at this time. if not mentionned, All times will be extracted and the texture will be a temporal object. In socket implementation, it is necessary to get a new id for the texture object and to pass it to the command.

Returns

texture – The newly created texture object

Return type

AObject

generateTexture(**kwargs)

Generates an empty texture (value 0 everywhere) for a mesh object.

Parameters

dimension (int) – Texture dimension (1 or 2)

Returns

texture – The newly created texture object

Return type

AObject

getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

getWindows(**kwargs)

Gets windows that contain this object.

Returns

windows – Open windows that contain this object.

Return type

list of Anatomist.AWindow

loadReferentialFromHeader(**kwargs)

Extract information about referential and transformations from the header of the object and assign the found referential.

notifyObservers(**kwargs)

Update the observers views on the object (windows, or fusion objects etc will be re-calculated as needed)

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

reload(**kwargs)

Reload this object already in memory reading its file.

removeFromWindows(**kwargs)

Removes object from windows.

Parameters

windows (list of Anatomist.AWindow) – List of windows from which the object must be removed

save(**kwargs)

Saves object in a file.

Parameters

filename (str) – File in which the object will be written. If not mentionned, the object is saved in the file from which it has been loaded.

setChanged(**kwargs)

Mark the current object as changed, so that a view update will take it into account.

setMaterial(**kwargs)

Changes object material properties.

Parameters
  • material (Material) – Material characteristics, including render properties. The material may be specified as a Material object, or as its various properties (ambient, diffuse, etc.). If both a material parameter and other properties are specified, the material is used as a base, and properties are used to modify it

  • refresh (bool) – If True, force windows refreshing

  • ambient (list) – RGB[A] vector: float values between 0 and 1.

  • diffuse (list) – RGB[A] vector: float values between 0 and 1. This parameter corresponds to the “standard” notion of color

  • emission (list) – RGB[A] vector: float values between 0 and 1.

  • specular (list) – RGB[A] vector: float values between 0 and 1.

  • shininess (float) – 0-124

  • lighting (int) – enables (1) or disables (0) objects lighting/shading. Setting this value to -1 goes back to the default mode (globally set at the view/scene level).

  • smooth_shading (int) – (tristate: 0/1/-1) smooth or flat polygons mode

  • polygon_filtering (int) – (tristate: 0/1/-1) filtering (antialiasing) of lines/polygons

  • depth_buffer (int) – (tristate: 0/1/-1) enables/disables writing in the Z-buffer. You can disable it if you want to click “through” an object (but it may have strange effects on the rendering)

  • face_culling (int) – (tristate: 0/1/-1) don’t draw polygons seen from the back side. The best is to enable it for transparent objects, and to disable it for “open” (on which both sides may be seen) and opaque meshes. For objects both open and transparent, there is no perfoect setting…

  • polygon_mode (string) – polygons rendering mode: “normal”, “wireframe”, “outline” (normal + wireframe), “hiddenface_wireframe” (wireframe with hidden faces), “default” (use the global view settings), “ext_outlined” (thickened external boundaries + normal rendering).

  • unlit_color (RGB[A] vector: float values between 0 and 1.) – color used for lines when lighting is off. For now it only affects polygons boundaries in “outlined” or “ext_outlined” polygon modes.

  • line_width (float) – Lines thickness (meshes, segments, wireframe rendering modes). A null or negative value fallsback to default (1 in principle).

  • front_face (string) – Specifies if the mesh(es) polygons external face is the clockwise or counterclockwise side. Normally in Aims/Anatomist indirect referentials, polygons are in clockwise orientation. Values are “clockwise”, “counterclockwise”, or “neutral” (the default).

  • selectable_mode (string) –

    New in Anatomist 4.5. Replaces the ghost property.

    always_selectable:

    object is selecatble whatever its opacity.

    ghost:

    object is not selectable.

    selectable_when_opaque:

    object is selectable when totally opaque (this is the default in Anatomist).

    selectable_when_not_totally_transparent:

    object is selectable unless opacity is zero.

  • use_shader (int) – enable or disable the use of OpenGL shaders for this object.

  • shader_color_normals (int) – when shaders are enabled, normals can be represented as colors on the object.

  • normal_is_direction (int) – when shaders are enabled and shader_color_normals is set, normals may be pre-calculates as mesh direction, on a “line” mesh (polygons are lines, not triangles).

setPalette(**kwargs)

Assign a palette to object, or change its characteristics (scaling etc).

Parameters
  • palette (Anatomist.APalette or str (name)) – Principal palette to apply

  • minVal (float) – Minimum object texture value mapped to the lower bound of the palette, by default in relative proportional mode.

  • maxVal (float) –

    Minimum object texture value mapped to the lower bound of the palette.

    By default minVal, maxVal, minVal2 and maxVal2 are relative values expressed in proportion of object texture extrema: [0-1] corresponds to the whole object dynamics. If absoluteMode is True, then values are in object texture values space. The range [minVal-maxVal] is mapped to the while palette, thus any value below or over these extrema will get the first or last (resp.) color of the palette. Values outside [0-1] may be used, meaning that not all the palette colors range will be mapped to the texture values.

  • palette2 (APalette) – Second palette, for 2D textures

  • minVal2 (float (0 - 1)) – Second palette value to affect to object texture second component min value

  • maxVal2 (float (0 - 1)) – Second palette value to assign to object texture second component max value

  • mixMethod (string) – Method to mix two palettes in a 2D palette: linear or geometric

  • linMixFactor (float) – mix factor for the linear method

  • palette1Dmapping (string) – way of using 2D palette for 1D texture : FirstLine or Diagonal

  • absoluteMode (bool) – if True, min/max values are supposed to be absolute values (in regard to objects texture) rather than proportions

  • zeroCentered1 (bool) – min/max should be updated to keep absolute value 0 at the center of the palette (for palette 1).

  • zeroCentered2 (bool) – min/max should be updated to keep absolute value 0 at the center of the palette (for palette 2).

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

toAimsObject(**kwargs)

Converts AObject to aims object.

class APalette(*args, **kwargs)
getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

setColors(**kwargs)

Modifies a palette (colors).

Parameters
  • colors (list of int) – Color vectors, in line (a list of R, G, B, R, G, B… or R, G, B, A, ..), as int 8 bit values

  • color_mode (str) – 'RGB' or 'RGBA'

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

class AWindow(*args, **kwargs)

If internal rep is given in parameter, the corresponding anatomist window already exists : take a reference on it (to prevent its deletion).

activateAction(**kwargs)

Triggers window action activation.

New in Anatomist 4.5.

Parameters
  • action_type (str (mandatory)) – type of action: “key_press”, “key_release”, “mouse_press”, “mouse_release”, “mouse_double_click”, “mouse_move”. Additional parameters depend on the action type: * key actions do not use any; * mouse actions need x and y keyword parameters

  • method (str (mandatory)) – action method name, as registered in the active control. Deteremines what will actually be done.

  • x (int (optional)) – x mouse coord, for mouse actions only.

  • y (int (optional)) – y mouse coord, for mouse actions only.

addObjects(**kwargs)

Adds objects in window.

Parameters
  • objects (list of Anatomist.AObject) – List of objects to add

  • temporary (bool (optional)) – temporary object do not affect the view boundaries and camera settings

  • position (int (optional)) – insert objects as this order number

assignReferential(**kwargs)

Assign a referential to window. The referential must exist. To create a new Referential, execute createReferential, to assign the central referential, first get it with Anatomist.centralRef attribute.

Parameters

referential (Anatomist.Referential) – The referential to assign to objects and/or windows

camera(**kwargs)

Sets the point of view, zoom, cursor position for a 3D window.

Parameters
  • zoom (float) – Zoom factor, default is 1

  • observer_position (float vector, size 3) – Camera position

  • view_quaternion (float vector, size 4, normed) – View rotation

  • slice_quaternion (float vector, size 4, normed) – Slice plan rotation

  • force_redraw (bool) – If True, refresh printing immediatly, default is False

  • cursor_position (float vector) – Linked cursor position

  • boundingbox_min (float vector) – Bounding box min values

  • boundingbox_max (float vector) – Bounding box max values

  • slice_orientation (float vector, size 3) – Slice plane orientation, normal to the plane

close(**kwargs)

Closes window.

getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

getReferential(**kwargs)

Get the referential attached to the window (the coordinates system used for 3D positions in this window)

imshow(**kwargs)

Display the 3D view rendering into a Matplotlib figure using pylab.imshow(). This is useful to display static figures in a widget, or use them to export in a document, or to use the sphinx_gallery module for documentation.

moveLinkedCursor(**kwargs)

Changes cursor position in this window and all linked windows (same group).

Parameters

position (float vector, size 3) – Cursor new position

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

removeObjects(**kwargs)

Removes objects from window.

Parameters

objects (list of Anatomist.AObject) – List of objects to remove

setControl(**kwargs)

Changes the selected button in windows menu. Examples of controls : 'PaintControl', 'NodeSelectionControl', 'Default 3D Control', 'Selection 3D', 'Flight Control', 'ObliqueControl', 'TransformationControl', 'CutControl', 'Browser Selection', 'RoiControl'

showToolbox(**kwargs)

Shows or hides the toolbox frame of a window.

Parameters

show (bool) – If True, the window’s toolbox frame is shown, else it is hidden.

snapshot(**kwargs)

Take a snapshot of the window 3D contents and save it into a file

Equivalent to:

window.windowConfig(snapshot=filename, snapshot_width=width,
                    snapshot_height=height)
Parameters
  • filename (str) – file name to save the snapshot into

  • width (int) – width of the snapshot. If unspecified, or if framebuffer rendering is not supported by the OpenGL implementation, the width will always be the actual visible window width.

  • height (int) – height of the snapshot. If unspecified, or if framebuffer rendering is not supported by the OpenGL implementation, the height will always be the actual visible window height.

Render the view in a matplotlib AGG graph to be used by the sphinx_gallery module, when building documentation examples. If sphinx_gallery is not already loaded, then nothing is done

Parameters
  • width (int) –

  • height (int) –

  • restore_backend (bool) – the rendering needs to set matplotlib backend to “agg” temporarily. If restore_backend is True, then the former backend is restored. Otherwise (the default) it is left to agg. sphinx_gallery generally needs to leave it to agg when building docs for multiple Anatomist examples.

Returns

result oy pyplot.imshow(), or None if sphinx_gallery is not loaded

Return type

plot

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

windowConfig(**kwargs)

Settings for windows (includes various settings)

Parameters
  • clipping (int (optional)) – number of clipping planes: 0, 1 or 2

  • clip_distance (float (optional)) – distance between the slice plane and the clipping planes

  • cursor_visibility (int (optional)) – makes visible (1) or invisible (0) the linked cursor in the chosen windows. The value -1 sets back the global setting (of the preferences)

  • face_culling (int (optional)) – enables (1) or disables (0) the elimination of polygons seen from the bottom face

  • flat_shading (int (optional)) – enables (1) or disables (0) rendering in “flat shading” mode (without color smoothing)

  • fog (int (optional)) – enables (1) or disables (0) fog

  • geometry (list of int (optional)) – position and size of the window (external size). If sizes are zero or not specified, the current window size is not changed

  • iconify (int (optional)) – iconifies (or hides) windows

  • light (dict (optional)) –

    Windows lighting settings. This dictionary may include the following parameters: ubublle

    • ambient: ambiant lighting settings (list of float, 4 elements)

    • diffuse: diffuse lighting settings (list of float, 4 elements)

    • specular: specular lighting settings (list of float, 4 elements)

    • background: background color (list of float, 4 elements)

    • position: light position (list of float, 4 elements)

    • spot_direction: spot light direction (list of float, 3 elements)

    • spot_exponent: spot light intensity exponent (float)

    • spot_cutoff: spot light cutoff angle (float)

    • attenuation_offset: light attenuation, offset part ( float)

    • attenuation_linear: light attenuation, linear coefficient (float)

    • attenuation_quadratic: light attenuation, quadratic coefficient (float)

    • model_ambient: don’t really know… (list of float, 4 elements)

    • model_local_viewer: don’t really know… (float)

    • model_two_side: don’t really know (float)

  • linkedcursor_on_slider_change (int (optional)) – enables or disables the mode when slice/time sliders act as linked cursor actions (with propagation to other views)

  • perspective (int (optional)) – enables (1) or disables (0) the perspective rendering mode

  • perspective_angle (float (optional)) – set the perspective view angle (low: more isometric, high: more distorted). Only used when perspective is enabled.

  • perspective_auto_far_plane (int (optional)) – enables (1) or disables (0) the automatic perspective far clipping plane setup. Only used when perspective is enabled.

  • perspective_far_distance (float (optional)) – set the clipping distance from the eye. Only used when perspective is enabled and perspective_auto_far_plane is disabled.

  • perspective_near_ratio (float (optional)) – set the minimum ratio between the near clipping plane distance and the far one. Objects nearer than this near plane will not be displayed. But reducing this ratio lowers the precision of the depth buffer. Default is 0.01. Only used when perspective is enabled.

  • polygon_filtering (int (optional)) – enables (1) or disables (0) polygons and lines smoothing (anti- aliasing)

  • polygon_mode (string (optional)) – polygons rendering mode: “normal”, “wireframe”, “outline” (normal + wireframe), “hiddenface_wireframe” (wireframe with hidden faces)

  • polygons_depth_sorting (int (optional)) – enables (1) or disables (0) polygons sortig along depth on transparent objects to allow a better rendering. This mode has a large impact on performances, so use it with care.

  • raise_window (int (optional)) – unicognifies windows and make them move to the top of the desktop. Note that this parameter has a different name as the anatomist command interface (is was “raise” there) because “raise” is a reserved keyword in Python and cannot be used here.

  • record_basename (string (optional):) – base filename of images written using the film recording mode (ex: /tmp/toto.jpg). Images will actually have numbers appended before the extension

  • record_mode (int (optional)) – enables (1) or disables (0) the images recording mode (film) of 3D windows. To enable it, record_basename must also be specified

  • snapshot (string (optional)) – Saves the image of the view in the specified file. If windows contains several values, then several images have to be saved: in this case, snapshot is a list of filenames separated by space characters: so the file name/path must not contain any space character (this restriction doesn’t apply if a single window is used). Node: escape character (”“) are not supported yet.

  • snapshot_width (int (optional)) – Snapshot or recorded images width. If unspecified, fit the window size. New in Anatomist 4.6.

  • snapshot_height (int (optional)) – Snapshot or recorded images height. If unspecified, fit the window size. New in Anatomist 4.6.

  • transparent_depth_buffer (int (optional)) – enables (1) or disables (0) writing of transparent objects in the depth buffer. Useful if you want to click across transparents objects (but the rendering can be wrong)

  • view_size (list of int (optional)) – size of the rendering zone (3D rendering widget). This parameter has a higher priority than sizes given using geometry if both are specified

  • fullscreen (int (optional)) – enables or disables the fullscreen mode

  • show_cursor_position (int (optional)) – shows or hides the status bar at the bottom of the window, showing the cursor position and a current object value at this position.

  • show_toolbars (int (optional)) – shows or hides everything around the 3D view (menus, buttons bars, status bar, referential…)

class AWindowsBlock(*args, **kwargs)
class WidgetProxy(anatomistinstance, internalRep, widget)
getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

class AWindowsGroup(*args, **kwargs)
addToSelection(**kwargs)

Adds objects to this windows group’s current selection.

Parameters

objects (list of Anatomist.AObject) – Objects to add to selection

addToSelectionByNomenclature(**kwargs)

Adds objects to this windows group’s current selection, given their name in a nomenclature.

Parameters
  • nomenclature (AObject) – Tree with names and labels associated to nodes.

  • names (list of str) – Names of elements to add to selection.

getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

getSelection(**kwargs)
Returns

objects – Objects that are selected in this windows group

Return type

list of Anatomist.AObject

isSelected(**kwargs)
Parameters

object (AObject) – An object in this windows group

Returns

selectedTrue if the object is selected in this windows group

Return type

bool

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

setSelection(**kwargs)

Initializes selection with given objects for this windows group.

Parameters

objects (list of Anatomist.AObject) – Objects to select

setSelectionByNomenclature(**kwargs)

Selects objects giving their name in a nomenclature. In anatomist graphical interface, it is done by clicking on items of a nomenclature opened in a browser.

Parameters
  • nomenclature (AObject) – tree with names and labels associated to nodes.

  • names (list of str) – Names of elements to select.

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

toggleSelection(**kwargs)

Inverses selection in this windows group. Selected objects becomes unselected, unselected objects become selected.

toggleSelectionByNomenclature(**kwargs)

Removes objects from this windows group’s selection, given their name in a nomenclature.

Parameters
  • nomenclature (AObject) – Tree with names and labels associated to nodes.

  • names (list of str) – Names of elements to unselect.

unSelect(**kwargs)

Removes objects from this windows group selection.

Parameters

objects (list of Anatomist.AObject) – Objects to unselect

class Material(ambient=None, diffuse=None, emission=None, shininess=None, specular=None, lighting=None, smooth_shading=None, polygon_filtering=None, depth_buffer=None, face_culling=None, polygon_mode=None, unlit_color=None, line_width=None, ghost=None, front_face=None, selectable_mode=None, use_shader=None, shader_color_normals=None, normal_is_direction=None)
class Referential(*args, **kwargs)
getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

class Transformation(*args, **kwargs)
getInfo(**kwargs)

Gets information about this object.

Returns

info – information about the object (property -> value)

Return type

dict

getInfos(**kwargs)

Obsolete - now use getInfo()

getInternalRep(**kwargs)

Returns internal representation of the object (implementation dependant).

getRef(**kwargs)

Get a reference of type refType on this object.

Returns

ref – A copy of current object with a reference of type refType on anatomist object.

Return type

AItem

ref(**kwargs)

Access the underlying object

releaseAppRef(**kwargs)

Release anatomist application reference on this object: so object life is controled by references on it. If there is no more references on the object, it is deleted. Used when an object is created by python api. It is not owned by anatomist application.

releaseRef(**kwargs)

Release a reference on this object.

save(**kwargs)

Saves transformation in a file.

Parameters

filename (str) – File in which the transformation will be written.

takeAppRef(**kwargs)

Take anatomist application reference on this object : so object life is controled the normal way by Anatomist. Inverse of releaseAppRef(). The object is now owned by anatomist application.

takeRef(**kwargs)

Take a reference on this object.

addObjects(**kwargs)

Adds objects in windows. The objects and windows must already exist.

Parameters
  • objects (list of AObject) – List of objects to add

  • windows (list of AWindow) – List of windows in which the objects must be added

  • add_children (bool (optional)) – if children objects should also be added individually after their parent

  • add_graph_relations (bool (optional)) – if graph relations should be also be added

  • temporary (bool (optional)) – temporary object do not affect the view boundaries and camera settings

  • position (int (optional)) – insert objects as this order number

applyBuiltinReferential(**kwargs)

Extracts referentials / transformations from objects headers when they contain such information, and assign them.

Parameters

objects (list of AObject) – Objects which referential information must be loaded

assignReferential(**kwargs)

Assign a referential to objects and/or windows. The referential must exist. To create a new Referential, execute createReferential, to assign the central referential, first get it with Anatomist.centralRef attribute.

Parameters
  • referential (Referential) – The referential to assign to objects and/or windows

  • elements (list of AObject / AWindow) – Objects or windows which referential must be changed. The corresponding command tree contains an attribute central_ref to indicate if the referential to assign is anatomist central ref, because this referential isn’t referenced by an id. In the socket implementation, Referential object must have an attribute central_ref, in order to create the command message. In direct impl, it is possible to access directly to the central ref object.

camera(**kwargs)

Sets the point of view, zoom, cursor position for 3D windows.

Parameters
  • windows (list of AWindow) – Windows which options must be changed

  • zoom (float) – Zoom factor, default is 1

  • observer_position (float vector, size 3) – Camera position

  • view_quaternion (float vector, size 4, normed) – View rotation

  • slice_quaternion (float vector, size 4, normed) – Slice plane rotation

  • force_redraw (bool) – If True, refresh printing immediatly, default is False

  • cursor_position (float vector) – Linked cursor position

  • boundingbox_min (float vector) – Bounding box min values

  • boundingbox_max (float vector) – Bounding box max values

  • slice_orientation (float vector, size 3) – Slice plane orientation, normal to the plane

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.

closeWindows(**kwargs)

Closes windows.

Parameters

windows (list of AWindow) – Windows to be closed

convertParamsToAItems(**kwargs)

Recursively converts C++ API objects or context IDs to generic API objects.

Parameters
  • params (dict or list or anything else) –

  • convertIDs (bool) – If True, int numbers are treated as item IDs and converted accordingly when possible.

  • changed (list) – If anything has been changed from the input params, then changed will be added a True value. It’s actually an output parameter

Returns

elements – converted elements

Return type

list

convertParamsToIDs(**kwargs)

Converts current api objects to corresponding anatomist object representation. This method must be called before sending a command to anatomist application on command parameters.

Parameters

params (dict or list) – Elements to convert

Returns

elements – Converted elements

Return type

dict or list

convertParamsToObjects(**kwargs)

Converts current api objects to corresponding anatomist object representation. This method must be called before sending a command to anatomist application on command parameters.

Parameters

params (dict or list) – Elements to convert

Returns

objects – Converted elements

Return type

dict or list

convertSingleObjectParamsToIDs(**kwargs)

Converts current api object to corresponding anatomist object representation.

Parameters

v (AItem instance) – Element to convert

Returns

Converted elements

Return type

*dictionary* or list

convertSingleObjectParamsToObjects(**kwargs)

Converts current api object to corresponding anatomist C++ object representation.

Parameters

v (AItem) – Element to convert

Returns

objects – Converted elements

Return type

dict or list

createControlWindow(**kwargs)

Creates anatomist main window. Currently it is done automatically.

createGraph(**kwargs)

Creates a graph associated to an object (volume for example). This object initializes the graph dimensions (voxel size, extrema).

Parameters
  • object (AObject) – The new graph is based on this object

  • name (str) – Graph name. default is 'RoiArg'.

  • syntax (str) – Graph syntactic attribute. default is 'RoiArg'.

  • filename (str) – Filename used for saving. Default is None.

Returns

graph – The new graph object

Return type

AGraph

createPalette(**kwargs)

Creates an empty palette and adds it in the palettes list.

Parameters

name (str) – Name of the new palette

Returns

palette – The newly created palette

Return type

APalette

createReferential(**kwargs)

This command does not exist in Anatomist because the command AssignReferential can create a new referential if needed. But the way of creating a new referential depends on the connection with Anatomist, so it seems to be better to encapsulate this step on another command. So referentials are treated the same as other objects. (LoadObject -> addAobject | createReferential -> assignReferential)

Parameters

filename (str) – Name of a file (minf file, extension .referential) containing information about the referential: its name and uuid

Returns

ref – The newly created referential

Return type

Referential

createTransformation(**kwargs)

Creates a transformation from a referential to another. The transformation informations are given in a matrix.

Parameters
  • matrix (float vector, size 12) – Transformation matrix (4 lines, 3 colons ; 1st line: translation, others: rotation)

  • origin (Referential) – Origin of the transformation

  • destination (Referential) – Referential after applying transformation

Returns

trans – New transformation

Return type

Transformation

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
  • nbCols (int) – Number of columns of the windows block

  • nbRows (int) – Number of rows of the windows block (exclusive with nbCols)

  • widget (QWidget (optional)) – New in Anatomist 4.6.2, only applies to the direct implementation. Existing parent widget to be used as a block

Returns

block – A window which can contain several AWindow

Return type

AWindowsBlock

deleteElements(**kwargs)

Deletes objects, windows, referentials, anything that is referenced in anatomist application.

Parameters

elements (list of AItem) – Elements to delete

deleteObjects(**kwargs)

Deletes objects

Parameters

objects (list of AObject) – Objects to delete

disableListening(**kwargs)

Set listening of this event off.

Parameters

event (str) – Name of the event to disable.

duplicateObject(**kwargs)

Creates a copy of source object.

Parameters

source (AObject) – The object to copy.

Returns

object – The copy. it has a reference to its source object, so original object will not be deleted as long as the copy exists.

Return type

AObject

enableListening(**kwargs)

Set listening of this event on. So when the event occurs, the notifier’s notify method is called. This method is automatically called when the first listener is added to a notifier. That is to say that notifiers are activated only if they have registered listeners.

Parameters
  • event (str) – Name of the event to listen

  • notifier (soma.notification.Notifier) – The notifier whose notify method must be called when this event occurs

execute(**kwargs)

Executes a command in anatomist application. It should be a command that can be processed by Anatomist command processor. The list of available commands is in the commands system. Parameters are converted before sending the request to anatomist application.

Parameters
  • command (str) – Name of the command to execute.

  • kwargs (dict) – Parameters for the command

fusionObjects(**kwargs)

Creates a fusionned multi object that contains all given objects.

Parameters
  • objects (list of AObject) – List of objects that must be fusionned

  • method (str) – Method to apply for the fusion ('Fusion2DMethod'…)

  • ask_order (bool) – If True, asks user in which order the fusion must be processed.

Returns

object – The newly created fusion object.

Return type

AObject

getAItem(**kwargs)

Converts a C++ API objects or context IDs to a generic API object.

Parameters
  • idorcpp (ID or C++ instance to be converted) – If idorcpp is already an AItem, it is returned as is

  • convertIDs (bool) – If True, int numbers are treated as item IDs and converted accordingly when possible.

  • allowother (bool) – If True, idorcpp is returned unchanged if not recognized

Returns

aitem – Converted element

Return type

AItem instance, or None (or the unchanged input if allowother is True)

getAimsInfo(**kwargs)
Returns

info – Information about the AIMS library.

Return type

str

getCommandsList(**kwargs)
Returns

commands – Dict of commands available in Anatomist with their parameters. dict command name -> dict parameter name -> dict attribute -> value (needed, type)

Return type

dict

getDefaultWindowsGroup(**kwargs)

Normally returns 0

getFusionInfo(**kwargs)

Gets information about fusion methods. If objects is not specified, the global list of all fusion methods is returned. Otherwise the allowed fusions for those specific objects is returned.

Returns

methods – Fusion methods

Return type

dict

getModulesInfo(**kwargs)
Returns

info – Dict of modules and their description. dict module name -> dict attribute -> value (description)

Return type

dict

getObject(**kwargs)

Get the object corresponding to this filename if it is currently loaded.

Parameters

filename (str) – Filename of the requested object

Returns

object – The object if it is loaded, else returns None.

Return type

AObject

getObjects(**kwargs)

Gets all objects referenced in current context.

Returns

objects – List of existing objects

Return type

list of AObject

getPalette(**kwargs)
Returns

palette – The named palette

Return type

APalette

getPalettes(**kwargs)
Returns

palettes – List of palettes.

Return type

list of APalette

getReferentials(**kwargs)

Gets all referentials in current context.

Returns

refs – List of referentials

Return type

list of Referential

getSelection(**kwargs)
Parameters

group (AWindowsGroup) – Get the selection in this group. If None, returns the selection in the default group.

Returns

objects – The list of selected objects in the group of windows

Return type

list of AObject

getTransformations(**kwargs)

Gets all transformations.

Returns

trans – List of transformations

Return type

list of Transformation

getVersion(**kwargs)
Returns

version – Anatomist version

Return type

str

getWindows(**kwargs)

Gets all windows referenced in current context.

Returns

windows – List of opened windows

Return type

list of AWindow

groupObjects(**kwargs)

Creates a multi object containing objects in parameters.

Parameters

objects (list of AObject) – Objects to put in a group

Returns

group – The newly created multi object

Return type

AObject

importObjects(**kwargs)

Gets objects importing those that are not referenced in the current context.

Parameters

top_level_only (bool) – If True, imports only top-level objects (that have no parents), else all objects are imported.

Returns

objects – List of existing objects

Return type

list of AObject

importReferentials(**kwargs)

Gets all referentials importing those that are not referenced in the current context.

Returns

refs – List of referentials

Return type

list of Referential

importTransformations(**kwargs)

Gets all transformations importing those that are not referenced in the current context.

Returns

trans – List of transformations

Return type

list of Transformation

importWindows(**kwargs)

Gets all windows importing those that are not referenced in the current context.

Returns

windows – List of opened windows

Return type

list of AWindow

linkCursorLastClickedPosition(**kwargs)

Gives the last clicked position of the cursor.

Parameters

ref (Referential) – If given, cursor position value will be in this referential. Else, anatomist central referential is used.

Returns

position – Last position of the cursor

Return type

float vector, size 3

linkWindows(**kwargs)

Links windows in a group. Moving cursor position in a window moves it in all linked windows. By default all windows are in the same group.

Parameters
  • windows (list of AWindow) – The windows to link

  • group (AWindowsGroup) – Put the windows in this group. If it is None, a new group is created.

loadCursor(**kwargs)

Loads a cursor for 3D windows from a file.

Parameters

filename (str) – The file containing object data

Returns

cursor – The loaded object

Return type

AObject

loadObject(**kwargs)

Loads an object from a file (volume, mesh, graph, texture…)

Parameters
  • filename (str) – The file containing object data

  • objectName (str) – Object name

  • restrict_object_types (dict) – object -> accpepted types list. Ex: {'Volume' : ['S16', 'FLOAT']}

  • forceReload (bool) – If True, the object will be loaded even if it is already loaded in Anatomist. Otherwise, the already loaded one is returned.

  • duplicate (bool) – If the object already exists, duplicate it. The original and the copy will share the same data but not display parameters as palette. If the object is not loaded yet, load it hidden and duplicate it (unable to keep the original object with default display parameters).

  • hidden (bool) – A hidden object does not appear in Anatomist main control window.

Returns

object – The loaded object

Return type

AObject

loadReferentialFromHeader(**kwargs)

Extracts referentials / transformations from objects headers when they contain such information, and assign them.

Parameters

objects (list of AObject) – Objects which referential information must be loaded

loadTransformation(**kwargs)

Loads a transformation from a referential to another. The transformation informations are given in a file.

Parameters
  • filename (str) – File containing transformation information

  • origin (Referential) – Origin of the transformation

  • destination (Referential) – Referential after applying transformation

Returns

trans – Transformation to apply to convert coordinates from one referent

Return type

Transformation

log(**kwargs)

Use this method to print a log message. This method prints on standard output. To be redefined for another type of log.

static makeList(*args, **kwargs)

Transforms the argument into a list: a list with one element if it is not a sequence, or return the input sequence if it is already one

newId(**kwargs)

In this implementation, anatomist objects are accessibles but some commands need an id associated to the object : CreateWindowCommand blockid attribute, linkWindows group attribute… This method generates a unique id in current context.

Returns

id – A new unused ID.

Return type

int

newItemRep(**kwargs)

Creates a new item representation.

reloadObjects(**kwargs)

Reload objects already in memory reading their files.

removeObjects(**kwargs)

Removes objects from windows.

Parameters
  • objects (list of AObject) – List of objects to remove

  • windows (list of AWindow) – List of windows from which the objects must be removed

send(**kwargs)

Sends a command to anatomist application. Call this method if there is no answer to get. This method depends on the mean of communication with anatomist. Must be redefined in implementation api.

Parameters
  • command (str) – Name of the command to execute. Any command that can be processed by anatomist command processor. The complete commands list is in the commands system

  • kwargs (dict) – Parameters for the command

setGraphParams(**kwargs)

Modifies graphs and selections options.

Parameters
  • display_mode (str) – Paint mode of objects in graph nodes : mesh, bucket, all, first

  • label_attribute (str) – Selects the attribute used as selection filter: label or name

  • save_only_modified (bool int (0/1)) – If enabled, graph save saves not all sub objects but only those that have been modified.

  • saving_mode (str) – Graph saving mode : unchanged (keep the reading format), global (1 file for all same category sub-objects), or local (1 file per sub- object)

  • selection_color (int vector) – Selected objects color : R G B [A [NA]] (A opacity, NA: 0/1 use object opacity parameter)

  • selection_color_inverse (bool int (0/1)) – Selection inverses color instead of using selection_color

  • set_base_directory (bool int (0/1)) – Save subobjects in a directory <graph name>.data

  • show_tooltips (bool int (0/1)) – Show graph nodes names in tooltips

  • use_nomenclature (bool int (0/1)) – Enable graph coloring with nomenclature

setMaterial(**kwargs)

Changes objects material properties.

Parameters
  • objects (AObject or list) – objects to change material on.

  • material (Material) – Material characteristics, including render properties. The material may be specified as a Material object, or as its various properties (ambient, diffuse, etc.). If both a material parameter and other properties are specified, the material is used as a base, and properties are used to modify it

  • refresh (bool) – If True, force windows refreshing

  • ambient (list) – RGB[A] vector: float values between 0 and 1.

  • diffuse (list) – RGB[A] vector: float values between 0 and 1. This parameter corresponds to the “standard” notion of color

  • emission (list) – RGB[A] vector: float values between 0 and 1.

  • specular (list) – RGB[A] vector: float values between 0 and 1.

  • shininess (float) – 0-124

  • lighting (int) – enables (1) or disables (0) objects lighting/shading. Setting this value to -1 goes back to the default mode (globally set at the view/scene level).

  • smooth_shading (int) – (tristate: 0/1/-1) smooth or flat polygons mode

  • polygon_filtering (int) – (tristate: 0/1/-1) filtering (antialiasing) of lines/polygons

  • depth_buffer (int) – (tristate: 0/1/-1) enables/disables writing in the Z-buffer. You can disable it if you want to click “through” an object (but it may have strange effects on the rendering)

  • face_culling (int) – (tristate: 0/1/-1) don’t draw polygons seen from the back side. The best is to enable it for transparent objects, and to disable it for “open” (on which both sides may be seen) and opaque meshes. For objects both open and transparent, there is no perfoect setting…

  • polygon_mode (string) – polygons rendering mode: “normal”, “wireframe”, “outline” (normal + wireframe), “hiddenface_wireframe” (wireframe with hidden faces), “default” (use the global view settings), “ext_outlined” (thickened external boundaries + normal rendering).

  • unlit_color (RGB[A] vector: float values between 0 and 1.) – color used for lines when lighting is off. For now it only affects polygons boundaries in “outlined” or “ext_outlined” polygon modes.

  • line_width (float) – Lines thickness (meshes, segments, wireframe rendering modes). A null or negative value fallsback to default (1 in principle).

  • front_face (string) – Specifies if the mesh(es) polygons external face is the clockwise or counterclockwise side. Normally in Aims/Anatomist indirect referentials, polygons are in clockwise orientation. Values are “clockwise”, “counterclockwise”, or “neutral” (the default).

  • selectable_mode (string) –

    New in Anatomist 4.5. Replaces the ghost property.

    always_selectable:

    object is selecatble whatever its opacity.

    ghost:

    object is not selectable.

    selectable_when_opaque:

    object is selectable when totally opaque (this is the default in Anatomist).

    selectable_when_not_totally_transparent:

    object is selectable unless opacity is zero.

  • use_shader (int) – enable or disable the use of OpenGL shaders for this object.

  • shader_color_normals (int) – when shaders are enabled, normals can be represented as colors on the object.

  • normal_is_direction (int) – when shaders are enabled and shader_color_normals is set, normals may be pre-calculates as mesh direction, on a “line” mesh (polygons are lines, not triangles).

setObjectPalette(**kwargs)

Assign a palette to objects

Parameters
  • objects (list of AObject) – Assign palette parameters to these objects

  • palette (APalette or str (name)) – Principal palette to apply

  • minVal (float (0 - 1)) – Palette value to assign to objects texture min value (proportionally to palette’s limits)

  • maxVal (float (0 - 1)) – Palette value to assign to objects texture max value

  • palette2 (APalette or str (name)) – Second palette, for 2D textures

  • minVal2 (float (0 - 1)) – Second palette value to affect to object texture second component min value

  • maxVal2 (float (0 - 1)) – Second palette value to assign to object texture second component max value

  • mixMethod (string) – Method to mix two palettes in a 2D palette : linear or geometric

  • linMixFactor (float) – mix factor for the linear method

  • palette1Dmapping (string) – way of using 2D palette for 1D texture : FirstLine or Diagonal

  • absoluteMode (bool) – if True, min/max values are supposed to be absolute values (in regard to objects texture) rather than proportions

  • zeroCentered1 (bool) – min/max should be updated to keep absolute value 0 at the center of the palette (for palette 1).

  • zeroCentered2 (bool) – min/max should be updated to keep absolute value 0 at the center of the palette (for palette 2).

setPaintParams(**kwargs)

Setup Paint contol parameters. All parameters are optional.

Parameters
  • brush_size (float) – Radius of the paint brush, either in millimeters or in voxels, depending on the millimeter_mode.

  • brush_type (str) – “point”, “square”, “disk”, or “sphere”. “ball” is an alias for sphere.

  • follow_linked_cursor (bool) – Linked cursor moving with brush

  • line_mode (bool) – line interpolation mode between brush strokes

  • millimeter_mode (bool) – brush size can be either in mm or in voxels. In voxels mode, the brush may be anisotropic.

  • replace_mode (bool) – region replacing mode (when drawing on a different region)

  • region_transparency (float) – value of the region transparency

setWindowsControl(**kwargs)

Changes the selected button in windows menu.

Parameters
  • windows (list of AWindow) – Windows to set control on

  • control (str) – Control to set. Examples of controls: ‘PaintControl’, ‘NodeSelectionControl’, ‘Default 3D Control’, ‘Selection 3D’, ‘Flight Control’, ‘ObliqueControl’, ‘TransformationControl’, ‘CutControl’, ‘Browser Selection’, ‘RoiControl’…

showObject(**kwargs)

Displays the given object in a new window

sync(**kwargs)

Wait for anatomist finishing current processing.

toAObject(**kwargs)

Converts an AIMS object or numpy array to AObject.

Returns

aobject

Return type

AObject

toAimsObject(**kwargs)

Converts an AObject to an AIMS object.

Parameters

object (AObject) – The object to convert

Returns

aims – The underlying converted AIMS object

Return type

various types

typedObject(**kwargs)

Get AObject or a subclass from a sip object when it is possible.

Returns

object

Return type

AObject

waitEndProcessing(**kwargs)

Deprecated. Use method sync instead.

Utility sub-module for the threaded implementation

This module makes anatomist module given implementation thread safe.

The ThreadSafeMetaclass is used to build thread-safe versions of classes (Anatomist, AItem and other inherited classes).

The function getThreadSafeClass() enables to create a thread safe class based on a given Anatomist implementation class. It replaces all methods by a call in main thread of the same method. The ThreadSafeMetaclass metaclass ensures that inherited classes will also be thread safe.

class anatomist.threadedimpl.ThreadSafeMetaclass(name, bases, attdict)[source]

The ThreadSafeMetaclass replaces all methods of the classes it builds with thread-safe wrappers. All function calls are actually deported to the main thread. Subclasses are also handled. Anatomist.AItem is also made to inherit soma.qt_gui.qtThread.MainThreadLife and makes a hook to force deletion to happen in the main thread when reference count reaches zero from any thread.

This meta-class inherits from the meta-class used by PyQt classes.

anatomist.threadedimpl.getThreadSafeClass(classObj, mainThread)[source]

Generates a thread safe class which inherits from the class given in parameters. Methods are executed in the main thread to be thread safe.

Parameters
  • classObj (Class) – the class which needs to be thread safe

  • mainThread (QtThreadCall) – an object that enables to send tasks to the main thread.

Returns

new_class – The generated thread safe class

Return type

Class

anatomist.threadedimpl.get_thead_safe_dict(cls, dictatt, filtered=False)[source]

Builds thread-safe wrappers around dict elements which are methods or functions, replace classes by thread-safe subclasses. Methods are actually queried on the class cls through its __mro__

anatomist.threadedimpl.threadSafeCall(mainThread, func)[source]

Utility function wrapper for main thread calls

Returns

func – a function that sends the given function’s call to the main thread

Return type

function

anatomist.threadedimpl.threadedModule(anatomistModule, mainThread=None)[source]

Adds to current module a thread safe version of given anatomist module, replacing Anatomist class by thread safe Anatomist class.

Parameters
  • anatomistModule (module) – a module containing an implementation of Anatomist class

  • mainThread (MainThreadActions (optional)) – an object that enables to send tasks to the mainThread. If it is not given in parameters, an instance will be created in this function. So it must be called by the mainThread.