BrainVoyager Python Developer Guide 0.9

Mesh Scene Commands

The following commands are exposed by the MeshScene object. A MeshScene object holds the 3D Viewer (OpenGL) window, which can contain one or more Mesh objects. In combination with its properties, a MeshScene object can be used e.g. to access, create and load meshes.

 

snapshot()

Description
Creates a snapshot of the current 3D viewer and embeds it in the output section of the current cell of the notebook that executes the command. This function saves a screenshot image but also stores the paths to the mesh and map files currently viewed in the current 3D Viewer in the BrainVoyager (multi-document) main window. If double-clicked, a 3D viewer is started that runs embedded in the notebook loading the previously stored mesh and map files (if still available at their original location). Double-clicking the embedded viewer ends the interactive exploration, grabs the current view as an image and shows it at the viewer location. If this command is not called from a notebook, it is ignored.


size() → int

Description
Like the property 'count', this function returns the number of meshes (MeshPyBV objects) available in the calling MeshScene object.


item(int index) → MeshPyBV

Description
Returns the MeshPyBV object at the provided index of the meshes list of the calling MeshScenePyBV object. Together with the 'count' property (or 'size()' function), this function can be used to iterate over all MeshPyBV objects in a mesh scene. Note that one mesh is always the current mesh, which can be retrieved and set using the 'current_mesh' property of a mesh scene object. The mesh (MeshPyBV) object can be used to call mesh-specific functions.
index (int)
Specifies the position in the meshes list maintained by the mesh scene object. If index is smaller than 0 or equal / larger than the number of meshes in the list, the function returns 'None'.


load_mesh(str mesh_file) → bool

Description
Loads a mesh (SRF) file into the MeshScene object. Note that currently available mesh(es) in the mesh scene are removed before the specified mesh is loaded and shown in the 3D Viewer of the MeshScene object. The boolean return value indicates whether the command could be performed successfully. A value of 'False' is returned, for example, in case that the mesh file was not found at the specified path (or current directory in case no path is provided). If successful, the loaded mesh can be accessed using the CurrentMesh property or by using the Item command with index value '0'.
mesh_file (str)
String specifying the name of the mesh (.srf) file to be loaded. It is recommended to include the full file path. If only a file name is provided, the file is loaded from the current directory.


add_mesh(str mesh_file) → bool

Description
Loads a mesh (SRF) file into the MeshScene object without removing any currently available mesh(es) in the mesh scene, i.e. the specified mesh is added to the scene and shown in the 3D Viewer next to the meshes already available before calling this command. The boolean return value indicates whether the command could be performed successfully. A value of 'False' is returned, for example, in case that the mesh file was not found at the specified path. If successful, the loaded mesh can be accessed using the CurrentMesh property or by using the Item command with index value 'Count - 1'.
mesh_file (str)
String specifying the name of the mesh (.srf) file to be loaded. It is recommended to include the full file path. If only a file name is provided, the file is loaded from the current directory if found.


create_sphere_mesh(int radius, int resol_level=1, bool use_head_colors=True) → MeshPyBV

Description
Creates a sphere mesh with the provided radius that can be used for shrink-wrap morphing. (see 'Mesh Commands' topic). The optional parameter 'resol_level' (default: 1) can be used to create a sphere mesh with higher or lower vertices. The 'use_had_colors' parameter can be used to use yellow-golden default "head colors" ('True', default) or grey colors used for cortex meshes. 
radius (str)
Integer specifying the radius of the created sphere mesh. A value of '140' is recommended when using the sphere for subsequent head skin fitting using shrink-wrap morphing and a value of 140 is usually big enough to encompass the head inside the sphere.
resol_level (int)
Optional. Integer specifying the resolution (number of triangles used) for the created sphere. Value '1' (default) creates a sphere with a standard resolution (20480 triangles), value '2' creates a high resolution sphere with 81920 triangles and value '3' creates a very high resolution sphere with 327680 triangles.
use_head_colors (bool)
Optional. Boolean specifies whether the color of the created sphere mesh uses the colors used by BV for the skin of the reconstructed head ('True', default) or (one of) the color(s) used for cortex meshes.


reconstruct_mesh() → MeshPyBV

Description
Reconstructs the surface of a prepared segmented VMR dataset (usually blue colored with yellow border) to which the calling mesh scene object is linked to. If successful, a mesh object is returned and visualized in the 3D viewer of the mesh scene.


merge_meshes() → str

Description
Merges all individual meshes in the mesh scene into one mesh object. If successful, the default name under which the merged mesh will be saved to disk ('MergedMeshes.srf' at present) will be returned, otherwise an empty string. Note that the function attempts to also merge MTCs, SSMs and POIs if available for all meshes.


update_viewer()

Description
This command can be used to trigger an update of the 3D Viewer associated with the SceneMeshPyBV object. Note that the 3D Viewer usually runs in auto-update mode and this command is thus not necessary in most cases.


save_screenshot_of_viewer(str screenshot_file) → bool

Description
Captures the image displayed in the 3D Viewer and saves it as an image file to disk.
screenshot_file (str)
String specifying the name of the to be saved image file. The filename should contain a standard image file extension to save in the respective format; the file extension '.png' is recommended but also '.jpg' and '.gif' files are supported. If a file name is provided without a path, the file is stored in the current directory.


Cortex-Based Alignment Commands (CBA)


create_sphere_mesh_cba() → MeshPyBV

Description
Creates a sphere mesh prepared to be used for CBA with a standard radius. The 'sphere_resolution_cba' property can be changed before calling this command to specify a sphere for low-, standard- or high- resolution CBA.


Full documentation coming soon...


str MapSphereMeshFromStandardSphere()


str SetStandardSphereToFoldedMesh(str FoldedMeshFileName)


ClearGroupCBACurvatureFiles()


bool AddCurvatureFileForGroupCBA(str CurvatureSMPFileName)


bool RunRigidCBA(str TargetPMPFile)


bool RunCBA()


bool CreateAverageCurvatureGroupMap()


bool CreateAverageFoldedGroupMesh()


Copyright © 2020 Rainer Goebel. All rights reserved.