Skip to content

mpfi-dsp/AnnotationScaler

Repository files navigation

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)

About

A Dragonfly 3D World plugin to scale annotations. Useful when changing the voxel spacing of 3D image data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors