BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3
19
20import enum
21import typing
22
23
24class MicroscopeError(Exception):
25 """Base class for Python Microscope exceptions."""
26
27 pass
28
29
31 """Raised when there is an issue controlling a device.
32
33 This exception is raised when there is an issue with controlling
34 the device, be it with its programming interface or with the
35 physical hardware. It is most common when commands to the device
36 fail or return something unexpected.
37
38 .. note::
39
40 The subclasses `DisabledDeviceError`, `IncompatibleStateError`,
41 `InitialiseError`, and `UnsupportedFeatureError` provide more
42 fine grained exceptions.
43
44 """
45
46 pass
47
48
50 """Raised when an operation is incompatible with the current device
51 state.
52
53 This exception is raised when the device is in a state
54 incompatible with an attempted operation, e.g., calling
55 :mod:`TriggerTargetMixin.trigger` on a device that is set for
56 hardware triggers. The subclass `DisabledDeviceError` provides an
57 exception specific to the case where the issue is the device being
58 disabled.
59
60 .. note::
61
62 This exception is for attempting to perform some action but
63 device is wrong state. If the issue is about a setting that is
64 incompatible with some other setting that this specific device
65 does not support, then `UnsupportedFeatureError` should be
66 raised.
67
68 """
69
70 pass
71
72
74 """Raised when an operation requires an enabled device but the device is
75 disabled.
76 """
77
78 pass
79
80
82 """Raised when a device fails to initialise.
83
84 This exception is raised when there is a failure connecting to a
85 device, typically because the device is not connected, or the serial
86 number or port address is incorrect.
87
88 """
89
90 pass
91
92
94 """Raised when some operation requires a feature that is not supported.
95
96 This exception is raised when an operation requires some feature
97 that is not supported, either because the physical device does not
98 provide it, or Python Microscope has not yet implemented it. For
99 example, most devices do not support all trigger modes.
100
101 """
102
103 pass
104
105
107 """Raised when the loading and initialisation of a device library fails.
108
109 This exception is raised when a shared library or DLL fails to load,
110 typically because the required library is not found or is missing
111 some required symbol.
112
113 If there is a module that is a straight wrapper to the C library
114 (there should be one on the `microscope._wrappers` package) then
115 this exception can easily be used chained with the exception that
116 originated it like so::
117
118 .. code-block:: python
119
120 try:
121 import microscope._wrappers.libname
122 except Exception as e:
123 raise microscope.LibraryLoadError(e) from e
124
125 """
126
127 pass
128
129
130class AxisLimits(typing.NamedTuple):
131 """Limits of a :class:`microscope.abc.StageAxis`."""
132
133 lower: float
134 upper: float
135
136
137class Binning(typing.NamedTuple):
138 """A tuple containing parameters for horizontal and vertical binning."""
139
140 h: int
141 v: int
142
143
144class ROI(typing.NamedTuple):
145 """A tuple that defines a region of interest.
146
147 This rectangle format completely defines the ROI without reference
148 to the sensor geometry.
149 """
150
151 left: int
152 top: int
153 width: int
154 height: int
155
156
157class TriggerType(enum.Enum):
158 """Type of a trigger for a :class:`microscope.abc.TriggerTargetMixin`.
159
160 The trigger type defines what constitutes a trigger, as opposed to
161 the trigger mode which defines a type of action when the trigger
162 is received.
163
164 :const:`TriggerType.SOFTWARE`
165 when :meth:`microscope.abc.TriggerTargetMixin.trigger` is called
166 :const:`TriggerType.RISING_EDGE`
167 when level changes to high
168 :const:`TriggerType.FALLING_EDGE`
169 when level changes to low
170 """
171
172 SOFTWARE = 0
173 RISING_EDGE = 1
174 HIGH = 1
175 FALLING_EDGE = 2
176 LOW = 2
177 PULSE = 3
178
179
180class TriggerMode(enum.Enum):
181 """Mode of a trigger for a :class:`microscope.abc.TriggerTargetMixin`.
182
183 The trigger mode defines what type of action when a trigger is
184 received, as opposed to the trigger type which defines what
185 constitutes a trigger. The exact type of action is highly
186 dependent on device type, so check their documentation.
187
188 :const:`TriggerMode.ONCE`
189 Act once. For example, acquire a single image when a camera
190 is triggered.
191 :const:`TriggerMode.BULB`
192 Act while device is being triggered. For example, a laser
193 keeps emitting emit light or a camera keeps exposing while the
194 trigger line is high. This trigger mode is incompatible with
195 :attr:`TriggerType.SOFTWARE`.
196 :const:`TriggerMode.STROBE`
197 Act repeatably while device is being triggered. For example,
198 a camera keep acquiring multiple images while the trigger line
199 is high.
200 """
201
202 ONCE = 1
203 BULB = 2
204 STROBE = 3
205 START = 4