BrainVoyager Python Developer Guide 0.9

Mesh Commands

The following commands are exposed by the Mesh object that can be used e.g. to save a mesh to disk, to morph the shape of a mesh and to operate on associated surface map (SMP) and mesh time course (MTC) data. Besides the commands described below, a Mesh object also provides properties that can be used to read and write basic attributes of meshes and associated data. For an example how to use the described properties and commands, see the example 'mesh_scene_test.py' and 'mesh_morphing.py' files in the 'Scripts' tab of the Python Development window.

 

update_appearance()

Description
This command updates the visual representation of a Mesh object. This is, for example, needed after changing the data of associated surface maps, e.g. when overlaying a new (calculated) sub-map, or after selecting patches-of-interest (POIs) for display.


recreate_geometry()

Description
This command synchronizes the visual display of made changes to the geometry of a MeshPyBV object. This is, for example, needed after changing the mesh geometry with custom code to synchronize the internal geometry calculations with the visual representation. When calling the in-build morphing routines (e.g. to smooth, inflate and flatten meshes), the geometry is updated automatically and this command is not needed. Note that for efficiency, the visual representation of the geometry of a mesh is not updated at each step during a standard morphing process; the number of steps after which the visual representaton of the mesh geometry is updated during morphing can, however, be specified using the 'morphing_update_interval' property of the MeshPyBV object.


save()

Description
Saves the mesh to disk using the current name of the mesh (see 'file_name' property).


save_as(str mesh_file, bool remove_cur_on_disk=False)

Description
Saves the MeshScene object to disk using the provided mesh file name.
mesh_file (str)
String specifying the name of the to-be-saved mesh (.srf) file. It is recommended to include the full file path. If only a file name is provided, the file is saved in the current directory.
remove_cur_on_disk (bool)
Optional, default 'False'. If set to 'True', the current mesh objects representation on disk will be removed, i.e. the old file is replaced with the (modified) mesh's newly saved file name.


Morphing Commands


shrink_wrap_morph(int n_cycles, float find_vmr_value) → bool

Description
Shrinks a created sphere mesh and stops when tissue values greater or equal to the provided 'find_vmr_value' parameter are detected. The return value indicates whether the morphing routine was executed without issues.
n_cycles (int)
This parameter specifies the number of times the basic smooth morphing operation will be called. Note that morphing proceeds in small steps in order to keep the mesh geometry stable.
find_vmr_value (float)
This parameter specifies the strenght used to smooth the mesh geometry at each morphing step. Recommended values are in the range from '0.01' to '0.1' (value of '0.07' is used as default internally).


smooth_geometry_simple(int n_cycles, float smooth_force) → bool

Description
Smoothes the geometry of the calling mesh (MeshPyBV) object. This command uses the basic smoothing mode that leads to shrinkage of the mesh. It is useful in case that geometry preserving is not needed (e.g. during inflation or as part of distortion correction when vertices are kept anyway on a flat surface or a shere). The return value indicates whether the morphing routine was executed without issues.
n_cycles (int)
This parameter specifies the number of times the basic smooth morphing operation will be called. Note that morphing proceeds in small steps in order to keep the mesh geometry stable.
smooth_force (float)
This parameter specifies the strenght used to smooth the mesh geometry at each morphing step. Recommended values are in the range from '0.01' to '0.1' (value of '0.07' is used as default internally).


smooth_geometry(int n_cycles, float smooth_force) → bool

Description
Smoothes the geometry of the calling mesh (MeshPyBV) object. This command uses BrainVoyager's 'advanced' smoothing mode that avoids mesh shrinkage during smoothing. This command should be used in case that the mesh geometry should be preserved, e.g. when smoothing a "voxelated" reconstructed mesh. The return value indicates whether the morphing routine was executed without issues.
n_cycles (int)
This parameter specifies the number of times the basic smooth morphing operation will be called. Note that morphing proceeds in small steps in order to keep the mesh geometry stable.
smooth_force (float)
This parameter specifies the strenght used to smooth the mesh geometry at each morphing step. Recommended values are in the range from '0.01' to '0.1' (value of '0.07' is used as default internally).


