Base Armature

Armature definition procedure

Armature are configured based on a Python dictionary object that can be modified in a dedicated editor included in the Stereotaxic Frame module.

_images/armature_config_editor.png

The frame geometry is given as a series of translation and rotation transforms representative of each stereotaxic frame joints.

# Armature configuration definition example
{
   '_armature_joints': {
      'Joint 1 (x translation only)': {
         'translation_0': {
            'args': ['x', 0.05],
            '_is_editable': False,
         }
      },
      'Joint 2 (z translation + z rotation + y translation)': {
         'translation_0': {
            'args': ['z', 0.01],
            '_is_editable': False
         },
         'rotation_0': {
            'args': ['z', 20.0, 'degrees'],
            '_is_editable': True,
            '_edit_increment': 1,
            '_unit': 'deg'
         },
         'translation_1': {
            'args': ['y', 0.07],
            '_is_editable': True,
            '_edit_increment': 0.0005,
            '_unit': 'm'
         }
      }
   }
}

These dictionaries are constructed through carreful measurements of the stereotaxic frame geometry.

_images/stereatax_frame_constants.jpg

Joints with constant dimensions can reference values defined in a constant dictionary. These can be used as transformation arguments by providing a string that will be evaluated 'args': ['x', "-csts['L2'] + csts['d1']/2"] when displaying the armature. Fixed joints can be hidden from the GUI editor by setting _is_editable to False.

Armature definition validation

Proper armature definition should results in simulated armature geometries matching their actual counterpart in a large range of configurations.

_images/armature_validation_no_angle.png _images/armature_validation_dv1_angle.png _images/armature_validation_dv0_angle.png
In this example, the stereotaxic frame has been defined as a series of 3 discrete armatures:
  1. Bregma loc correction → bridging the rodent head location, with the Arm origin.

  2. Arm 2 → The main arm possessing 5 degrees of freedom (\(x\), \(y\), \(z\) translations + \(x\), \(z\) rotations)

  3. Dummy probe → a detachable probe holder which is in this case constitutes of a single rod with no attachments.

Configuration dictionaries for these armatures have been defined as follows:

  • Bregma loc correction Armature

# Armature configuration definition
{
   '_armature_joints': {
      'AP Bregma': {
            'translation_0': {
               'args': ['x', 0.0787],
               '_is_editable': True,
               '_edit_increment': 0.0005,
               '_unit': 'm'
            }
      },
      'ML Bregma': {
            'translation_0': {
               'args': ['y', 0.0938],
               '_is_editable': True,
               '_edit_increment': 0.0005,
               '_unit': 'm'
            }
      },
      'DV Bregma': {
            'translation_0': {
               'args': ['z', 0.0225],
               '_is_editable': True,
               '_edit_increment': 0.0005,
               '_unit': 'm'
            }
      }
   }
}
  • Arm 2 Armature

# Armature constant definition
{
   'L1': 0.0215,
   'L2': 0.135,
   'L3': 0.0483,
   'L4': 0.077,
   'L5': 0.0245,
   'L6': 0.1152,
   'L7': 0.013,
   'L8': 0.0303,
   'L9': 0.014,
   'L10': 0.0053,
   'L11': 0.0128,
   'L12': 0.136,
   'L13': 0.0245,
   'L14': 0.014,
   'd1': 0.0332,
   'd2': 0.0095,
   'd3': 0.0096,
   'd4': 0.008
}

# Armature configuration definition
{
   '_armature_joints': {
      'ML0': {
            'translation_0': {
               'args': ['y', "csts['L1']/2"],
               '_is_editable': False
            }
      },
      'AP Knob': {
            'translation_0': {
               'args': ['x', 0.0029],
               '_is_editable': True,
               '_force_gui_location_to': 0,
               '_edit_increment': 0.0005,
               '_color': 'x_RED',
               '_unit': 'm'
            }
      },
      'AP0': {
            'translation_0': {
               'args': ['x', "-csts['L2'] + csts['d1']/2"],
               '_is_editable': False
            }
      },
      'DV0': {
            'translation_0': {
               'args': ['z', "csts['L3'] - csts['d2']/2"],
               '_is_editable': False
            },
            'rotation_0': {
               'args': ['z', 20.0, 'degrees'],
               '_is_editable': True,
               '_edit_increment': 1,
               '_unit': 'deg'
            }
      },
      'DV1': {
            'translation_0': {
               'args': ['z', "csts['d2']/2 + csts['L4'] - csts['L5']"],
               '_is_editable': False
            },
            'rotation_0': {
               'args': ['x', 0.0, 'degrees'],
               '_is_editable': True,
               '_edit_increment': 1,
               '_unit': 'deg'
            }
      },
      'DV Knob': {
            'translation_0': {
               'args': ['z', 0.0128],
               '_is_editable': True,
               '_force_gui_location_to': 2,
               '_color': 'z_BLUE',
               '_edit_increment': 0.0005,
               '_unit': 'm'
            }
      },
      'ML Knob': {
            'translation_0': {
               'args': ['y', 0.013000000000000001],
               '_is_editable': True,
               '_force_gui_location_to': 1,
               '_edit_increment': 0.0005,
               '_color': 'y_GREEN',
               '_unit': 'm'
            }
      },
      'AP2': {
            'translation_0': {
               'args': ['x', "csts['d3']/2 - csts['L7'] + csts['L8'] - csts['L9'] - csts['L10'] - csts['d4']/2"],
               '_is_editable': False
            }
      },
      'ML2': {
            'translation_0': {
               'args': ['y', "-csts['d3']/2 + csts['L11'] - csts['L12'] + csts['d4']/2"],
               '_is_editable': False
            }
      },
      'DV2': {
            'translation_0': {
               'args': ['z', "csts['L13'] - csts['L14']"],
               '_is_editable': False
            }
      }
   }
}
  • Dummy probe attachment Armature

# Armature configuration definition
{
   '_armature_joints': {
      'DummyProbe arm': {
            'translation_0': {
               'args': ['z', -0.1465]
            }
      }
   }
}

Base Armature API reference

class coperniFUS.modules.armatures.base_armature.Armature(armature_display_name, parent_viewer, stereotax_frame_instance, **kwargs)[source]

Bases: object

property uneval_armature_config_dict

Unevaluated armature configuration dictionary. A non-jsonable copy of the dict with expression strings evaluated is available by calling armature_config_dict

property armature_config_dict

Armature configuration dictionary with expression strings fully evaluated.

property armature_config_csts

Set of constants defined by the user in the armature configuration panel (dictionary).

get_joints(armature_config_dict=None)[source]

Get the list of joints names defined in the _armature_joints section of the armature_config_dict

get_joint_transforms(joint_id, armature_config_dict=None)[source]

Get the affine transmation matrix associated to a given armature joint_id. Joint identifiers can be obtained by calling get_joints().

property end_transform_mat

Returns the transform matrix of the last joint in the armature

property armature_tooltip_tmat
property visible

Armature visibility in viewer

property rgba_color

Armature joints color in viewer

property glline_width

Armature joints line width in viewer

add_render()[source]

Called when populating the viewer with the module rendered objects

update_render(force_update=False)[source]

Called on render view updates

delete_render()[source]

Called on deletion of the module rendered objects

get_armature_user_param(param_name, default_value=None)[source]

Get armature configuration parameter stored in cache (or default values if non existant)

set_armature_user_param(param_name, param_value)[source]

Set armature configuration parameter to cache

custom_armature_param_widgets(armature_params_rowcount, armature_params_colcount)[source]

List of widgets to be added in the Armature Parameters section of the Stereotaxic Frame Module dock.