Skip to content

Commit

Permalink
Merge pull request #801 from HazenBabcock/scripts/introspection
Browse files Browse the repository at this point in the history
Introspection examples script.
  • Loading branch information
henrypinkard authored Nov 6, 2024
2 parents fa0052b + 747a113 commit c68499c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions scripts/introspection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
This example shows how to do basic micro-manager introspection using
pycro-manager.
"""

from pycromanager import Core


# Connect to MM.
core = Core()


# Current configuration.
def current_config():
devices = core.get_loaded_devices()
for i in range(devices.size()):
devstr = devices.get(i)
print("Device: ", devstr)

pnames = core.get_device_property_names(devstr)

for j in range(pnames.size()):
pname = pnames.get(j)
pvalue = core.get_property(devstr, pname)
ptype = core.get_property_type(devstr, pname).to_string()
print(f" {devstr}-{pname} '{pvalue}' {ptype}")
print()


# Current ROI.
def current_roi():
roi = core.get_roi()
print(f"x: {roi.x}, y: {roi.y}, width: {roi.width}, height: {roi.height}")


# Properties of a JAVA object.
def pyjavaz_props():
roi = core.get_roi()
print(dir(roi))


print("Example JAVA object properties:")
pyjavaz_props()
print()

print("Getting the current ROI:")
current_roi()
print()

print("Getting the current configuration:")
current_config()
print()

0 comments on commit c68499c

Please sign in to comment.