cellects.gui.video_analysis_window
cellects.gui.video_analysis_window
Third main widget for Cellects GUI enabling video analysis configuration and execution.
This module implements a video tracking interface for analyzing cell movement through configurable parameters like arena selection, segmentation methods, and smoothing thresholds. It provides interactive controls including spinboxes, comboboxes, buttons for detection/post-processing, and an image display area with full-screen support. Threaded operations (VideoReaderThread, VideoTrackingThread) handle background processing to maintain UI responsiveness.
Main Components VideoAnalysisWindow : QWidget subclass implementing the video analysis interface with tab navigation, parameter controls, and thread coordination
Notes Uses QThread for background operations to maintain UI responsiveness.
VideoAnalysisWindow
Bases: MainTabsType
Source code in src/cellects/gui/video_analysis_window.py
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 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 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 695 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 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 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | |
__init__(parent, night_mode)
Initialize the VideoAnalysis window with a parent widget and night mode setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
QWidget
|
The parent widget to which this window will be attached. |
required |
night_mode
|
bool
|
A boolean indicating whether the night mode should be enabled. |
required |
Examples:
>>> from PySide6 import QtWidgets
>>> from cellects.gui.cellects import CellectsMainWidget
>>> from cellects.gui.video_analysis_window import VideoAnalysisWindow
>>> import sys
>>> app = QtWidgets.QApplication([])
>>> parent = CellectsMainWidget()
>>> session = VideoAnalysisWindow(parent, False)
>>> parent.insertWidget(0, session)
>>> parent.show()
>>> sys.exit(app.exec())
Source code in src/cellects/gui/video_analysis_window.py
advanced_parameters_is_clicked()
Modifies the interface to display advanced parameters.
Source code in src/cellects/gui/video_analysis_window.py
arena_changed()
Resets the loaded arena when its video and processing threads are not running.
Notes
This function is part of a larger class responsible for managing video and arena processing threads. It should be called when all relevant threads are not running to ensure the arena's state is properly reset.
Source code in src/cellects/gui/video_analysis_window.py
compute_all_options_check()
Save the compute_all_options checkbox value to process every video segmentation algorithms during the next run.
Source code in src/cellects/gui/video_analysis_window.py
data_tab_is_clicked()
Handles the logic for when the "Data specifications" button is clicked in the interface, leading to the FirstWindow.
Notes
This function displays an error message when a thread relative to the current window is running. This function also save the id of the following window for later use.
Source code in src/cellects/gui/video_analysis_window.py
detection_is_clicked()
Trigger detection when a button is clicked.
This method handles the logic when the user clicks the "detection" button. It resets certain states, sets a flag for quick full processing, and starts a thread to run the detection in one arena.
Notes
This method is part of a larger state machine for handling user interactions.
It assumes that the parent object has a po attribute with a load_quick_full
flag and a method to run an arena thread.
Source code in src/cellects/gui/video_analysis_window.py
display_conditionally_visible_widgets()
Display Conditionally Visible Widgets
Source code in src/cellects/gui/video_analysis_window.py
display_image_during_thread(dictionary)
Display an image and set a message during a thread operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary
|
dict
|
A dictionary containing the 'message' and 'current_image'. The message is a string to display. The current_image is the image data that will be displayed. |
required |
Source code in src/cellects/gui/video_analysis_window.py
display_message_from_thread(text_from_thread)
Updates the message displayed in the UI with text from a thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_from_thread
|
str
|
The text to be displayed in the UI message. |
required |
Source code in src/cellects/gui/video_analysis_window.py
fading_changed()
Save the fading spinbox value to modify how intensity must decrease to detect a pixel left by the specimen(s).
full_screen_display(event)
Full-screen display of an image.
This method creates a full-screen image popup and displays it. The full-screen image is initialized with the current image to display, and its size is set to match the screen dimensions.
Source code in src/cellects/gui/video_analysis_window.py
image_tab_is_clicked()
Handles the logic for when the "Image analysis" button is clicked in the interface, leading to the image analysis window.
Notes
This function displays an error message when a thread relative to the current window is running. This function also save the id of the following window for later use.
Source code in src/cellects/gui/video_analysis_window.py
load_one_arena_is_clicked()
Load one arena if clicked.
Resets the general step, sets load_quick_full to 0, and runs the arena in a separate thread.
Source code in src/cellects/gui/video_analysis_window.py
maximal_growth_factor_changed()
Save the maximal_growth_factor spinbox value to modulate the maximal growth between two frames.
Source code in src/cellects/gui/video_analysis_window.py
option_changed()
Handles the logic for changing video option settings and logging the appropriate actions.
This method is responsible for updating various flags and configuration variables based on the selected video option. It also logs informational messages regarding the behavior of the segmentation algorithms being enabled or disabled.
Notes
This function updates the parent object's configuration variables and logs messages based on the selected video option. The behavior changes depending on the number of colors detected and the specific video option chosen.
Source code in src/cellects/gui/video_analysis_window.py
post_processing_is_clicked()
Trigger post-processing when a button is clicked.
Extended Description
This function updates the parent object's load_quick_full attribute, logs a specific variable value, and runs an arena thread.
Source code in src/cellects/gui/video_analysis_window.py
previous_is_clicked()
Transition to the previous tab based on current tab history.
This method handles the logic for navigating back through the application's tabs when "previous" is clicked. It updates the current tab to the one that was last visited, cycling through the predefined order of tabs.
Notes
This function is part of a state-machine-like navigation system that
tracks tab history. It assumes the parent widget has methods last_tab
and change_widget for managing the current view.
Source code in src/cellects/gui/video_analysis_window.py
read_is_clicked()
Read a video corresponding to a numbered arena (numbered using natural sorting) in the image
This function checks if the detection has been run and if the video reader or analysis thread is running. If both threads are idle, it starts the video reading process. Otherwise, it updates the message accordingly.
Source code in src/cellects/gui/video_analysis_window.py
repeat_video_smoothing_changed()
Save the repeat_video_smoothing spinbox value to set how many times the pixel intensity dynamics will be smoothed.
Source code in src/cellects/gui/video_analysis_window.py
required_outputs_is_clicked()
Sets the required outputs flag and changes the widget to the "Required Output" window.
reset_general_step()
Reset the general step counter and update UI labels.
Source code in src/cellects/gui/video_analysis_window.py
run_all_is_clicked()
Handle the click event to start the complete analysis.
This function checks if any threads are running and starts the 'VideoTracking' thread for all arenas. It also updates various attributes and messages related to the analysis process.
Notes
This function will only start the analysis if no other threads are running. It updates several attributes of the parent object.
Source code in src/cellects/gui/video_analysis_window.py
run_one_arena_thread()
Run the VideoTracking thread for processing one arena.
Executes the thread to load one video, initialize analysis, stop any running instance of the thread, save settings, and connect signals for displaying messages, images, and handling completion events.
Notes
Ensures that the previous arena settings are cleared and connects signals to display messages and images during thread execution.
Source code in src/cellects/gui/video_analysis_window.py
save_all_vars_thread()
Start the 'SaveAllVars' thread if it is not already running.
This method is used to ensure that variable saving operations are performed in a separate thread to avoid blocking the main application.
Source code in src/cellects/gui/video_analysis_window.py
save_current_settings()
Saves the current settings from UI components to persistent storage.
This method captures the values of various UI components and stores them in a persistent data structure to ensure settings are saved across sessions.
Source code in src/cellects/gui/video_analysis_window.py
save_one_result_is_clicked()
Finalize one arena analysis and save the result if conditions are met.
This function checks various conditions before starting a thread to finalize the analysis and save the result. It ensures that certain threads are not running before proceeding.
Source code in src/cellects/gui/video_analysis_window.py
specimen_activity_changed()
Save the fading checkbox value to allow cases where pixels can be left by the specimen(s).
Source code in src/cellects/gui/video_analysis_window.py
step_done_is_clicked()
Step the analysis progress when 'Done' button is clicked.
Increments the current step and updates the UI accordingly based on the new step value. Updates labels, tooltips, and visibility of widgets.
Notes
This method is automatically called when the 'Done' button is clicked. It updates the GUI elements to reflect progress in a multi-step analysis process.
Source code in src/cellects/gui/video_analysis_window.py
true_init()
Initialize the video tracking interface and set up its UI components.
Extended Description
This method initializes various tabs, threads, and UI elements for the video tracking interface. It sets up event handlers for tab clicks and configures layout components such as labels, buttons, spinboxes, and comboboxes.
Notes
This method assumes that the parent widget has a 'po' attribute with specific settings and variables.
Source code in src/cellects/gui/video_analysis_window.py
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 | |
when_detection_finished(message)
Handles the completion of video detection and updates the UI accordingly.
When the video detection is finished, this function waits for the VideoReader thread to complete if it's running. It then processes the last frame of the video based on the configured visualization and motion detection settings. Finally, it updates the UI with the processed image and sets appropriate labels' visibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to display upon completion of detection. This could be a status update or any relevant information. |
required |
Notes
This function assumes that the parent object has attributes po and
image_to_display, and methods like display_image.update_image.
Source code in src/cellects/gui/video_analysis_window.py
when_loading_thread_finished(save_loaded_video)
Ends the loading thread process and handles post-loading actions.
Notes
This method assumes that the parent object has a po attribute with an
'arena' key and a load_quick_full attribute. It also assumes that the
parent object has a 'thread' dictionary and a message UI component.