Skip to content

Commit d8c579c

Browse files
committed
change file type
1 parent f0c38f7 commit d8c579c

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

micro-manager_setup.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Setup and examples for using the ExEngine with a micro-manager backend
2+
3+
- clone the repository
4+
- install it, specifying which device and data storage backends
5+
`pip install -e ".[micromanager, ndstorage]"`
6+
- install Micro-Manager
7+
8+
```python
9+
from mmpycorex import download_and_install_mm
10+
download_and_install_mm()
11+
```
12+
13+
14+
## Running the ExEngine
15+
16+
```python
17+
from mmpycorex import create_core_instance, download_and_install_mm, terminate_core_instances
18+
from exengine.kernel.executor import ExecutionEngine
19+
from exengine.kernel.data_coords import DataCoordinates
20+
from exengine.kernel.ex_event_base import DataHandler
21+
from exengine.backends.micromanager.mm_device_implementations import MicroManagerCamera, MicroManagerSingleAxisStage
22+
from exengine.storage_backends.NDTiffandRAM import NDRAMStorage
23+
from exengine.events.detector_events import StartCapture, ReadoutData
24+
25+
26+
# Start Micro-Manager core instance with Demo config
27+
create_core_instance()
28+
29+
executor = ExecutionEngine()
30+
31+
32+
# get access to the micro-manager devices
33+
camera = MicroManagerCamera()
34+
z_stage = MicroManagerSingleAxisStage()
35+
36+
```
37+
38+
39+
### Example 1: Use the exengine to acquire a timelapse
40+
41+
```python
42+
# Capture 100 images on the camera
43+
num_images = 100
44+
data_handler = DataHandler(storage=NDRAMStorage())
45+
46+
start_capture_event = StartCapture(num_images=num_images, detector=camera)
47+
readout_images_event = ReadoutData(num_images=num_images, detector=camera,
48+
data_coordinates_iterator=[DataCoordinates(time=t) for t in range(num_images)],
49+
data_handler=data_handler)
50+
51+
_ = executor.submit(start_capture_event)
52+
future = executor.submit(readout_images_event)
53+
54+
# block until all images have been read out
55+
future.await_execution()
56+
57+
# Tell the data handler no more images are expected
58+
data_handler.finish()
59+
60+
```
61+
62+
### Example 2: create series of events with multi-d function
63+
```python
64+
from exengine.events.multi_d_events import multi_d_acquisition_events
65+
66+
data_handler = DataHandler(storage=NDRAMStorage())
67+
events = multi_d_acquisition_events(z_start=0, z_end=10, z_step=2)
68+
69+
futures = executor.submit(events)
70+
# wait until the final event finished
71+
futures[-1].await_execution()
72+
73+
# Tell the data handler no more images are expected
74+
data_handler.finish()
75+
```
76+
77+
78+
```python
79+
# shutdown the engine
80+
executor.shutdown()
81+
# shutdown micro-manager
82+
terminate_core_instances()
83+
```

0 commit comments

Comments
 (0)