pymmcore_plus.model
¶
An in-memory model of a Micro-Manager configuration.
This can be used to read, edit and write .cfg files without loading any devices.
Classes
| Name | Description |
|---|---|
AvailableDevice |
Model of an available device, with a possible hub parent. |
ConfigGroup |
ConfigGroup model. |
ConfigPreset |
ConfigPreset model. |
CoreDevice |
|
Device |
Model of a device. |
Microscope |
Full model of a microscope. |
PixelSizeGroup |
Model of the pixel size group. |
PixelSizePreset |
PixelSizePreset model. |
Property |
Model of a device property. |
Setting |
Model of a device setting. |
Classes¶
ConfigGroup
dataclass
¶
ConfigGroup(name: str, presets: MutableMapping[str, ConfigPreset] = dict())
ConfigGroup model.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
presets |
MutableMapping[str, ConfigPreset]
|
|
update_from_core
¶
update_from_core(core: CMMCorePlus) -> None
Update this object's values from the core.
all_config_groups
staticmethod
¶
all_config_groups(core: CMMCorePlus) -> dict[str, ConfigGroup]
Get all config presets from the given core.
ConfigPreset
dataclass
¶
Setting
¶
Bases: NamedTuple
Model of a device setting.
Attributes:
| Name | Type | Description |
|---|---|---|
device_name |
str
|
|
property_name |
str
|
|
property_value |
str
|
|
CoreDevice
dataclass
¶
CoreDevice(
name: str = CORE,
library: str = "",
adapter_name: str = CORE,
description: str = "Core device",
device_type: DeviceType = Core,
properties: list[Property] = _core_props(),
delay_ms: float = 0.0,
uses_delay: bool = False,
parent_label: str = "",
initialized: bool = False,
labels: tuple[str, ...] = tuple(),
focus_direction: FocusDirection = Unknown,
children: tuple[str, ...] = tuple(),
)
Bases: Device
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
library |
str
|
|
adapter_name |
str
|
|
description |
str
|
|
device_type |
DeviceType
|
|
properties |
list[Property]
|
|
delay_ms |
float
|
|
uses_delay |
bool
|
|
parent_label |
str
|
|
initialized |
bool
|
|
labels |
tuple[str, ...]
|
|
focus_direction |
FocusDirection
|
|
children |
tuple[str, ...]
|
|
AvailableDevice
dataclass
¶
AvailableDevice(
name: str = UNDEFINED,
library: str = "",
adapter_name: str = "",
description: str = "",
device_type: DeviceType = Any,
properties: list[Property] = list(),
delay_ms: float = 0.0,
uses_delay: bool = False,
parent_label: str = "",
initialized: bool = False,
labels: tuple[str, ...] = tuple(),
focus_direction: FocusDirection = Unknown,
children: tuple[str, ...] = tuple(),
library_hub: AvailableDevice | None = None,
)
Bases: Device
Model of an available device, with a possible hub parent.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
library |
str
|
|
adapter_name |
str
|
|
description |
str
|
|
device_type |
DeviceType
|
|
properties |
list[Property]
|
|
delay_ms |
float
|
|
uses_delay |
bool
|
|
parent_label |
str
|
|
initialized |
bool
|
|
labels |
tuple[str, ...]
|
|
focus_direction |
FocusDirection
|
|
children |
tuple[str, ...]
|
|
library_hub |
AvailableDevice | None
|
|
Device
dataclass
¶
Device(
name: str = UNDEFINED,
library: str = "",
adapter_name: str = "",
description: str = "",
device_type: DeviceType = Any,
properties: list[Property] = list(),
delay_ms: float = 0.0,
uses_delay: bool = False,
parent_label: str = "",
initialized: bool = False,
labels: tuple[str, ...] = tuple(),
focus_direction: FocusDirection = Unknown,
children: tuple[str, ...] = tuple(),
)
Bases: CoreObject
Model of a device.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
library |
str
|
|
adapter_name |
str
|
|
description |
str
|
|
device_type |
DeviceType
|
|
properties |
list[Property]
|
|
delay_ms |
float
|
|
uses_delay |
bool
|
|
parent_label |
str
|
|
initialized |
bool
|
|
labels |
tuple[str, ...]
|
|
focus_direction |
FocusDirection
|
|
children |
tuple[str, ...]
|
|
port
property
writable
¶
port: str | None
Returns the value of the first property named "Port".
Returns None if the device has no port property.
set_prop_default
¶
Works similar to dict.set_default. Add property if it doesn't exist.
create_from_core
classmethod
¶
create_from_core(core: CMMCorePlus, *args: Any, **kwargs: Any) -> Device
update_from_core
¶
update_from_core(
core: CMMCorePlus,
*,
exclude: Container[str] = (),
on_err: ErrCallback | None = None,
) -> None
Update device properties from the core.
load
¶
load(core: CMMCorePlus, *, reload: bool = False) -> None
Load device properties from the core.
initialize
¶
initialize(
core: CMMCorePlus,
*,
apply_pre_init: bool = False,
reload: bool = False,
then_update: bool = True,
) -> None
Initialize the device in core.
apply_to_core
¶
apply_to_core(
core: CMMCorePlus,
*,
exclude: Container[str] = ("delay_ms",),
on_err: ErrCallback | None = None,
apply_properties: bool = True,
then_update: bool = True,
) -> None
loaded_peripherals
¶
loaded_peripherals(core: CMMCorePlus) -> tuple[str, ...]
Return device labels of all loaded devices that belong to this hub.
NOTE: unlike "available_peripherals", this returns device labels currently loaded into core. It does not check whether the devices are in the model.
available_peripherals
¶
available_peripherals(model: Microscope) -> Iterable[AvailableDevice]
Return all available devices that belong to this hub that aren't in model.
Microscope
dataclass
¶
Microscope(
core_device: CoreDevice = CoreDevice(),
devices: list[Device] = list(),
config_groups: dict[str, ConfigGroup] = dict(),
pixel_size_group: PixelSizeGroup = PixelSizeGroup(),
config_file: str = "",
initialized: bool = False,
)
Full model of a microscope.
Attributes:
| Name | Type | Description |
|---|---|---|
core_device |
CoreDevice
|
CoreDevice(name: 'str' = 'Core', library: 'str' = '', adapter_name: 'str' = 'Core', description: 'str' = 'Core device', device_type: 'DeviceType' = |
devices |
list[Device]
|
|
config_groups |
dict[str, ConfigGroup]
|
|
pixel_size_group |
PixelSizeGroup
|
Model of the pixel size group. |
config_file |
str
|
|
initialized |
bool
|
|
assigned_com_ports
property
¶
Return map of SerialDevice -> DeviceUsingIt.
A com port is "claimed" if it is assigned to a device.
available_serial_devices
property
¶
Return the available com ports.
filter_devices
¶
filter_devices(
name: str | None = None,
library: str | None = None,
adapter_name: str | None = None,
description: str | None = None,
device_type: DeviceType | str | None = None,
parent_label: str | None = None,
) -> Iterable[Device]
Filter devices by name .
load_config
¶
Load model from a micro-manager config file or string.
from_summary_metadata
classmethod
¶
from_summary_metadata(summary_meta: SummaryMetaV1) -> Microscope
Create a Microscope model from summary metadata.
This may be used to load a model from summary metadata, such as as written during the course of a Multi-Dimensional Acquisition. This is useful for restoring the state of a microscope from a specific experiment, or writing out a cfg file that can be used to restore the state of the microscope.
create_from_core
classmethod
¶
create_from_core(core: CMMCorePlus, *args: Any, **kwargs: Any) -> Microscope
update_from_core
¶
update_from_core(
core: CMMCorePlus,
*,
exclude: Container[str] = (),
on_err: ErrCallback | None = None,
) -> None
Update this object's values from the core.
apply_to_core
¶
apply_to_core(
core: CMMCorePlus,
*,
exclude: Container[str] = (),
on_err: ErrCallback | None = None,
apply_properties: bool = True,
then_update: bool = True,
) -> None
initialize
¶
initialize(
core: CMMCorePlus,
on_fail: Callable[[Device | Property, BaseException], bool | None] = _noop,
) -> None
Attempt to initialize all devices in the model.
Simulates what MMCore does upon loading config file.
load_available_devices
¶
load_available_devices(core: CMMCorePlus) -> None
Load the available device list.
update_config_groups_from_core
¶
update_config_groups_from_core(core: CMMCorePlus) -> None
Load config groups from the core.
update_pixel_sizes_from_core
¶
update_pixel_sizes_from_core(core: CMMCorePlus) -> None
Load pixel size groups from the core.
PixelSizeGroup
dataclass
¶
PixelSizeGroup(
name: str = PIXEL_SIZE_GROUP,
presets: MutableMapping[str, PixelSizePreset] = dict(),
)
Bases: ConfigGroup
Model of the pixel size group.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
presets |
MutableMapping[str, PixelSizePreset]
|
|
from_metadata
classmethod
¶
from_metadata(meta: tuple[PixelSizeConfigPreset, ...]) -> Self
Create a PixelSizeGroup from metadata.
create_from_core
classmethod
¶
create_from_core(
core: CMMCorePlus, name: str = PIXEL_SIZE_GROUP
) -> PixelSizeGroup
Create pixel size presets from the given core.
PixelSizePreset
dataclass
¶
PixelSizePreset(
name: str,
settings: list[Setting] = list(),
pixel_size_um: float = 0.0,
affine: AffineTuple = DEFAULT_AFFINE,
angle_dxdz: float = 0.0,
angle_dydz: float = 0.0,
optimalz_um: float = 0.0,
)
Bases: ConfigPreset
PixelSizePreset model.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
settings |
list[Setting]
|
|
pixel_size_um |
float
|
|
affine |
AffineTuple
|
|
angle_dxdz |
float
|
|
angle_dydz |
float
|
|
optimalz_um |
float
|
|
Property
dataclass
¶
Property(
device_name: str,
name: str,
value: str = "",
is_read_only: bool = False,
is_pre_init: bool = False,
allowed_values: tuple[str, ...] = tuple(),
has_limits: bool = False,
lower_limit: float = 0.0,
upper_limit: float = 0.0,
property_type: PropertyType = Undef,
)
Bases: CoreObject
Model of a device property.
Attributes:
| Name | Type | Description |
|---|---|---|
device_name |
str
|
|
name |
str
|
|
value |
str
|
|
is_read_only |
bool
|
|
is_pre_init |
bool
|
|
allowed_values |
tuple[str, ...]
|
|
has_limits |
bool
|
|
lower_limit |
float
|
|
upper_limit |
float
|
|
property_type |
PropertyType
|
|
apply_to_core
¶
apply_to_core(
core: CMMCorePlus,
*,
exclude: Container[str] = (),
on_err: ErrCallback | None = None,
then_update: bool = True,
) -> None
Apply the property to the given Core instance.