Controllers¶
optari.controllers.base ¶
Base class for task-specific controllers.
TaskControllerBase ¶
TaskControllerBase(parent_controller)
Minimal interface for task controllers.
Each task controller (Analysis, Unmixing, etc) inherits from this.
A controller that runs heavy work implements three methods and gets the dock's
Run button (run_from_ui) for free:
_params_from_ui()reads the dock into a params object, raising ValueError with a user-facing message when the run cannot be set upprepare(params)validates and returns aBackgroundStep, raising ValueErrorpublish(result, params)adds the layers and returns the text shown after "Finished:"
Batch mode builds params from a preset instead and calls the same prepare and
publish, which is what keeps its numbers equal to the GUI's.
Initialize with reference to parent controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_controller
|
OptariController
|
OptariController instance with viewer and session state. |
required |
Source code in src/optari/controllers/base.py
49 50 51 52 53 54 55 56 | |
bind_events ¶
bind_events()
Connect this controller's dock signals to their handlers.
Source code in src/optari/controllers/base.py
70 71 72 73 | |
initialize_ui ¶
initialize_ui()
Initialize UI controls (populate lists, combos, etc). Override if needed.
Source code in src/optari/controllers/base.py
58 59 60 | |
refresh_ui ¶
refresh_ui()
Refresh controller-owned UI after application state changes.
Source code in src/optari/controllers/base.py
84 85 86 | |
run_from_ui ¶
run_from_ui(dock)
The dock's Run button: params from widgets, fetch weights if needed, run, publish.
Source code in src/optari/controllers/base.py
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 | |
teardown ¶
teardown()
Release resources (models, threads). Override if needed.
Source code in src/optari/controllers/base.py
80 81 82 | |
unbind_events ¶
unbind_events()
Disconnect everything bind_events connected.
Source code in src/optari/controllers/base.py
75 76 77 78 | |
weights_to_fetch ¶
weights_to_fetch(params)
(local path, download url) a run needs on disk before it can start, or None.
Source code in src/optari/controllers/base.py
89 90 91 | |
optari.controllers.scan_controller ¶
Scan and study discovery, and loading a scan into the viewer.
ScanController ¶
ScanController(parent_controller)
Bases: TaskControllerBase
Scan/session lifecycle and data-loading helpers for OPTARI.
Initialize with reference to parent controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_controller
|
OptariController
|
OptariController instance with viewer and session state. |
required |
Source code in src/optari/controllers/scan_controller.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
close_current_scan ¶
close_current_scan()
Close the HDF5 handle for the current scan.
Source code in src/optari/controllers/scan_controller.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
get_fov ¶
get_fov()
Return (fov_x_m, fov_y_m) from stored PATATO objects, or None.
Source code in src/optari/controllers/scan_controller.py
362 363 364 | |
go_to_frame ¶
go_to_frame(selector)
Show the frame selector means for the loaded scan, and return it.
"spectral_motion" and "frame_motion" are the frame with the lowest score
of that kind in motion_scores(). A scan without spectral motion (one image per
wav set) uses frame-to-frame motion instead. A scan with no ultrasound (a raw time
series) has nothing to score and falls back to frame 0.
"acquisition_start" is the ithera recording start frame
"roi" is the first frame holding one of the scan's ROIs, frame 0 without any.
It needs the scan's ROIs restored first.
Both the viewer and a batch run go through this, so a selector means the same
frame in either.
Raises ValueError for a frame number the scan does not have.
Source code in src/optari/controllers/scan_controller.py
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 | |
init_shapes_from_scan ¶
init_shapes_from_scan()
Fill the freshly created ROIs layer with the ROIs stored in the scan.
Source code in src/optari/controllers/scan_controller.py
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 | |
layers_from_pa_data ¶
layers_from_pa_data()
Build napari LayerData tuples from the open controller.pa_data handle.
Source code in src/optari/controllers/scan_controller.py
355 356 357 358 359 360 | |
load_scan ¶
load_scan(scan_path, scan_info)
Open scan_path and build its layers. False if the scan could not be loaded.
Failures fall back to the startup logo rather than raising, which is what the GUI wants. The return value is what lets an unattended caller (batch mode) tell a loaded scan from an empty viewer. scan_info comes from discovery, so the Scan Browser's list and a batch plan can each load their own scans.
Source code in src/optari/controllers/scan_controller.py
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 | |
motion_scores ¶
motion_scores(*, compute=True)
Motion scores per frame of the loaded scan (0 = stillest, 1 = most motion),
keyed "spectral_motion" and "frame_motion", or None without ultrasound.
Spectral motion is None for a scan with one image per wav set. Both kinds are
computed together on first use and cached on the US layer.
With compute=False only cached scores are returned, which lets a
caller show them without paying for scoring.
Source code in src/optari/controllers/scan_controller.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
on_browse_study_clicked ¶
on_browse_study_clicked()
Prompt for a study folder, the folder that contains the scans.
Source code in src/optari/controllers/scan_controller.py
120 121 122 123 124 125 126 | |
on_hdf5_export_clicked ¶
on_hdf5_export_clicked(event=None)
Prompt for a destination and export the current scan to HDF5.
Source code in src/optari/controllers/scan_controller.py
398 399 400 401 402 403 404 405 | |
on_ipasc_export_clicked ¶
on_ipasc_export_clicked(event=None)
Prompt for a destination and export the current scan's raw time series as IPASC.
Source code in src/optari/controllers/scan_controller.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |
on_scan_selected ¶
on_scan_selected(row)
Load the scan at row in the scan list, ignoring an out-of-range selection.
Source code in src/optari/controllers/scan_controller.py
128 129 130 131 132 133 | |
refresh_ui ¶
refresh_ui()
Lock the scan browser while a task runs, and gate HDF5 export on a scan being loaded.
Source code in src/optari/controllers/scan_controller.py
72 73 74 75 76 77 78 79 80 81 82 | |
reset_scan_state ¶
reset_scan_state(restore_startup_logo=True)
Clear current scan state and remove all viewer layers.
Source code in src/optari/controllers/scan_controller.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
scan_name ¶
scan_name()
The scan's internal (vendor) name, for stamping onto layers OPTARI creates.
Source code in src/optari/controllers/scan_controller.py
84 85 86 | |
set_scan_folder ¶
set_scan_folder(folder)
Discover scans in folder and select the first one.
Source code in src/optari/controllers/scan_controller.py
135 136 137 138 139 140 141 142 143 144 145 | |
optari.controllers.roi_controller ¶
Owns the ROI shapes layer, the Live and Saved Analysis tables, and ROI presets and placement.
RoiController ¶
RoiController(parent_controller)
Bases: TaskControllerBase
ROI visualization, table management, and ROI export helpers.
Initialize with reference to parent controller.
Sets up the ROI record store, the session's autosaved Saved Analysis table, and the ROI preset store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_controller
|
OptariController
|
OptariController instance with viewer and session state. |
required |
Source code in src/optari/controllers/roi_controller.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
add_shape ¶
add_shape(verts, shape_type, tissue_class='undefined')
Add an ROI to the current frame and select it, which also enables Save.
tissue_class labels the ROI's location, e.g. the class it was placed in from a segmentation mask, and is exported with it.
Source code in src/optari/controllers/roi_controller.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
clear_roi_records ¶
clear_roi_records()
Discard all ROI records and the rasterized-mask cache, e.g. when switching scans.
Source code in src/optari/controllers/roi_controller.py
230 231 232 233 234 235 | |
current_records ¶
current_records()
Records for the ROIs currently displayed, in display order.
Source code in src/optari/controllers/roi_controller.py
237 238 239 | |
expand_current_projection_to_all_frames ¶
expand_current_projection_to_all_frames(verts_for_frame=None)
Duplicate the last-placed ROI onto every other frame, as one group.
verts_for_frame(frame_id, source_verts) lets a caller resolve each
frame's own geometry instead of reusing source_verts unchanged e.g.
auto-placement re-anchoring to that frame's own segmentation mask.
Returning None skips that frame entirely
Source code in src/optari/controllers/roi_controller.py
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 | |
initialize_ui ¶
initialize_ui()
Initialize ROI preset controls and current ROI display state.
Source code in src/optari/controllers/roi_controller.py
1370 1371 1372 1373 1374 | |
measure_selected_rois ¶
measure_selected_rois(selected_ids, *, scope=None, layers=None, clamp=None)
Measure the selected ROIs over every layer, frame and channel in scope.
scope defaults to the annotation dock's checkboxes, layers to whatever that scope resolves to and clamp to the dock's intensity filter. Batch mode passes all three, so its numbers depend on the plan alone, not on the dock.
Source code in src/optari/controllers/roi_controller.py
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 | |
on_delete_saved_clicked ¶
on_delete_saved_clicked(event=None)
Delete the selected rows from the Saved Analysis table.
Source code in src/optari/controllers/roi_controller.py
831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |
on_import_clicked ¶
on_import_clicked(event=None)
Append a previously exported table to the saved table.
Source code in src/optari/controllers/roi_controller.py
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
on_intensity_settings_changed ¶
on_intensity_settings_changed(_=None)
Read the intensity filter and measure.
Source code in src/optari/controllers/roi_controller.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
on_live_table_delete_key ¶
on_live_table_delete_key()
Delete selected shapes when Delete is pressed in the live table. on MacOS the actual Delete (forward-delete) key (Fn+Backspace) has to be pressed, not just the backspace key
Source code in src/optari/controllers/roi_controller.py
434 435 436 437 438 439 440 441 | |
on_live_table_selection_changed ¶
on_live_table_selection_changed()
Sync live table row selection → shapes layer selection.
Source code in src/optari/controllers/roi_controller.py
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 | |
on_place_roi_clicked ¶
on_place_roi_clicked(event=None)
Place the preset currently selected in the presets list, using the dock's placement and scope.
Source code in src/optari/controllers/roi_controller.py
1324 1325 1326 | |
on_remove_roi_preset_clicked ¶
on_remove_roi_preset_clicked(event=None)
Delete the preset currently selected in the presets list.
Source code in src/optari/controllers/roi_controller.py
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | |
on_restore_selected_rows ¶
on_restore_selected_rows(default_row=None)
Put the selected saved rows back into the viewer, one ROI per row. Restoring is per row, not per ROI group
Source code in src/optari/controllers/roi_controller.py
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | |
on_roi_preset_item_clicked ¶
on_roi_preset_item_clicked(item)
Place the double-clicked preset.
Source code in src/optari/controllers/roi_controller.py
1328 1329 1330 | |
on_roi_preset_item_selected ¶
on_roi_preset_item_selected(item, previous=None)
Preselect the placement for item's preset, and show its description and location.
Runs only when the selection changes, so a placement the user picked by hand survives clicking or double-clicking the same preset again.
Source code in src/optari/controllers/roi_controller.py
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 | |
on_save_clicked ¶
on_save_clicked(event=None)
Measure the ROIs selected in the viewer and add to the Saved Analysis table.
Source code in src/optari/controllers/roi_controller.py
639 640 641 642 643 644 645 646 647 648 649 650 | |
on_save_roi_preset_clicked ¶
on_save_roi_preset_clicked(event=None)
Save the first selected ROI as a named preset.
Prompts for a name, description, location and top margin. A location makes the preset placed in that segmentation class, horizontally centred, with its top the given margin below the class's top edge.
Source code in src/optari/controllers/roi_controller.py
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | |
on_saved_row_double_clicked ¶
on_saved_row_double_clicked(row, _column=0)
Restore the ROI of the double-clicked row onto that row's frame.
Source code in src/optari/controllers/roi_controller.py
877 878 879 880 881 | |
on_shapes_data_changed ¶
on_shapes_data_changed(event=None)
Sync ROI records after a completed Shapes-layer edit, then refresh the display and live table.
Runs on every mouse-move of a drag. Ignores the intent event napari fires before a mutation (only the completion event is acted on), and skips the shape-display refresh unless the set of projected ids actually changed.
Source code in src/optari/controllers/roi_controller.py
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 | |
on_shapes_selection_changed ¶
on_shapes_selection_changed(event=None)
Sync shapes selection -> live table selection on selection changes only.
Source code in src/optari/controllers/roi_controller.py
394 395 396 397 398 399 400 401 402 403 404 405 406 | |
on_shapes_set_data ¶
on_shapes_set_data(event=None)
Catch shape additions that never emit events.data.
copy/pasting shapes (e.g. from one frame to another) appends to the layer and emits
only set_data, so a pasted ROI would stay invisible. set_data also fires on every redraw,
hence the count check before doing any real work.
Source code in src/optari/controllers/roi_controller.py
585 586 587 588 589 590 591 592 593 594 595 596 | |
on_xlsx_export_clicked ¶
on_xlsx_export_clicked(event=None)
Prompt for a destination and export the Saved Analysis table to XLSX.
Source code in src/optari/controllers/roi_controller.py
846 847 848 849 850 851 852 853 | |
place_preset ¶
place_preset(preset, *, placement, all_frames)
Place preset on the current frame, and across every frame if asked.
Auto placement re-anchors onto each frame's own segmentation when expanding, so every frame gets an ROI that belongs to it. The dock and a batch run both come through here, which is what makes "measure all frames" mean the same thing in both. Raises ValueError with a user-facing message when placement fails.
Source code in src/optari/controllers/roi_controller.py
1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | |
project_current_frame ¶
project_current_frame()
Write the current frame's ROI records into the Shapes layer.
self._roi_records is the source of truth. This is the only place that
should assign shapes.data directly. Guarded by self._projecting so the
resulting data-change event doesn't sync back into the records it was
generated from.
Source code in src/optari/controllers/roi_controller.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 | |
refresh_ui ¶
refresh_ui()
Refresh ROI controls after scan or active-layer state changes.
Source code in src/optari/controllers/roi_controller.py
1376 1377 1378 1379 1380 1381 1382 1383 | |
restore_roi_records ¶
restore_roi_records(records)
Replace all ROI records with the ones stored in the scan, resuming the id counters above their highest values.
Also projects the current frame, so the Shapes layer reflects the new records.
Source code in src/optari/controllers/roi_controller.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
selected_roi_ids ¶
selected_roi_ids()
roi_ids of the ROIs selected in the viewer, empty (with a reason) if none.
Source code in src/optari/controllers/roi_controller.py
652 653 654 655 656 657 658 659 660 661 662 663 664 665 | |
sync_records_from_shapes ¶
sync_records_from_shapes()
Keep frame-owned ROI records in sync with the projected Shapes layer.
Same/grown shape count: ids are kept positionally (napari always appends new shapes at the end. in-place edits keep their position). Smaller shape count: removal preserves the relative order of remaining shapes, so ids are recovered by matching remaining geometry to the old records.
Returns whether anything actually changed, so callers can skip the refresh when the layer already agrees with the records.
Source code in src/optari/controllers/roi_controller.py
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 | |
update_live_table ¶
update_live_table(event=None)
Recompute the Live Analysis table for the ROIs on the current frame, active layer and channel.
Falls back to an empty table when there is no shapes layer or no active reconstruction layer to measure against.
Source code in src/optari/controllers/roi_controller.py
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 | |
optari.controllers.segmentation_controller ¶
Segmentation controller: the ONNX model registry, running inference, the segmentation Labels layer, and automatic ROI-from-mask placement.
SegmentParams
dataclass
¶
SegmentParams(model_id, us_data, us_shape, class_ids, output_frames, us_scale, us_translate, current_frame_id=None)
Everything one segmentation run needs, resolved against a loaded scan.
build
classmethod
¶
build(controller, model_id, class_ids, *, frame_id)
Resolve a segmentation setup against the loaded scan's US layer.
Raises ValueError, message safe to show the user, when it cannot run here.
Source code in src/optari/controllers/segmentation_controller.py
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 | |
SegmentationController ¶
SegmentationController(parent_controller)
Bases: TaskControllerBase
Segmentation-related UI actions and geometry helpers. Segmentation masks are generated either for a single frame or all frames, depending on the checkbox state in the UI. For single frame, the mask will be shown only on the selected frame. In any case, the mask is padded to the full shape of the US data and repeated across the channel dimension for correct napari display.
Load the model registry and initialize segmentation state.
Source code in src/optari/controllers/segmentation_controller.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
active_segmentation_model_id
property
¶
active_segmentation_model_id
ID of the currently selected segmentation model.
active_seg_mask_2d ¶
active_seg_mask_2d()
Return (H, W) segmentation mask for the current viewer frame, or None.
Source code in src/optari/controllers/segmentation_controller.py
321 322 323 324 325 326 327 328 | |
active_segmentation_class_items ¶
active_segmentation_class_items()
Return sorted (class_id, class_name) entries for the active model.
Source code in src/optari/controllers/segmentation_controller.py
282 283 284 285 286 | |
get_segmenter ¶
get_segmenter(model_id=None)
The segmenter for model_id, defaulting to the dock's current selection.
A caller that already decided which model to run (a batch plan naming one) must get that model, not whichever the dock happens to be showing.
Source code in src/optari/controllers/segmentation_controller.py
297 298 299 300 301 302 303 304 305 306 307 308 309 | |
initialize_ui ¶
initialize_ui()
Initialize model combo and populate default classes once.
Source code in src/optari/controllers/segmentation_controller.py
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 | |
model_weights_path ¶
model_weights_path(model_id)
Where the given model's ONNX weights are expected on disk.
Source code in src/optari/controllers/segmentation_controller.py
647 648 649 650 651 652 653 654 | |
on_generate_roi_from_mask_clicked ¶
on_generate_roi_from_mask_clicked()
Generate one ROI from the selected frame of the segmentation mask.
Source code in src/optari/controllers/segmentation_controller.py
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 | |
on_generate_tissue_segmentation_clicked ¶
on_generate_tissue_segmentation_clicked()
Run segmentation from the dock's Run button.
Source code in src/optari/controllers/segmentation_controller.py
758 759 760 | |
on_preset_changed ¶
on_preset_changed()
Load and apply the selected segmentation preset.
Source code in src/optari/controllers/segmentation_controller.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
on_remove_preset_clicked ¶
on_remove_preset_clicked()
Remove the selected segmentation preset.
Source code in src/optari/controllers/segmentation_controller.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
on_save_preset_clicked ¶
on_save_preset_clicked()
Save the current segmentation and ROI settings as a new user preset.
Source code in src/optari/controllers/segmentation_controller.py
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 | |
on_segmentation_clear_classes_clicked ¶
on_segmentation_clear_classes_clicked()
Uncheck all segmentation classes.
Source code in src/optari/controllers/segmentation_controller.py
548 549 550 551 552 553 | |
on_segmentation_model_changed ¶
on_segmentation_model_changed()
Apply the model picked in the combo and repopulate the class list.
Source code in src/optari/controllers/segmentation_controller.py
359 360 361 362 363 364 365 366 367 368 369 370 | |
on_segmentation_select_all_classes_clicked ¶
on_segmentation_select_all_classes_clicked()
Check all segmentation classes.
Source code in src/optari/controllers/segmentation_controller.py
541 542 543 544 545 546 | |
populate_segmentation_controls ¶
populate_segmentation_controls(selected_class_ids=None)
Rebuild the classes list for the active model.
Checks selected_class_ids if given, otherwise falls back to the model's own default class.
Source code in src/optari/controllers/segmentation_controller.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
prepare ¶
prepare(params)
Validate params and return the work to run. Raises ValueError if it can't run.
Model weights are required to already be on disk: fetching them is the caller's job, so an unattended run can download once up front instead of per scan.
Source code in src/optari/controllers/segmentation_controller.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | |
publish ¶
publish(result, params)
Add the finished segmentation as a labels layer. Runs on the main thread.
Source code in src/optari/controllers/segmentation_controller.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | |
refresh_ui ¶
refresh_ui()
Refresh controls that require scan or segmentation output.
Source code in src/optari/controllers/segmentation_controller.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
restore_from_scan ¶
restore_from_scan(pa_data)
Rebuild the segmentation layer from scan data.
Source code in src/optari/controllers/segmentation_controller.py
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 | |
segmentation_model_options ¶
segmentation_model_options()
Return model IDs for the model combo.
Source code in src/optari/controllers/segmentation_controller.py
261 262 263 | |
selected_segmentation_class_ids ¶
selected_segmentation_class_ids()
Return the class IDs checked in the segmentation classes list.
Source code in src/optari/controllers/segmentation_controller.py
288 289 290 291 292 293 294 295 | |
set_active_segmentation_model ¶
set_active_segmentation_model(model_id)
Set the active model. Raises ValueError if model_id is not in the registry.
Source code in src/optari/controllers/segmentation_controller.py
270 271 272 273 274 | |
teardown ¶
teardown()
Release cached segmentation model to free memory.
Source code in src/optari/controllers/segmentation_controller.py
240 241 242 243 244 | |
weights_to_fetch ¶
weights_to_fetch(params)
Local path and download URL for the model params requires.
Source code in src/optari/controllers/segmentation_controller.py
656 657 658 659 660 661 662 663 | |
optari.controllers.reconstruction_controller ¶
Reconstruction controller: presets and running PATATO's backprojection/DeepMB pipelines.
ReconParams
dataclass
¶
ReconParams(settings, pa_data_for_run, algorithm_name, speed_of_sound, suffix, output_frames, source_frame_count, scan_path, scan_name=None, current_frame_id=None, offset_x_mm=0.0, offset_z_mm=0.0, timestamps=None, acquisition_start=None, n_wavelengths=1)
Everything one reconstruction run needs, resolved against a loaded scan.
The dock fills this from its widgets and batch mode from a preset, so neither
prepare nor publish has to reach back into ambient viewer or widget state.
chunk_frames
property
¶
chunk_frames
Frames per reconstruction chunk, capped so frames x wavelengths stays within PATATO's batch size limit.
from_settings
classmethod
¶
from_settings(settings_dict, controller, *, speed_of_sound=None, suffix='', frame_id=None)
Resolve a reconstruction preset against the currently loaded scan.
speed_of_sound defaults to the preset's own value. The dock passes its slider instead, which is what lets the slider override the preset.
Raises ValueError, message safe to show the user, when the preset cannot be run on this scan.
Source code in src/optari/controllers/reconstruction_controller.py
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 | |
ReconstructionController ¶
ReconstructionController(parent_controller)
Bases: TaskControllerBase
Run PATATO reconstruction presets on the loaded scan and add as layers.
Initialize preset state and the reconstruction preset store.
Source code in src/optari/controllers/reconstruction_controller.py
198 199 200 201 202 203 204 | |
initialize_ui ¶
initialize_ui()
Populate the preset combo once.
Source code in src/optari/controllers/reconstruction_controller.py
223 224 225 226 227 228 229 230 | |
on_all_settings_toggled ¶
on_all_settings_toggled(checked)
Show or hide the in-memory JSON settings editor.
Source code in src/optari/controllers/reconstruction_controller.py
274 275 276 277 278 279 280 281 | |
on_apply_preset_clicked ¶
on_apply_preset_clicked()
Validate and apply the edited JSON settings in memory.
Source code in src/optari/controllers/reconstruction_controller.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
on_preset_changed ¶
on_preset_changed()
Load the selected preset into the in-memory settings editor.
Source code in src/optari/controllers/reconstruction_controller.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
on_remove_preset_clicked ¶
on_remove_preset_clicked()
Remove the selected reconstruction preset.
Source code in src/optari/controllers/reconstruction_controller.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
on_run_reconstruction_clicked ¶
on_run_reconstruction_clicked()
Run reconstruction from the dock's Run button.
Source code in src/optari/controllers/reconstruction_controller.py
531 532 533 | |
on_save_preset_clicked ¶
on_save_preset_clicked()
Save the current JSON editor contents as a new user preset.
Source code in src/optari/controllers/reconstruction_controller.py
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 | |
on_settings_text_changed ¶
on_settings_text_changed()
Mark the editor contents as pending without rewriting the document.
Source code in src/optari/controllers/reconstruction_controller.py
283 284 285 286 287 | |
on_speed_of_sound_changed ¶
on_speed_of_sound_changed(value)
Keep the speed of sound label in sync with the slider.
Source code in src/optari/controllers/reconstruction_controller.py
391 392 393 394 | |
prepare ¶
prepare(params)
Validate params and return the work to run. Raises ValueError if it can't run.
Model weights are required to already be on disk: fetching them is the caller's job, so an unattended run can download once up front instead of per scan.
Source code in src/optari/controllers/reconstruction_controller.py
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 | |
publish ¶
publish(result, params)
Add the finished reconstruction as a layer. Runs on the main thread.
Source code in src/optari/controllers/reconstruction_controller.py
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 | |
refresh_ui ¶
refresh_ui()
Refresh scan-dependent controls. Reconstruction runs off the loaded scan, not a layer. There is no "Source" to pick, so the only thing to reflect here is whether a scan is loaded at all.
Source code in src/optari/controllers/reconstruction_controller.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
weights_to_fetch ¶
weights_to_fetch(params)
DeepMB needs its ONNX weights on disk before the preset can be built.
Source code in src/optari/controllers/reconstruction_controller.py
418 419 420 421 422 423 424 425 | |
optari.controllers.unmixing_controller ¶
Unmixing controller: presets and running PATATO's spectral unmixing (+ THb/sO2).
UnmixParams
dataclass
¶
UnmixParams(recon_for_run, source_layer_name, source_layer_metadata, source_frame_count, wavelengths, chromophores, output_frames, translate, reduce_factor=1, suffix='', generate_thb=False, generate_so2=False, current_frame_id=None)
Everything one unmixing run needs, resolved against a loaded scan.
name_stem
property
¶
name_stem
Base name for output layers, derived from the source recon layer, suffix and frame.
settings
property
¶
settings
Settings dict stored as metadata on output layers, e.g. for presets and export.
build
classmethod
¶
build(controller, *, wavelengths, chromophores, reduce_factor=1, suffix='', generate_thb=False, generate_so2=False, frame_id=None)
Resolve an unmixing setup against the active reconstruction layer.
Raises ValueError, message safe to show the user, when it cannot run here.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
from_preset
classmethod
¶
from_preset(preset, controller, *, frame_id=None)
Resolve an unmixing preset against the loaded scan's own wavelengths.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
UnmixingController ¶
UnmixingController(parent_controller)
Bases: TaskControllerBase
Run spectral unmixing and add as layers.
Initialize the unmixing preset store.
Source code in src/optari/controllers/unmixing_controller.py
350 351 352 353 | |
initialize_ui ¶
initialize_ui()
Initialize preset, chromophore, and wavelength controls once.
Source code in src/optari/controllers/unmixing_controller.py
390 391 392 393 394 395 396 397 398 399 400 401 | |
on_chromophores_changed ¶
on_chromophores_changed()
Enable THb and sO2 options only when Hb and HbO2 are selected. so2 is activated by default
Source code in src/optari/controllers/unmixing_controller.py
545 546 547 548 549 550 551 552 553 554 555 556 557 | |
on_clear_wavelengths_clicked ¶
on_clear_wavelengths_clicked()
Clear all source wavelength selections in the list widget.
Source code in src/optari/controllers/unmixing_controller.py
494 495 496 497 498 499 | |
on_preset_changed ¶
on_preset_changed()
Load selected preset values into the unmixing controls.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
on_remove_preset_clicked ¶
on_remove_preset_clicked()
Remove the selected unmixing preset.
Source code in src/optari/controllers/unmixing_controller.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
on_run_unmixing_clicked ¶
on_run_unmixing_clicked()
Run unmixing from the dock's Run button.
Source code in src/optari/controllers/unmixing_controller.py
759 760 761 | |
on_save_preset_clicked ¶
on_save_preset_clicked()
Save the current unmixing controls as a new user preset.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
on_select_all_wavelengths_clicked ¶
on_select_all_wavelengths_clicked()
Select all source wavelengths in the list widget.
Source code in src/optari/controllers/unmixing_controller.py
488 489 490 491 492 | |
prepare ¶
prepare(params)
Return the work to run for params.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
publish ¶
publish(result, params)
Add the finished unmixed/THb/sO2 layers. Runs on the main thread.
Source code in src/optari/controllers/unmixing_controller.py
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
refresh_ui ¶
refresh_ui()
Refresh source-dependent controls from the active layer.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
resolve_unmixing_wavelengths ¶
resolve_unmixing_wavelengths(preset, available)
Which of a scan's available wavelengths a preset selects.
Presets name either an explicit list or an inclusive range, and both are resolved per scan rather than per preset: two scans in the same study can be acquired at different wavelengths, and a range must not invent one the scan does not have.
Source code in src/optari/controllers/unmixing_controller.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
validate_unmixing_spectra ¶
validate_unmixing_spectra(wavelengths, chromophores)
Raise a user-facing error when a spectrum has no values at a wavelength.
Source code in src/optari/controllers/unmixing_controller.py
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 | |
optari.controllers.analysis_controller ¶
Analysis controller: time-series, histogram and spectral plots (pyqtgraph) over selected ROIs, and the scan's motion score per frame.
AnalysisController ¶
AnalysisController(parent_controller)
Bases: TaskControllerBase
Temporal analysis, histograms, and spectral plotting helpers.
Source code in src/optari/controllers/base.py
49 50 51 52 53 54 55 56 | |
on_generate_time_analysis_clicked ¶
on_generate_time_analysis_clicked(event=None)
Compute and plot the time series for the current Time Analysis scope.
Validates that ROIs and a multi-frame PA layer are selected, lazily creates the plot widget on first use, then redraws all series for either the selected ROIs or a single tracked ID.
Source code in src/optari/controllers/analysis_controller.py
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 | |
on_motion_frame_line_dragged ¶
on_motion_frame_line_dragged(line)
Show the frame the user dragged the line to.
Source code in src/optari/controllers/analysis_controller.py
160 161 162 163 164 165 166 167 | |
on_refresh_histograms_clicked ¶
on_refresh_histograms_clicked(event=None)
Recompute and redraw per-ROI intensity histograms for the current frame and channel.
Source code in src/optari/controllers/analysis_controller.py
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 | |
on_refresh_motion_clicked ¶
on_refresh_motion_clicked()
Score the loaded scan's motion (once, then cached) and plot it.
Source code in src/optari/controllers/analysis_controller.py
88 89 90 | |
on_refresh_spectrum_clicked ¶
on_refresh_spectrum_clicked(event=None)
Recompute and redraw per-ROI spectra across channels for the current frame.
Source code in src/optari/controllers/analysis_controller.py
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 | |
on_time_analysis_scope_changed ¶
on_time_analysis_scope_changed(checked)
When the user switches between "Selected ROI" and "Track ID" scopes, refresh the track-id combo, show only tracks that exist in the current ROI records.
Source code in src/optari/controllers/analysis_controller.py
79 80 81 82 83 84 85 | |
on_time_frame_line_dragged ¶
on_time_frame_line_dragged(line)
Show the plotted frame nearest to where the user dragged the line.
Source code in src/optari/controllers/analysis_controller.py
169 170 171 172 173 174 175 176 | |
refresh_ui ¶
refresh_ui()
Refresh gating for the histogram/spectrum/time-analysis buttons.
Source code in src/optari/controllers/analysis_controller.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
show_motion_scores ¶
show_motion_scores(*, compute)
Plot both motion scores per frame of the loaded scan, or say why there are none.
Without compute only already cached scores are plotted, so a scan load can refresh the dock for free when a motion-based default frame scored it anyway.
Source code in src/optari/controllers/analysis_controller.py
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 | |
update_frame_lines ¶
update_frame_lines()
Move the Motion and Temporal frame lines to the viewer's current frame.
Source code in src/optari/controllers/analysis_controller.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
optari.controllers.viewer_export_controller ¶
Viewer export controller.
ViewerExportController ¶
Export the currently visible viewer content as image or video.
on_export_clicked
staticmethod
¶
on_export_clicked(controller)
Open the export dialog and write the chosen image or video to disk.
Source code in src/optari/controllers/viewer_export_controller.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |