Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 1.13 KB

File metadata and controls

26 lines (19 loc) · 1.13 KB

Annotation Scaler

Rescale annotations in the Dragonfly 3D World software. Made at the Max Planck Florida Institute for Neuroscience.

For unknown reasons, this plugin only works correctly when running it using the ORS minimal startup script (i.e., developer mode). It does not work when starting dragonfly.exe.

You may also use this script in the Python developer console to scale annotations without installing the plugin. (The above warning does not apply to this small script below):

# Before running the code below, select the annotations you want to scale in the right sidebar

initial_scale = [x, y, z]  # Put the current voxel scale (e.g., in nm, mm, etc.)
final_scale = [x, y, z]  # Put the voxel scale to translate to (in the same units as scale_initial)

import numpy as np

scale = np.array(final_scale) / np.array(initial_scale)
scale_ors = Vector3()
scale_ors.setXYZ(*scale)
mat = Matrix4x4()
mat.setupAsIdentity()
mat.setScale(scale_ors)

selected_annotations = WorkingContext.getEntitiesOfClassAsObjects(None, OrsSelectedObjects, Annotation)

for annotation in selected_annotations:
    annotation.applyTransformation(mat, 0)