inflate_geometry(int n_cycles, float smooth_force, str area_reference_mesh='') → bool

Description
Inflates the geometry of the Mesh object. This command is an extended version of the 'SmoothGeometryBasic' command with the difference that the area of the mesh is kept constant while smoothing. This leads to a visual size increase when folds are removed during smoothing. The return value indicates whether the morphing routine was executed without issues. (Note: The old command 'InflateMesh' is deprecated and will be removed in BrainVoyager 22.0)
n_cycles (int)
This parameter specifies the number of times the basic inflation morphing operation will be called. Note that morphing proceeds in small steps in order to keep the mesh geometry stable.
smooth_force (float)
This parameter specifies the strenght used to smooth the mesh geometry at each morphing step. Recommended values are in the range from '0.01' to '0.1' (value of '0.07' is used as default internally).
area_reference_mesh (str)
Optional. This string parameter can be used to specify the mesh that is used to calculate the area that will be kept for the Mesh object during morphing. if an empty string ('') is provided as input, the area of the current Mesh object at the moment the command is called will be used; this is recommended in case that the mesh that will be inflated is the result of cortex reconstruction after non-shrinking smoothing using the 'SmoothGeometry' command. 


Surface Map (SMP) Commands


Full documentation coming soon...


bool LoadSurfaceMaps(str SurfaceMapsFile)


SaveSurfaceMaps(str SurfaceMapsFile)


ShowSurfaceMap(int idx)


str GetNameOfSurfaceMap(int idx)


CalculateCurvature()


CalculateCurvatureCBA()


CreateSurfaceMapFromVolumeMap(int InterpolMethod, bool SampleOnlyNonZeroValues)


CreateSurfaceMapFromVolumeMapDepth(int InterpolMethod, bool SampleOnlyNonZeroValues, bool SampleMaxValue, float DepthStart, float DepthEnd, float StepSize)


SmoothCurrentMap(int NrOfCycles)


SmoothMap(int idx, int NrOfCycles, bool RestrictToNonZeroValues, bool IncludeOnlyNonZeroNeighborValues, bool RestrictToValuesLargerAbsThresh)


SmoothMapLags(int idx, int NrOfCycles, bool CircularLags, bool RestrictToNonZeroValues, bool IncludeOnlyNonZeroNeighborValues, bool RestrictToValuesLargerAbsThresh)


str CreateMultiScaleCurvatureMap(int SmoothLevel1, int SmoothLevel2, int SmoothLevel3, int SmoothLevel4)


str CreateSphericalCoordinatesMapFromSMP(str SMPOnSphereFileName)


Mesh Time Course (MTC) Commands


Full documentation coming soon...


bool CreateMTCFromVTC(real FromNormalPos, real ToNormalPos, str ResultingMTCFileName)


bool LinkMTC(str MTCFileName)


bool SaveMTC(str MTCFileName)


MTC preprocessing


bool SpatialSmoothing(int NrOfCycles)


bool LinearTrendRemoval()


bool TemporalHighPassFilterFFT(int CyclesInTimeCourse)


bool TemporalGaussianSmoothing(real FWHM, str UnitOfFWHMValue)


MTC statistics


ClearDesignMatrix()


bool LoadSingleStudyGLMDesignMatrix(str FileName)


SaveSingleStudyGLMDesignMatrix(str FileName)


ComputeSingleStudyGLM()


ShowGLM()


bool LoadGLM(str FileName)


SaveGLM(str FileName)


ClearMultiStudyGLMDefinition()


AddStudyAndDesignMatrixAndCortexMapping(str FunctionalFileName, str DesignMatrixFileName, str SSMFileName)


SaveMultiStudyGLMDefinitionFile(str FileNameMDM)


bool LoadMultiStudyGLMDefinitionFile(str FileNameMDM)


ComputeMultiStudyGLM()


ComputeRFXGLM()

Copyright © 2020 Rainer Goebel. All rights reserved.