:py:mod:`controllers` ===================== .. py:module:: controllers Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: controllers.IntController controllers.LifetimeController controllers.GroupingController controllers.SpectraController controllers.myPlotROI controllers.MyCrosshairOverlay controllers.RasterScanController controllers.AntibunchingController controllers.PlotFeature controllers.FilteringController Functions ~~~~~~~~~ .. autoapisummary:: controllers.export_plot_item Attributes ~~~~~~~~~~ .. autoapisummary:: controllers.__docformat__ controllers.EXPORT_WIDTH controllers.EXPORT_MPL_WIDTH controllers.EXPORT_MPL_HEIGHT controllers.EXPORT_MPL_DPI controllers.SIG_ROI_CHANGE_THRESHOLD controllers.logger .. py:data:: __docformat__ :value: "'NumPy'" .. py:data:: EXPORT_WIDTH :value: '1500' .. py:data:: EXPORT_MPL_WIDTH :value: '10' .. py:data:: EXPORT_MPL_HEIGHT :value: '4.5' .. py:data:: EXPORT_MPL_DPI :value: '300' .. py:data:: SIG_ROI_CHANGE_THRESHOLD :value: '0.1' .. py:data:: logger :value: "'controllers'" .. py:function:: export_plot_item(plot_item: pyqtgraph.PlotItem, path: str, text: str = None) .. py:class:: IntController(main_window: main.MainWindow) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:attribute:: main_window .. py:attribute:: resolve_mode :value: 'None' .. py:attribute:: results_gathered :value: 'False' .. py:attribute:: int_widget .. py:attribute:: int_plot .. py:attribute:: int_hist_container .. py:attribute:: show_int_hist .. py:attribute:: int_hist_line .. py:attribute:: int_hist_widget .. py:attribute:: int_hist_plot .. py:attribute:: lifetime_widget .. py:attribute:: lifetime_plot .. py:attribute:: group_int_widget .. py:attribute:: groups_int_plot .. py:attribute:: groups_hist_widget .. py:attribute:: groups_hist_plot .. py:attribute:: int_level_info_container .. py:attribute:: level_info_text .. py:attribute:: int_level_line .. py:attribute:: show_level_info .. py:attribute:: show_exp_trace .. py:attribute:: temp_fig :value: 'None' .. py:attribute:: temp_ax :value: 'None' .. py:attribute:: temp_bins :value: 'None' .. py:attribute:: int_ROI .. py:attribute:: confidence_index .. py:method:: setup_plot(plot_item: pyqtgraph.PlotItem, is_int_hist: bool = False, is_group_hist: bool = False, is_lifetime: bool = False) .. py:method:: setup_widget(plot_widget: pyqtgraph.PlotWidget) :staticmethod: .. py:method:: hide_show_chb(chb_obj: PyQt5.QtWidgets.QCheckBox, show: bool) .. py:method:: roi_chb_changed() .. py:method:: roi_region_changed() .. py:method:: hist_chb_changed() .. py:method:: level_info_chb_changed() .. py:method:: exp_trace_chb_changed() .. py:method:: gui_apply_bin() Changes the bin size of the data of the current particle and then displays the new trace. .. py:method:: gui_chb_show_groups() .. py:method:: gui_chb_show_global_groups() .. py:method:: get_bin() -> int Returns current GUI value for bin size in ms. :returns: The value of the bin size on the GUI in spbBinSize. :rtype: int .. py:method:: set_bin(new_bin: int) Sets the GUI value for the bin size in ms :param new_bin: Value to set bin size to, in ms. :type new_bin: int .. py:method:: gui_apply_bin_all() Changes the bin size of the data of all the particles and then displays the new trace of the current particle. .. py:method:: start_binall_thread(bin_size) -> None :param bin_size: .. py:method:: binall_thread_complete() .. py:method:: gui_resolve() Resolves the levels of the current particle and displays it. .. py:method:: gui_resolve_selected() Resolves the levels of the selected particles and displays the levels of the current particle. .. py:method:: gui_resolve_all() Resolves the levels of the all the particles and then displays the levels of the current particle. .. py:method:: plot_trace(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False) -> None Used to display the trace from the absolute arrival time data of the current particle. .. py:method:: plot_levels(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False) Used to plot the resolved intensity levels of the current particle. .. py:method:: plot_hist(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, for_levels: bool = False, for_groups: bool = False) .. py:method:: update_level_info(particle: smsh5.Particle = None) .. py:method:: plot_group_bounds(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False) .. py:method:: plot_all() .. py:method:: start_resolve_thread(mode: str = 'current', thread_finished=None, end_time_s=None) -> None Creates a worker to resolve levels. Depending on the ``current_selected_all`` parameter the worker will be given the necessary parameter to fit the current, selected or all particles. :param end_time_s: :type end_time_s: float :param thread_finished: :param mode: Possible values are 'current' (default), 'selected', and 'all'. :type mode: {'current', 'selected', 'all'} .. py:method:: gather_replace_results(results: Union[List[threads.ProcessTaskResult], threads.ProcessTaskResult]) .. py:method:: resolve_thread_complete(thread: threads.ProcessThread) .. py:method:: get_gui_confidence() Return current GUI value for confidence percentage. .. py:method:: gui_quick_roi(mode: str) .. py:method:: any_int_plot_double_click(event: pyqtgraph.GraphicsScene.mouseEvents.MouseClickEvent) .. py:method:: error(e) .. py:class:: LifetimeController(main_window: main.MainWindow) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:attribute:: all_should_apply :value: 'None' .. py:attribute:: main_window .. py:attribute:: lifetime_hist_widget .. py:attribute:: life_hist_plot .. py:attribute:: residual_widget .. py:attribute:: residual_plot .. py:attribute:: fitparamdialog .. py:attribute:: fitparam .. py:attribute:: irf_loaded :value: 'False' .. py:attribute:: first :value: '0' .. py:attribute:: startpoint :value: 'None' .. py:attribute:: tmin :value: '0' .. py:attribute:: temp_fig :value: 'None' .. py:attribute:: temp_ax :value: 'None' .. py:method:: setup_plot(plot: pyqtgraph.PlotItem, is_residuals: bool = False) .. py:method:: setup_widget(plot_widget: pyqtgraph.PlotWidget) :staticmethod: .. py:method:: gui_prev_lev() Moves to the previous resolves level and displays its decay curve. .. py:method:: gui_next_lev() Moves to the next resolves level and displays its decay curve. .. py:method:: gui_whole_trace() Unselects selected level and shows whole trace's decay curve .. py:method:: gui_jump_to_groups() .. py:method:: gui_show_hide_residuals() .. py:method:: gui_load_irf() Allow the user to load a IRF instead of the IRF that has already been loaded. .. py:method:: add_irf(decay, t) .. py:method:: gui_fit_param() Opens a dialog to choose the setting with which the decay curve will be fitted. .. py:method:: gui_fit_current() Fits the currently selected level's decay curve using the provided settings. .. py:method:: gui_fit_selected() Fits the all the levels decay curves in the all the selected particles using the provided settings. .. py:method:: gui_fit_all() Fits the all the levels decay curves in the all the particles using the provided settings. .. py:method:: gui_fit_levels() Fits the all the levels decay curves for the current particle. .. py:method:: gui_use_roi_changed() .. py:method:: test_need_roi_apply(particle: smsh5.Particle = None, update_buttons: bool = True) .. py:method:: update_apply_roi_button_colors() .. py:method:: apply_roi(particles: list) .. py:method:: gui_apply_roi_current() .. py:method:: gui_apply_roi_selected() .. py:method:: gui_apply_roi_all() .. py:method:: plot_all() .. py:method:: update_plot_log() .. py:method:: update_results(use_selected: bool = False, selected_level_or_group: Union[change_point.Level, grouping.GlobalLevel, grouping.Group] = None, particle: smsh5.Particle = None, for_export: bool = False, str_return: bool = False) -> Union[str, None] .. py:method:: plot_decay_and_convd(particle: smsh5.Particle, export_path: str, has_groups: bool, only_groups: bool = False, lock: bool = False) .. py:method:: plot_decay_convd_and_hist(particle: smsh5.Particle, export_path: str, has_groups: bool, only_groups: bool = False, lock: bool = False) .. py:method:: plot_decay(selected_level_or_group: Union[None, change_point.Level, grouping.GlobalLevel, grouping.Group] = None, use_selected: bool = False, particle: smsh5.Particle = None, remove_empty: bool = False, for_export: bool = False, export_path: str = None, lock: bool = False) -> None Used to display the histogram of the decay data of the current particle. .. py:method:: plot_convd(selected_level_or_group: Union[change_point.Level, grouping.GlobalLevel, grouping.Group] = None, use_selected: bool = False, particle: smsh5.Particle = None, remove_empty: bool = False, for_export: bool = False, export_path: str = None, lock: bool = False) -> None Used to display the histogram of the decay data of the current particle. .. py:method:: plot_residuals(selected_level_or_group: Union[change_point.Level, grouping.GlobalLevel, grouping.Group] = None, use_selected: bool = False, particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False) -> None Used to display the histogram of the decay data of the current particle. .. py:method:: start_fitting_thread(mode: str = 'current') -> None For now, doesn't actually use threads. This is due to high memory consumption. Depending on the ``current_selected_all`` parameter the worker will be given the necessary parameter to fit the current, selected or all particles. :param mode: Possible values are 'current' (default), 'selected', and 'all'. :type mode: {'current', 'selected', 'all'} .. py:method:: gather_replace_results(results: Union[List[threads.ProcessTaskResult], threads.ProcessTaskResult]) .. py:method:: fitting_thread_complete(mode: str = None) .. py:method:: change_irf_start(start, irf_data) .. py:method:: set_tmin(tmin=0) .. py:method:: show_residuals_widget(show: bool = True, lock: bool = None) .. py:method:: error(e) .. py:class:: GroupingController(main_widow: main.MainWindow) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:attribute:: main_window .. py:attribute:: bic_plot_widget .. py:attribute:: bic_scatter_plot .. py:attribute:: all_bic_plots :value: 'None' .. py:attribute:: all_last_solutions :value: 'None' .. py:attribute:: temp_dir :value: 'None' .. py:attribute:: temp_fig :value: 'None' .. py:attribute:: temp_ax :value: 'None' .. py:method:: clear_bic() .. py:method:: solution_clicked(plot, points) .. py:method:: plot_group_bic(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False, is_global_group=False) .. py:method:: gui_group_current() .. py:method:: gui_group_selected() .. py:method:: gui_group_all() .. py:method:: gui_apply_groups_current() .. py:method:: gui_apply_groups_selected() .. py:method:: gui_apply_groups_all() .. py:method:: start_grouping_thread(mode: str = 'current') -> None Creates a worker to resolve levels. Depending on the ``current_selected_all`` parameter the worker will be given the necessary parameter to fit the current, selected or all particles. :param thread_finished: :param mode: Possible values are 'current' (default), 'selected', and 'all'. :type mode: {'current', 'selected', 'all'} .. py:method:: gather_replace_results(results: Union[List[threads.ProcessTaskResult], threads.ProcessTaskResult]) .. py:method:: grouping_thread_complete(mode) .. py:method:: check_rois_and_set_label() .. py:method:: apply_groups(mode: str = 'current', particles=None) .. py:method:: build_global() .. py:method:: global_gather_replace_results(result: threads.ProcessTaskResult) .. py:method:: global_grouping_thread_complete() .. py:method:: start_global_grouping_thread() .. py:method:: gui_group_global() .. py:method:: error(e: Exception) .. py:class:: SpectraController(main_window: main.MainWindow) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:attribute:: main_window .. py:attribute:: spectra_image_view .. py:attribute:: temp_fig :value: 'None' .. py:attribute:: temp_ax :value: 'None' .. py:attribute:: roi_rotated :value: 'False' .. py:method:: gui_sub_bkg() Used to subtract the background .. py:method:: slot_plot_spectra(event) .. py:method:: gui_rot_roi() Used to rotate the ROI .. py:method:: set_roi_plot_ticks(wl, times) .. py:method:: plot_spectra(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False) .. py:class:: myPlotROI(size) Bases: :py:obj:`pyqtgraph.ROI` .. py:attribute:: rotateSnapAngle :value: '90' .. py:class:: MyCrosshairOverlay(pos=None, size=None, **kargs) Bases: :py:obj:`pyqtgraph.CrosshairROI` .. py:attribute:: _shape :value: 'None' .. py:attribute:: aspectLocked :value: 'True' .. py:class:: RasterScanController(main_window: main.MainWindow) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:attribute:: main_window .. py:attribute:: raster_scan_image_view .. py:attribute:: list_text .. py:attribute:: _crosshair_item :value: 'None' .. py:attribute:: _text_item :value: 'None' .. py:attribute:: temp_fig :value: 'None' .. py:attribute:: temp_ax :value: 'None' .. py:method:: create_crosshair_item(pos: Tuple[int, int], pixelsize) -> MyCrosshairOverlay :staticmethod: .. py:method:: create_text_item(text: str, pos: Tuple[int, int]) -> pyqtgraph.TextItem :staticmethod: .. py:method:: plot_raster_scan(particle: smsh5.Particle = None, raster_scan: smsh5.RasterScan = None, for_export: bool = False, export_path: str = None, lock: bool = False) .. py:class:: AntibunchingController(mainwindow: main.MainWindow, corr_widget: pyqtgraph.PlotWidget, corr_sum_widget: pyqtgraph.PlotWidget) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:property:: difftime .. py:attribute:: main_window .. py:attribute:: resolve_mode :value: 'None' .. py:attribute:: results_gathered :value: 'False' .. py:attribute:: corr_widget .. py:attribute:: corr_plot .. py:attribute:: corr_sum_widget .. py:attribute:: corr_sum_plot .. py:attribute:: temp_fig :value: 'None' .. py:attribute:: temp_ax :value: 'None' .. py:attribute:: corr :value: 'None' .. py:attribute:: bins :value: 'None' .. py:attribute:: irfdiff :value: '0' .. py:method:: setup_plot(plot_item: pyqtgraph.PlotItem) .. py:method:: setup_widget(plot_widget: pyqtgraph.PlotWidget) :staticmethod: .. py:method:: gui_correlate_current() .. py:method:: gui_correlate_selected() .. py:method:: gui_correlate_all() .. py:method:: plot_corr(particle: smsh5.Particle = None, for_export: bool = False, export_path: str = None, lock: bool = False) -> None .. py:method:: plot_corr_sum() .. py:method:: gui_curr_chb(checked) .. py:method:: start_corr_thread(mode: str = 'current') -> None Creates a worker to calculate correlations. Depending on the ``current_selected_all`` parameter the worker will be given the necessary parameter to correlate the current, selected or all particles. :param mode: Possible values are 'current' (default), 'selected', and 'all'. :type mode: {'current', 'selected', 'all'} .. py:method:: gather_replace_results(results: Union[List[threads.ProcessTaskResult], threads.ProcessTaskResult]) .. py:method:: corr_thread_complete(mode: str = None) .. py:method:: rebin_corrs() .. py:method:: error(e) .. py:class:: PlotFeature .. py:attribute:: PhotonNumber :value: "'Photon Number'" .. py:attribute:: Intensity :value: "'Intensity'" .. py:attribute:: Lifetime :value: "'Lifetime'" .. py:attribute:: DW :value: "'DW'" .. py:attribute:: ChiSquared :value: "'Chi-Squared'" .. py:attribute:: IRFShift :value: "'IRF Shift'" .. py:method:: get_list() -> list :classmethod: .. py:method:: get_dict() -> dict :classmethod: .. py:class:: FilteringController(main_window: main.MainWindow) Bases: :py:obj:`PyQt5.QtCore.QObject` .. py:attribute:: main_window .. py:attribute:: plot_widget .. py:attribute:: plot .. py:attribute:: option_linker .. py:attribute:: current_plot_type :value: '(None, None)' .. py:attribute:: current_particles_to_use :value: 'None' .. py:attribute:: current_data_points_to_use :value: 'None' .. py:attribute:: current_particles :value: '[]' .. py:attribute:: levels_to_use :value: 'None' .. py:attribute:: fit_result :value: 'None' .. py:attribute:: has_fit :value: 'False' .. py:attribute:: is_normalized :value: 'False' .. py:attribute:: plot_pen .. py:attribute:: distribution_item .. py:attribute:: two_feature_item .. py:attribute:: plot_fit_pen .. py:attribute:: int_lifetime_fit_item .. py:attribute:: filter_settings :value: 'None' .. py:method:: _get_label(feature: PlotFeature = None) -> tuple :staticmethod: .. py:method:: setup_plot(feature_x: PlotFeature, feature_y: PlotFeature = None, clear_plot: bool = True, is_first_setup: bool = False) .. py:method:: filter_option_changed(option: str) .. py:method:: auto_num_bins_changed() .. py:method:: get_two_features() -> tuple .. py:method:: change_plot_type(feature_x: Union[PlotFeature, str] = None, feature_y: Union[PlotFeature, str] = None) .. py:method:: set_levels_to_use() .. py:method:: get_data() -> tuple .. py:method:: two_features_changed(x_changed: bool = None) .. py:method:: switch_two_features() .. py:method:: plot_features(feature_x: Union[PlotFeature, str] = None, feature_y: Union[PlotFeature, str] = None, use_current_plot: bool = False, use_selected_two_features: bool = False) .. py:method:: _filter_numeric_data(feature_data: numpy.ndarray, are_used_flags: List[bool], test_min: bool = False, test_max: bool = False, min_value=None, max_value=None) :staticmethod: .. py:method:: get_feature_data(feature: Union[PlotFeature, str]) -> tuple .. py:method:: get_all_feature_data() -> tuple[dict[Any, dict[str, Any]], list[bool] | Any, list[bool] | Any] .. py:method:: get_all_filter() -> numpy.ndarray .. py:method:: set_limits(feature_x: Union[PlotFeature, str] = None, feature_y: Union[PlotFeature, str] = None) .. py:method:: plot_distribution() .. py:method:: plot_two_features() .. py:method:: prepare_plot_for_int_lifetime_fit() .. py:method:: plot_fit_result() .. py:method:: fit_intensity_lifetime() .. py:method:: get_filter_settings() -> dict .. py:method:: _block_change(obj, change_method_name, value) :staticmethod: .. py:method:: set_filter_settings(filter_settings: dict) .. py:method:: apply_filters() .. py:method:: reset_filters() .. py:method:: reset_dataset_filter() .. py:method:: get_all_levels_with_lifetime() -> list .. py:method:: reset_normalization() .. py:method:: apply_normalization()