Multi-Dimensional Acquisition#
The mda
attribute on the
CMMCorePlus
object provides a high-level
interface for running multi-dimensional microscopy experiments.
pymmcore_plus.mda.MDARunner
#
Object that executes a multi-dimensional experiment using an MDAEngine.
This object is available at CMMCorePlus.mda
.
This is the main object that runs a multi-dimensional experiment; it does so by
driving an acquisition engine that implements the
PMDAEngine
protocol. It emits signals at specific
times during the experiment (see
PMDASignaler
for details on the signals
that are available to connect to and when they are emitted).
Source code in pymmcore_plus/mda/_runner.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
cancel() -> None
#
Cancel the currently running acquisition.
This is a no-op if no acquisition is currently running. If an acquisition is running then this will cancel the acquisition and a sequenceCanceled signal, followed by a sequenceFinished signal will be emitted.
Source code in pymmcore_plus/mda/_runner.py
140 141 142 143 144 145 146 147 148 149 |
|
engine() -> MDAEngine | None
property
#
The PMDAEngine
that is currently being used.
Source code in pymmcore_plus/mda/_runner.py
99 100 101 102 |
|
event_seconds_elapsed() -> float
#
Return the number of seconds on the "event clock".
This is the time since either the start of the acquisition or the last
event with reset_event_timer
set to True
.
Source code in pymmcore_plus/mda/_runner.py
213 214 215 216 217 218 219 |
|
events() -> PMDASignaler
property
#
Signals that are emitted during the MDA run.
See PMDASignaler
for details on the
signals that are available to connect to.
Source code in pymmcore_plus/mda/_runner.py
104 105 106 107 108 109 110 111 |
|
is_paused() -> bool
#
Return True if the acquisition is currently paused.
Use toggle_pause
to change the paused state.
Returns:
Type | Description |
---|---|
bool
|
Whether the current acquisition is paused. |
Source code in pymmcore_plus/mda/_runner.py
128 129 130 131 132 133 134 135 136 137 138 |
|
is_running() -> bool
#
Return True if an acquisition is currently underway.
This will return True at any point between the emission of the
sequenceStarted
and
sequenceFinished
signals,
including when the acquisition is currently paused.
Returns:
Type | Description |
---|---|
bool
|
Whether an acquisition is underway. |
Source code in pymmcore_plus/mda/_runner.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
run(events: Iterable[MDAEvent], *, output: SingleOutput | Sequence[SingleOutput] | None = None) -> None
#
Run the multi-dimensional acquisition defined by sequence
.
Most users should not use this directly as it will block further
execution. Instead, use the
CMMCorePlus.run_mda
method which will
run on a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
events |
Iterable[MDAEvent]
|
An iterable of |
required |
output |
SingleOutput | Sequence[SingleOutput] | None, optional
|
The output handler(s) to use. If None, no output will be saved. The value may be either a single output or a sequence of outputs, where a "single output" can be any of the following:
|
None
|
Source code in pymmcore_plus/mda/_runner.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
seconds_elapsed() -> float
#
Return the number of seconds since the start of the acquisition.
Source code in pymmcore_plus/mda/_runner.py
209 210 211 |
|
set_engine(engine: PMDAEngine) -> PMDAEngine | None
#
Set the PMDAEngine
to use for the MDA run.
Source code in pymmcore_plus/mda/_runner.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
toggle_pause() -> None
#
Toggle the paused state of the current acquisition.
To get whether the acquisition is currently paused use the
is_paused
method. This method is a
no-op if no acquisition is currently underway.
Source code in pymmcore_plus/mda/_runner.py
151 152 153 154 155 156 157 158 159 160 |
|
pymmcore_plus.mda.PMDAEngine
#
Protocol that all MDA engines must implement.
event_iterator(events: Iterable[MDAEvent]) -> Iterator[MDAEvent]
#
Wrapper on the event iterator.
Optional.
This can be used to wrap the event iterator to perform any event merging
(e.g. if the engine supports HardwareSequencing) or event modification.
The default implementation is just iter(events)
.
Be careful when using this method. It is powerful and can result in unexpected event iteration if used incorrectly.
exec_event(event: MDAEvent) -> Iterable[PImagePayload]
abstractmethod
#
Execute event
.
This method is called after setup_event
and is responsible for
executing the event. The default assumption is to acquire an image,
but more elaborate events will be possible.
The protocol for the returned object is still under development. However, if
the returned object has an image
attribute, then the
MDARunner
will emit a
frameReady
signal
setup_event(event: MDAEvent) -> None
abstractmethod
#
Prepare state of system (hardware, etc.) for event
.
This method is called before each event in the sequence. It is
responsible for preparing the state of the system for the event.
The engine should be in a state where it can call exec_event
without any additional preparation. (This means that the engine
should perform any waits or blocks required for system state
changes to complete.)
setup_sequence(sequence: MDASequence) -> SummaryMetaV1 | None
abstractmethod
#
Setup state of system (hardware, etc.) before an MDA is run.
This method is called once at the beginning of a sequence.
teardown_event(event: MDAEvent) -> None
#
Teardown state of system (hardware, etc.) after event
.
Optional.
If the engine provides this function, it will be called after
exec_event
to perform any cleanup or teardown required after
the event has been executed.
teardown_sequence(sequence: MDASequence) -> None
#
Perform any teardown required after the sequence has been executed.
Optional.
If the engine provides this function, it will be called after the last event in the sequence has been executed.
pymmcore_plus.mda.MDAEngine
#
The default MDAengine that ships with pymmcore-plus.
This implements the PMDAEngine
protocol, and
uses a CMMCorePlus
instance to control the hardware.
It may be subclassed to provide custom behavior, or to override specific methods. https://pymmcore-plus.github.io/pymmcore-plus/guides/custom_engine/
Attributes:
Name | Type | Description |
---|---|---|
mmcore |
CMMCorePlus
|
The |
use_hardware_sequencing |
bool
|
Whether to use hardware sequencing if possible. If |
Source code in pymmcore_plus/mda/_engine.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
|
use_hardware_sequencing: bool = use_hardware_sequencing
instance-attribute
#
event_iterator(events: Iterable[MDAEvent]) -> Iterator[MDAEvent]
#
Event iterator that merges events for hardware sequencing if possible.
This wraps for event in events: ...
inside MDARunner.run()
and combines
sequenceable events into an instance of SequencedEvent
if
self.use_hardware_sequencing
is True
.
Source code in pymmcore_plus/mda/_engine.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
exec_event(event: MDAEvent) -> Iterable[PImagePayload]
#
Execute an individual event and return the image data.
Source code in pymmcore_plus/mda/_engine.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
exec_sequenced_event(event: SequencedEvent) -> Iterable[PImagePayload]
#
Execute a sequenced (triggered) event and return the image data.
This method is not part of the PMDAEngine protocol (it is called by
exec_event
, which is part of the protocol), but it is made public
in case a user wants to subclass this engine and override this method.
Source code in pymmcore_plus/mda/_engine.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
|
exec_single_event(event: MDAEvent) -> Iterator[PImagePayload]
#
Execute a single (non-triggered) event and return the image data.
This method is not part of the PMDAEngine protocol (it is called by
exec_event
, which is part of the protocol), but it is made public
in case a user wants to subclass this engine and override this method.
Source code in pymmcore_plus/mda/_engine.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
get_frame_metadata(event: MDAEvent, prop_values: tuple[PropertyValue, ...] | None = None, runner_time_ms: float = 0.0, include_position: bool = True, camera_device: str | None = None) -> FrameMetaV1
#
Source code in pymmcore_plus/mda/_engine.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
get_summary_metadata(mda_sequence: MDASequence | None) -> SummaryMetaV1
#
Source code in pymmcore_plus/mda/_engine.py
142 143 |
|
include_frame_position_metadata() -> IncludePositionArg
writable
property
#
Source code in pymmcore_plus/mda/_engine.py
102 103 104 |
|
mmcore() -> CMMCorePlus
property
#
The CMMCorePlus
instance to use for hardware control.
Source code in pymmcore_plus/mda/_engine.py
115 116 117 118 |
|
post_sequence_started(event: SequencedEvent) -> None
#
Perform any actions after startSequenceAcquisition has been called.
This method is available to subclasses in case they need to perform any actions after a hardware-triggered sequence has been started (i.e. after core.startSequenceAcquisition has been called).
The default implementation does nothing.
Source code in pymmcore_plus/mda/_engine.py
435 436 437 438 439 440 441 442 443 |
|
setup_event(event: MDAEvent) -> None
#
Set the system hardware (XY, Z, channel, exposure) as defined in the event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
MDAEvent
|
The event to use for the Hardware config |
required |
Source code in pymmcore_plus/mda/_engine.py
160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
setup_sequence(sequence: MDASequence) -> SummaryMetaV1 | None
#
Setup the hardware for the entire sequence.
Source code in pymmcore_plus/mda/_engine.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
setup_sequenced_event(event: SequencedEvent) -> None
#
Setup hardware for a sequenced (triggered) event.
This method is not part of the PMDAEngine protocol (it is called by
setup_event
, which is part of the protocol), but it is made public
in case a user wants to subclass this engine and override this method.
Source code in pymmcore_plus/mda/_engine.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
|
setup_single_event(event: MDAEvent) -> None
#
Setup hardware for a single (non-sequenced) event.
This method is not part of the PMDAEngine protocol (it is called by
setup_event
, which is part of the protocol), but it is made public
in case a user wants to subclass this engine and override this method.
Source code in pymmcore_plus/mda/_engine.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
teardown_event(event: MDAEvent) -> None
#
Teardown state of system (hardware, etc.) after event
.
Source code in pymmcore_plus/mda/_engine.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
teardown_sequence(sequence: MDASequence) -> None
#
Perform any teardown required after the sequence has been executed.
Source code in pymmcore_plus/mda/_engine.py
358 359 360 |
|