polo.widgets package¶
Submodules¶
polo.widgets.file_browser module¶
-
class
polo.widgets.file_browser.
fileBrowser
(parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QTreeWidget
-
DATA_INDEX
= 5¶
-
DIR_ICON
= '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/dir.png'¶
-
FILE_ICON
= '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/file.png'¶
-
get_checked_files
(home_dir)[source]¶ Traverse the file tree and return the full paths to files that have been selected by the user.
- Parameters
home_dir (str or Path) – User’s home directory. This path is the parent of all returned files.
- Returns
List of checked Paths
- Return type
list
-
grow_tree_using_mlsd
(ftp, home_dir, set_checkable=True)[source]¶ Rescursively add child nodes to the tree by traversing a user’s home directory at a remote ftp server. Filepaths are read using mlsd formating.
- Parameters
ftp (FTP) – FTP object with valid connection
home_dir (str or Path) – Path to the user’s home directory
set_checkable (bool, optional) – Set files and dirs to checkable, defaults to True
-
polo.widgets.map_box module¶
polo.widgets.optimize_widget module¶
-
class
polo.widgets.optimize_widget.
OptimizeWidget
(parent, run=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
-
GRID_ICON
= '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/grid.png'¶ The
OptimizeWidget
class is a primary run interface widget that allows users to create optimization screens around the crystallization conditions that yielded xtal hits. The concept is very similar to the program MakeTray available from Hampton Research. Currently, users cannot specify their own conditions and are limited to the predetermined conditions of theMenu
that was selected when the run was originally imported into Polo. Additionally, theOptimizeWidget
is only available toHWIRun
instances as the cocktail to well mapping cannot be inferred for other more generalRun
types.- Parameters
parent (QWidget) – Parent Widget
run (HWIRun, optional) – Run to screen for hits from, defaults to None
-
HTML_ICON
= '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/html.png'¶
-
_check_for_overflow
(volume_list)[source]¶ Private method to check if the volume of
Reagent
instancess in a given well exceeds the total well volume. If an overflow is detected, return False otherwise return the volume of H20 that should be added to the well as aUnitValue
instance.- Parameters
volume_list (list) – List of UnitValues that consitute the contents of a well in the optimization plate
- Returns
UnitValue describing the volume of water that should be added to the well if it does not overflow in liters, False otherwise
- Return type
UnitValue or False
-
_error_checker
()[source]¶ Private method to check if all widgets and attributes have allowed values before calculating the actual grid screen. Show error message if there is a conflict.
-
_gradient
(reagent, num_wells, step, stock=False)[source]¶ Private method for calculating a concentration gradient for a given
Reagent
using a given step size as a proportion of theReagent
instance’sconcentration
attribute.- Parameters
reagent (Reagent) – Reagent to vary concentration
num_wells (int) – Number of wells to vary concentration across
step (float < 1) – Proportion of hit concentration to vary each well by
stock (bool, optional) – If True, vary the stock volume not the hit concentration unit, defaults to False
- Returns
List of UnitValues that make up the _gradient
- Return type
list
-
_handle_reagent_change
(x=False, y=False, const=False)[source]¶ Private method that handles when a
Reagent
is changed. The arguments indicate whichReagent
has been changed.- Parameters
x (bool, optional) – If True update the x reagent, defaults to False
y (bool, optional) – If True update the y reagent, defaults to False
const (bool, optional) – If True update the constant reagents, defaults to False
-
_make_plate_list
()[source]¶ Private method that converts the concents of the
tableWidget
UI (assuming that a optimization screen has been already rendered to the user) to a list of lists that is easier to write to html using the jinja2 template.- Returns
tableWidget contents converted to list
- Return type
list
-
_make_well_html
(x_con, x_stock, y_con, y_stock, constants, water)[source]¶ Private method to format the information that describes the contents of an individual well into prettier html that can be displayed to the user in a
textBrowser
widget.- Parameters
x_con (UnitValue) – Concentration of x reagent in this well
x_stock (UnitValue) – Volume of x reagent stock in this well
y_con (UnitValue) – Concentration of y reagent in this well
y_stock (UnitValue) – Volume of y reagent stock in this well
constants (list of tuples) – Tuples of constant reagents to be included in each well
water (Signed Value) – Volume of water to be added to this well
- Returns
Html string to be rendered to the user
- Return type
str
-
_set_constant_reagents
()[source]¶ Private method that populates the listWidget with constant reagents to display to the user.
-
_set_hit_well_choices
()[source]¶ Private method that sets the hit well comboBox widget choices based on the images in the
run
attribute that are human classified as crystal. Wells are identified in the comboBox by their well number.
-
_set_reagent_choices
()[source]¶ Private method that sets
Reagent
choices for the x and y reagents based on the currently selected well.Reagents
must come from the class:Cocktail instance associated with the selected well.TODO: Add the option to vary pH instead of a
Reagent
along either axis. This would also mean that the constant reagents would need to be updated.
-
_set_reagent_stock_con
()[source]¶ Private method. If a
Reagent
has already been assigned a stock concentration this method displays that concentration to the user through the appropriateUnitCombobBox
instance. Only displays concentrations for the x and y reagents.
-
_set_reagent_stock_con_values
(x=False, y=False, const=False)[source]¶ Private method to update the stock concentations of current reagents through their
stock_con
attribute. TheReagent
to update is indicated by the flag set to True at the time the method is called. The stock concentration value is pulled from each reagent’s respective unitComboBox instance.
-
_set_up_unit_comboboxes
()[source]¶ Private method that sets the base unit and the scalers of all
unitComboBox
instances that are apart of the UI.
-
_update_current_reagents
(image_index=None)[source]¶ Private method that updates x and y
Reagent
comboBox widgets to reflect whatReagent
instances are contained in the currently selected well.- Parameters
image_index (int, optional) – Index of the
Image
to setReagent
choices from, defaults to None.
-
_write_optimization_screen
()[source]¶ Private method to write the current optimization screen to the
tableWidget
UI for display to the user.
-
property
constant_reagents
¶ Retrieve a set of
Reagents
that are not included as either the attr:x_reagent or the attr:y_reagent but are still part of the crystallization cocktail and therefore need to be included in the screen. Unlike either the x or y reagents, constant reagents do not change their concentration across the screening plate.
-
property
hit_images
¶ Retrieves a list of
Image
object instances that have human classification == ‘Crystals’. Used to determine what wells to allow the user to optimize. Currently, only allow the user to optimize wells they have marked as crystal.
-
property
run
¶
-
property
selected_constant
¶ Return the constant
Reagent
that is currently selected by the user.
-
update_interface
()[source]¶ Method to update reagents and selectable wells to the user after they have made additional classifications that would increase or decrease the pool of crystal classified images.
-
property
well_volume
¶ Returns the well volume set by the user modifed by whatever well volume unit is currently selected.
-
property
x_reagent
¶ Used to retrieve the
Reagent
object that is to be varied along the x axis of the screen.
-
property
x_wells
¶ Returns spinBox value that representing the number wells on the x axis of the screen.
-
property
y_reagent
¶ Used to retreive the
Reagent
object that is to be varied along the y axis of the optimization plate
-
property
y_wells
¶ Returns spinBox value representing the number of wells on the y axis of the screen.
-
polo.widgets.plate_inspector_widget module¶
-
class
polo.widgets.plate_inspector_widget.
PlateInspectorWidget
(parent, run=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
-
_apply_color_mapping
()[source]¶ Applies the current color mapping to displayed images. Images are colored based on either their human or marco classification.
-
_apply_image_filters
()[source]¶ Wrapper function around plateViewer
deemphasize_filtered_images()
which changes the opacity of currently displayed images based on their classifications.
-
_parse_label_checkboxes
()[source]¶ Private method that reads values from
QCheckBox
instances related to image filtering. Returns a dictionary where keys are the labels of theQCheckBox
instances which should also be the possible image classifications and values are the state of theQCheckBox
(True or False).Returned dictionary will have following structure.
{ 'Crystals': True, 'Clear': False, 'Precipitate': True, 'Other': False }
- Returns
Dict of
QCheckBox
states.- Return type
dict
Private helper function similar to
_set_time_resolved_buttons()
that determines if the navigation button that allows users to view alt spectrum images should be enabled. If conditions are not met then the button is disabled.
-
_set_color_comboboxs
()[source]¶ Private method that sets the label text associated with each color selector
QComboBox
. Should be called in the __init__ method before the widget is shown to the user.
-
_set_color_options
()[source]¶ Private methods that uses the
COLORS
constant to set the color options for each color selectorQComboBox
instance in the image coloring tab.
-
_set_current_page
(page_number)[source]¶ Set the current page number and show the view for that page by calling
show_current_page()
- Parameters
page_number (int) – The new page number
-
_set_image_count_options
()[source]¶ Private method to be called in the __init__ method that sets the allowed number of images per page.
-
_set_images_per_page
()[source]¶ Private method that tells the
plateViewer
UI widget to set itsimages_per_page
atttribute to the value specified in the images per pageQComboBox
.
-
_set_plate_label
()[source]¶ Private method to change the plate label to tell the user what view or “page” they are currently looking at.
Private helper function that determines if navigation buttons that display alt spectrum images, previous and next date images can be used.
-
apply_plate_settings
()[source]¶ Parses
QCheckBox
instances in the Plate View tab to determine what behavior of theplateViewer
widget is requested by the user.
-
property
color_mapping
¶ Creates a color mapping dictionary that reflects the currently selected color selector
QComboBox
instances. The dictionary maps each image classification to aQColor
instance that can then be used to color images in the plate viewer.
-
property
favorite
¶ Status of the favorite
QCheckBox
filter.- Returns
State of the favorite
QCheckBox
- Return type
bool
-
property
human
¶ Status of human image classification
QCheckBox
.- Returns
State of the human filter
QCheckBox
- Return type
bool
-
images_per_page
= [16, 64, 96]¶
-
property
marco
¶ Status of marco image classification
QCheckBox
.- Returns
State of the marco filter
QCheckBox
- Return type
bool
-
property
run
¶
-
property
selected_classifications
¶ Image classifications that are selected via the image filtering
QCheckBox
instances. Also see theimage_type_checkboxes
property.- Returns
List of currently selected image classifications. Images who’s classification is in this list should be shown / emphasized to the user.
- Return type
list
-
set_aspect_ratio_mode
()[source]¶ Sets the preserve_aspect attribute based on the status of the preserve aspect ratio
QCheckBox
. Preserving the aspect ratio results in displaying undistorted crystallization images but utilizes available display space less efficiently.
-
show_current_plate
(next_view=False, prev_view=False, next_date=False, prev_date=False, alt_spec=False)[source]¶ Show the images belonging to the current plate view to the user.
- Parameters
next_date (bool, optional) – Flag, if True show equivalent images from future date, defaults to False
prev_date (bool, optional) – Flag, if True shows equivalent images from past date, defaults to False
alt_spec (bool, optional) – Flag if True shows equivalent images in alternative imaging spectrum, defaults to False
-
polo.widgets.plate_viewer module¶
-
class
polo.widgets.plate_viewer.
PlateGraphicsItem
(pixmap, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QGraphicsPixmapItem
-
class
polo.widgets.plate_viewer.
plateViewer
(parent, run=None, images_per_page=24)[source]¶ Bases:
PyQt5.QtWidgets.QGraphicsView
-
_get_visible_wells
(page=None)[source]¶ Return indices of images that should be shown in the current page. A page is equivalent to a subsection of a larger screening plate.
- Parameters
page (int, optional) – Page number to find images for, defaults to None
- Yield
image index
- Return type
int
-
_make_image_label
(image, label_dict, font_size=35)[source]¶ Private helper method for creating label strings to overlay onto each image in the view.
- Parameters
image (Image) – Image to create label from
label_dict (dict) – Dictionary of image attributes to include in the label
font_size (int, optional) – Font size for the label, defaults to 35
- Returns
QGraphicsTextItem with label text set
- Return type
QGraphicsTextItem
-
_set_prerender_info
(item, image)[source]¶ Private helper method that sets flags and the tooltip for
QGraphicsItems
before they are added to theGraphicsScene
.- Parameters
item (QGraphicsItem) – GraphicsItem that is to be added to the scene
image (Image) – Image who’s data will be used to label the GraphicsItem
- Returns
QGraphicsItem
- Return type
QGraphicsItem
-
property
aspect_ratio
¶ Current “best” aspect ratio for the view given the size of the view and the number of images that need to be fit into the view.
- Returns
Dimensions of the image grid, in images
- Return type
tuple
-
changed_images_per_page_signal
¶
-
changed_page_signal
¶
-
property
current_page
¶ Current page
- Returns
Current page
- Return type
int
-
emphasize_all_images
()[source]¶ Returns the opacity of all images in the
_scene
attribute to 1, or fully opaque.
-
export_current_view
(save_path=None)[source]¶ Exports the current content of the
_scene
attribute to a png file.- Parameters
save_path (str or Path, optional) – Path to save the image to, defaults to None. If kept as None opens a QFileDialog to get a save file path.
-
fitInView
(scene, preserve_aspect=False)[source]¶ Fit items added to
_scene
attribute into the available display space.- Parameters
scene (QGraphicsScene) – QGraphicsScene to fit
preserve_aspect (bool, optional) – If True, preserves the aspect ratio of item is the scene, defaults to False
-
property
images_per_page
¶ Number of images in the current page.
- Returns
Number of images
- Return type
int
-
pop_out_selected_well
()[source]¶ Helper method to handle image selection and open an
ImagePopDialog
that displays the selected image in a pop out view.
-
set_scene_colors_from_filters
(color_mapping, strength=0.5, human=False)[source]¶ Set the color of images based on their current classifications. Very similar to
set_opacity_from_filters()
. Images can be colored by their MARCO or human classification.- Parameters
color_mapping (dict) – Dictionary that maps image classifications to QColors
strength (float, optional) – Image color strength, defaults to 0.5
human (bool, optional) – If True, use the human classification to color images, defaults to False
-
set_scene_opacity_from_filters
(image_types, human=False, marco=False, favorite=False, filtered_opacity=0.2)[source]¶ Sets the opacity of all items in the
_scene
attribute based on image filtering criteria. Allows for highlighting images that meet specific qualifications such has having a MARCO classification of crystals. Images that do not meet the set filter requirements will have their opacity set to the value specificed by the filtered_opacity argument.- Parameters
image_types (set of list) – Image classifications to select for.
human (bool, optional) – If True, use human classification to determine image classification, defaults to False
marco (bool, optional) – If True, use MARCO classification to determine image classification , defaults to False
favorite (bool, optional) – If True, image must be favorited to be selected, defaults to False
filtered_opacity (float, optional) – Set the opacity for images that do not need the filtering requirements, defaults to 0.2
-
subgrid_dict
= {16: (4, 4), 64: (8, 8), 96: (8, 12), 1536: (32, 48)}¶
-
tile_images_onto_scene
(label_dict={})[source]¶ Calculates images that should be shown based on the current page and the number of images per page. Then tiles these images into a grid, adding them to
_scene
attribute.- Parameters
label_dict (dict, optional) – Dictionary of Image attributes to pass along to
_make_image_label()
to create image labels, defaults to {}
-
property
total_pages
¶ Total number of pages based on the number of images per page and the number of images in the current run.
- Returns
Number of pages
- Return type
int
-
property
view_dims
¶ Current view dimensions in pixels.
- Returns
Width and height of the view
- Return type
tuple
-
static
well_index_to_subgrid
(i, c_r, c_c, p_r, p_c)[source]¶ Find the linear index of the subgrid that a particular index belongs to within a larger grid. For example, ou are given a list of length 16. The list is reshaped into a 4 x 4 2D list. We divide the new grid into 4 quadrants each 2 X 2 and label them with an index (0, 1, 2, 3). Given an index of the original list we want to find the subgrid it belongs to.
- Parameters
i (int) – Index of point to locate in the 1D list
c_r (int) – Number of rows in each subgrid
c_c (int) – Number of columns in each subgrid
p_r (int) – Number or rows in the entire grid
p_c (int) – Number of columns in the entire grid
- Returns
Index of the subgrid the index i belongs to
- Return type
int
-
polo.widgets.plate_visualizer module¶
-
class
polo.widgets.plate_visualizer.
PlateVisualizer
(parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QGraphicsView
The
PlateVisualizer
is a small widget to assist users understand what part of the screening plate they are currently viewing. It renders a grid of rectangles (blocks) that each represent one view (page) in thePlateInspector
widget. The page that is currently being viewed is highlighted to show the user what part of the plate they are looking at.- Parameters
parent (QWidget, optional) – Parent widget, defaults to None
-
_block_size
(x, y)[source]¶ Private method to calculate the size of individual blocks to render in the QGraphicsView.
- Parameters
x (int) – Length of x-axis in blocks
y (int) – Length of y-axis in blocks
- Returns
tuple, length of block x-axis in pixels, length of block y-axis in pixels
- Return type
tuple
-
_handle_block_selection
()[source]¶ Private helper method to handle when a user selects a block. In theory should open the view that the selected block corresponds to but currently having some issues with this causing segmentation faults so it is disabled for now.
-
_highlight_block
(block)[source]¶ Private method that highlights a block in the QGraphicsScene.
- Parameters
block (QGraphicsRectItem) – Block to highlight
-
static
block_dims
(plate_x, plate_y, grid_x, grid_y)[source]¶ Helper method to calculate the size of plate section blocks
- Parameters
plate_x (int) – Number of wells plate has on its x axis
plate_y (int) – Number of wells plate has on it s y axis
grid_x (int) – Number of wells in the subgrid on its x axis
grid_y (int) – Number of wells in the subgrid on its y axis
- Returns
tuple, first item being length of x axis in blocks and second being length of y axis in blocks
- Return type
tuple
-
default_brush
= <PyQt5.QtGui.QBrush object>¶
-
default_pen
= <PyQt5.QtGui.QPen object>¶
-
plate_size
= (32, 48)¶
-
plate_view_requested
¶
-
selected_brush
= <PyQt5.QtGui.QBrush object>¶
-
set_selected_block
(block_id)[source]¶ Sets the currently selected block based on its ID.
- Parameters
block_id (int) – Block ID
-
setup_view
(grid_cords, plate_size=None)[source]¶ set up the intail view based on the current plate size (normally 32 * 48 wells for 1536 well plate) and the subgrid size in wells.
- Parameters
grid_cords (tuple) – Subgrid size tuple (x, y) in wells
plate_size (tuple, optional) – Size of entire plate (x, y) in wells, defaults to None. If None used the default 1536 well plate size of 32 * 48.
polo.widgets.run_organizer module¶
-
class
polo.widgets.run_organizer.
RunOrganizer
(parent=None, auto_link_runs=True)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget for organizing and importing runs into Polo.
- Parameters
parent (QWidget, optional) – Parent widget, defaults to None
auto_link_runs (bool, optional) – If True runs are automatically linked as they are loaded in, defaults to True
-
_add_runs_to_tree
(runs)[source]¶ Private method to add a set of runs to the runTree.
- Parameters
runs (list) – List of runs to add to the runTree
-
_check_for_existing_backup
(run)[source]¶ Check the directory specified by the BACKUP_DIR constant for a backup mso file that matches the run passed through the run argument. Run’s are matched to mso backups by their run name so it the user has renamed their run after the backup is saved it will not be found.
See
backup_classifications()
for details on how the mso files are written.- Parameters
run (HWIRun) – Run to search for mso backup with
- Returns
Path to mso backup if one exists that matches the run, else return None
- Return type
str or None
-
_classify_multiple_runs
(runs)[source]¶ Run the MARCO model on a list of runs. Recursively creates
ClassificationThreads
for eachRun
until allRun
instances have been classified.- Parameters
runs (list) – List of
Run
instance to classify using MARCO
-
_clear_current_run
(run_list)[source]¶ Clear out the current run from other widgets by emiting a
opening_run
signal with a list that does not contain a Run or HWIRun object.- Parameters
run_list (list) – List of runs
-
_finished_ftp_download
()[source]¶ Private method that cleans up after all queued FTP downloads have been completed and shows a message box to the user to inform them of the status of their downloads.
-
_handle_classification_request
()[source]¶ Private method to open a classification thread of the currently selected run. Calls
_open_classification_thread()
to start the classification thread.
-
_handle_ftp_download
(file_path)[source]¶ Private method that handles when an individual file in the FTP download queue has finished downloading. Attempts to import the run by calling
import_runs()
and then increments the FTP download counter by one.- Parameters
file_path (str or Path) – Path to file that was just downloaded
-
_handle_opening_run
(*args)[source]¶ Private method that signal to other widgets that the current run should be opened for analysis and viewing by emiting the
opening_run
signal containing the selected run.
-
_import_runs
(file_paths)[source]¶ Import
Run
objects from a list of file and directory paths. Runs that are imported successfully will be added to the sample browser.- Parameters
file_paths (list) – List of paths to files and directories to be imported as runs
-
_open_classification_thread
(run)[source]¶ Private method to create and run a classification thread which will run the MARCO model on all images in the run passed to run argument. Does not actually start the classification thread, just stores the newly created classification thread in classification_thread attribute.
-
_set_estimated_classification_time
(time, num_images_remain)[source]¶ Display the estimated classification time to the user. Time remaining is calculated by multiplying the time it took to classify a representative image by the number of images that remain to be classified.
- Parameters
time (int) – Time to classify latest image
num_images_remain (int) – Number of images that still require classification
-
_set_progress_value
(val)[source]¶ Private helper method to increment the classification progress bar.
- Parameters
val (int) – Value to set progress bar to
-
property
all_runs
¶ Get all runs currently listed in the
runTree
.- Returns
List of
Run
objects- Return type
list
-
backup_classifications
(run)[source]¶ Write the human classifications of the images in the run argument to an mso file and store it in the directory specified by the
BACKUP_DIR
constant. Does not store MARCO classifications because these can be much more easily recreated than human classifications. Additionally, when a run is loaded back in and a backup mso exists for it Polo assumes the classifications in that mso file are human classifications.Currently only
HWIRun
instances can be written as mso files because of mso’s integration with cocktail data and well assignments. Need a different format for non-HWI runs that would map filenames to classifications and ignore cocktail data / well assignments.- Parameters
run (HWIRun) –
HWIRun
to backup human classifications
-
backup_classifications_on_thread
(run)[source]¶ Does the exact same thing as
backup_classifications()
except excutes the job on a QuickThread instance to avoid slow computers complaining about the GUI being frozen. This has been especially prevelant on Windows machines.- Parameters
run (HWIRun) – Run to save as mso file
-
classify_run
¶
-
ftp_download_status
¶
-
import_run_from_ftp
()[source]¶ Import runs from an FTP server. If an FTP download thread is not already running creates an FTPDialog instances and opens it to the user. FTP functions are then taken over by the FTPDialog until it is closed.
-
import_saved_runs
(xtal_files=[])[source]¶ Import runs saved to xtal files.
- Parameters
xtal_files (list, optional) – List of xtal files to import runs from, defaults to []
-
opening_run
¶
-
property
recent_files
¶ Return recently accessed imports.
- Returns
List of recently accessed imports
- Return type
list
polo.widgets.run_tree module¶
-
class
polo.widgets.run_tree.
RunTree
(parent=None, auto_link=True)[source]¶ Bases:
PyQt5.QtWidgets.QTreeWidget
Inherits the
QTreeWidget
class and acts as the sample and run display. The User uses the RunTree to open and classify runs they load into Polo.- Parameters
parent (QWidget, optional) – Parent widget, defaults to None
auto_link (bool, optional) – If True automatically link runs together, defaults to True
-
_add_classifications_from_mso_slot
(event=None)[source]¶ Add classifications to an existing
Run
from the contents of an MSO file. Intended to be connected to the classify_from_mso QAction that is defined in the :contextMenuEvent()
method.- Parameters
event (QEvent, optional) – QEvent, defaults to None
-
_classify_all_runs_slot
(sample_name)[source]¶ Classify all the unclassified runs belonging to a the selected sample.
-
_display_name_setter
(run)[source]¶ Private method that creates a display name for a run that also avoids collisions with existing display names. Currently the process of translating a display name to a
Run
object involves first looking up the display name in theformated_name_to_name
dictionary to get the run name and then looking up the run name in theloaded_runs
dictionary to get theRun
object. This means that currently run names and display names need to be unique to avoid collisions.
-
_edit_data_slot
(event=None)[source]¶ Private method used to update the data in a
Run
after it has been modified by the user through theRunUpdater
dialog.- Parameters
event (QEvent, optional) – QEvent, defaults to None
-
_get_run_node
(run)[source]¶ Private helper method that returns the
QTreeWidgetItem
corresponding to a givenRun
. Returns None if a node cannot be found.
-
_open_run_slot
(event=None)[source]¶ Private method that emits the
opening_run
signal when called. This signal can be connected to other widgets to communicate that the user has selected a run and wants to open it for analysis.- Parameters
event (QEvent, optional) – QEvent, defaults to None
-
_remove_run_slot
(event=None)[source]¶ Slot to connect to contextMenu popup to remove the selected run.
-
add_classified_run
(run)[source]¶ Marks a
Run
instance as classified by adding it to theclassified_status
dictionary.
-
add_run_to_tree
(new_run)[source]¶ Add a new
Run
instance to the tree. Uses theRun
instance’ssampleName
attribute to determine what sample node theRun
instance should be added to. If the sample name does not exist in the tree a new sample node is added. If theRun
instance lacks thesampleName
attribute as is the case for non-HWIRuns thesampleName
attribute is set to “Non-HWI Runs”. If theRun
instance is anHWIRun
and lacks thesampleName
attributesampleName
is set to “Sampleless Runs”.
-
add_sample
(sample_name, *args)[source]¶ Adds a new sample to the tree. Samples are the highest level node in the RunTree.
- Parameters
sample_name (str) – Name of sample to add, acts as key so should be unique.
-
classify_sample_signal
¶
-
contextMenuEvent
(event)[source]¶ Handle left click events by creating a popup context menu.
- Parameters
event (QEvent) – QEvent
-
property
current_run_names
¶ List of all currently loaded
Run
names.- Returns
List of :class:Run` names
- Return type
list
-
dropped_links_signal
¶
-
link_sample
(sample_name)[source]¶ Links all
Run
instances in a given sample together by both date and spectrum using thethe_big_link()
method.- Parameters
sample_name (str) – Name of the sample who’s runs should be linked
-
opening_run
¶
-
remove_run
(display_name)[source]¶ - Private method to remove a
Run
completely from the Polo interface.
- Parameters
display_name – Display name being shown to the user to represent the run to be removed.
- Private method to remove a
-
remove_run_from_view
(display_name, sample_name)[source]¶ Remove a
Run
instance using itsrun_name
attribute. Does not effect any other widgets. Calling this method only removes theRun
instance from the display. If aRun
instance is removed from successfully it is returned.TODO UPDATE
-
remove_run_signal
¶
-
save_run_signal
¶
polo.widgets.slideshow_inspector module¶
-
class
polo.widgets.slideshow_inspector.
slideshowInspector
(parent, run=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
The slideshowInspector widget is a primary run interface that allows users to view their screening images in a standard slideshow format. If multiple imaging runs of the sample sample exist it also allows the user to navigate between or simultaneously view these images.
- Parameters
-
_classify_image
(classification)[source]¶ Private method to change the human classification of the current image.
- Parameters
classification (str) – Image classification
-
_display_current_image
()[source]¶ Private method that displays the current image as determined by the current_image attribute of the slideshowViewer widget and populates any widgets that display current image metadata.
-
_mark_current_image_as_favorite
()[source]¶ Private method that sets the favorite label on the current image to the current value of the favorite
QCheckBox
.- Parameters
favorite_status (bool) – Whether this image is a favorite or not
Private method to control the carousel using boolean flags. Calls
carousel_controls()
.- Parameters
next_image (bool, optional) – If True navigates to next image in carousel, defaults to False
prev_image (bool, optional) – If True navigates to previous image in carousel, defaults to False
-
_set_alt_image
(next_date=False, prev_date=False, alt_spec=False)[source]¶ Display an image linked to the current image based on boolean flags.
- Parameters
next_date (bool, optional) – If True show the current image’s next image by date, defaults to False
prev_date (bool, optional) – If True, show the current image’s previous image by date, defaults to False
alt_spec (bool, optional) – If True, show the current image’s alt spectrum image, defaults to False
Turns alt spectrum functions on or off depending on contents of the Run instance referenced by the run attribute. Alt spectrum buttons will be enabled if the run is a part of an alt spectrum linked list. This means another Run instance is referenced by it’s alt_spectrum attribute.
Private method that sets the labels of image classification buttons based on the
IMAGE_CLASSIFICATIONS
constant. Should be called in the __init__ method.
-
_set_favorite_checkbox
()[source]¶ Private method that sets the value of the favorite
QCheckBox
based on whether the current image is marked as a favorite or not. Should be used when loading an image into the view.An image is considered a favorite if it’s favorite attribute == True.
-
_set_image_class_checkbox_labels
()[source]¶ Private method to the
QCheckBox
labels for imaging filtering from the IMAGE_CLASSIFICATIONS constant. Should be called in the __init__ method.
-
_set_image_name
()[source]¶ Private method that sets current image label to the image’s filepath basename.
-
_set_slideshow_mode
(show_all_dates=False, show_all_specs=False)[source]¶ Private method to set the slideshowViewer mode. Either to display a single image, all dates or all spectrums.
- Parameters
show_all_dates (bool, optional) – If True sets slideshowViewer to show all dates, defaults to False
show_all_specs (bool, optional) – If True sets slideshowViewer to show all spectrums, defaults to False
-
_set_time_resolved_functions
()[source]¶ Private method that turns time resolved functions on or off depending on contents of the Run instance referenced by the run attribute. Time resolved functions are enabled when the run is part of a time resolved linked list. This means another Run instance is referenced by it’s next_run and / or previous_run attributes.
-
_show_image_from_well_number
(well_number)[source]¶ Private method to display an image by well number.
- Parameters
well_number (int) – Well number of image to display
-
_submit_filters
()[source]¶ Private method that passes the current user selected image filters to the slideshowViewer so the current slideshow contents can be adjusted to reflect the new filters. Displays the current image after filtering.
-
property
current_image
¶ Current
Image
object being displayed in the slideshowViewer widget.- Returns
The current image
- Return type
-
property
current_sort_function
¶ Return a function to use for image sorting based on current user radiobutton sort selections.
- Returns
Sort function
- Return type
func
-
export_current_view
()[source]¶ Export the current view to a png file. Show the user a message box to tell them if the export succeeded or failed.
-
property
favorites
¶ Returns the state of the favorite
QCheckBox
.- Returns
Favorite
QCheckBox
state- Return type
bool
-
property
human
¶ State of the human classifier
QCheckBox
. If True, assume the user wants their selected image classifications to be in reference to image’s human classification.- Returns
State of the
QCheckBox
- Return type
bool
-
property
marco
¶ State of the MARCO classifier
QCheckBox
. If True, assume the user wants their selected image classifications to be in reference to image’s MARCO classification.- Returns
State of the
QCheckBox
- Return type
bool
-
property
run
¶
-
property
selected_classifications
¶ Returns image classification keywords for any image classification
QCheckBox
instances that are checked.- Returns
List of selected images classifications
- Return type
list
-
static
sort_images_by_cocktail_number
(images)[source]¶ Helper method that sorts a collection of images by their cocktail number. Returns False if the images cannot be sorted by this parameter.
- Parameters
images (list) – List of images to be sorted
- Returns
List of images sorted by cocktail number, False if cannot be sorted
- Return type
list, bool
-
static
sort_images_by_marco_confidence
(images)[source]¶ Helper method to sort a collection of images by their MARCO classification confidence. Does not descriminate based on image classification.
- Parameters
images (list) – List of images to sort
- Returns
List of images sorted by prediction confidence
- Return type
list
-
static
sort_images_by_well_number
(images)[source]¶ Helper method to sort a collection of images by their well number. If images cannot be sorted by well number (which in theory shouldn’t happen) returns False
- Parameters
images (list) – List of images to be sorted
- Returns
List os images sorted by well number
- Return type
list
polo.widgets.slideshow_viewer module¶
-
class
polo.widgets.slideshow_viewer.
Carousel
[source]¶ Bases:
object
The Carousel class handles navigation between Slide instances.
-
add_slides
(ordered_images, sort_function=None)[source]¶ Sets up linked list consisting of nodes of Slide instances. The list is circular and bi-directional. Sets self.current_slide to the first slide in the linked list. The order of the slides in the linked list will reflect the order of the images in the ordered_images argument.
- Parameters
ordered_images – a list of Image objects to create the linked list from. The order of the images will be reflected by the linked list.
- Returns
First slide in linked list
- Return type
-
controls
(next_slide=False, prev_slide=False)[source]¶ Controls the navigation through the slides in the carousel. Does not control access to alternative images that may be available to the user.
- Parameters
next_slide (bool) – If set to True, tells the carousel to advance one Slide
prev_slide (bool) – If set to True, tells the carousel to retreat by one Slide
-
-
class
polo.widgets.slideshow_viewer.
PhotoViewer
(parent)[source]¶ Bases:
PyQt5.QtWidgets.QGraphicsView
-
add_pixmap
(pixmap)[source]¶ Adds a Pixmap instances to the current sene.
- Parameters
pixmap (Pixmap) – Pixmap to add to the sene
-
fitInView
(self, QRectF, mode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio)[source]¶ fitInView(self, QGraphicsItem, mode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio) fitInView(self, float, float, float, float, mode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio)
-
mousePressEvent
(event)[source]¶ Handles mouse press events.
- Parameters
event (QEvent) – Mouse press event
-
photoClicked
¶
-
-
class
polo.widgets.slideshow_viewer.
Slide
(image, next_slide=None, prev_slide=None, slide_number=None)[source]¶ Bases:
object
Acts like a slide in a slideshow carousel. Holds an Image object instance as the contents of the slide. Forms a linked list with other slides through the next_slide and prev_slide attributes which act as the forwards and backwards pointers to other slides.
- Parameters
-
class
polo.widgets.slideshow_viewer.
SlideshowViewer
(parent, run=None, current_image=None)[source]¶ Bases:
polo.widgets.slideshow_viewer.PhotoViewer
-
_add_text_to_scene
(text, x, y, size=40)[source]¶ Private method to add text on top of an image. Adds the text to the current scene at the position specified by the x and y arguments.
- Parameters
text (str) – Text to add to image
x (int) – X cordinate of text
y (int) – Y cordinate of text
size (int, optional) – Size of text, defaults to 40
-
_set_all_dates_scene
(image)[source]¶ Private method that creates a time resolved view from the
Image
instance passed through the image argument.- Parameters
image (Image) – Image to create time resolved view from
-
_set_all_spectrums_scene
(image)[source]¶ Private method that creates a view that includes all alt spectrum images the
Image
instance is linked to.- Parameters
image (Image) – Image to create the view from
-
_set_single_image_scene
(image)[source]¶ Private method that creates a standard single image view from the
Image
instance passed to the image argument.- Parameters
image (Image) – Image to display
-
arrange_multi_image_scene
(image_list, render_date=False)[source]¶ Helper method to arrange multiple images into the same view.
- Parameters
image_list (list) – List of images to add to the view
render_date (bool, optional) – If True adds a date label to each image, defaults to False
-
carousel_controls
(next_image=False, previous_image=False)[source]¶ Wrapper around the
controls()
method that allows image navigation. Does not actually display the image.- Parameters
next_image (bool) – If True, tells carousel to advance by one slide.
previous_image (bool) – If True, tells carousel to retreat by one slide.
:returns The current image. :rtype Image
-
classify_current_image
(classification)[source]¶ Changes the human classification of the current image.
-
property
current_slide_number
¶
-
display_current_image
()[source]¶ Renders the Image instance currently stored in the current_image attribute.
-
get_cur_img_cocktail_str
()[source]¶ Retruns the current_image cocktail information as a string.
- Returns
Cocktail information string
- Return type
str
-
get_cur_img_meta_str
()[source]¶ Returns the current_image metadata as a string.
- Returns
Metadata string
- Return type
str
-
photoClicked
¶ Wrapper class around QGraphicsView and displays image to the user in the slideshow viewer tab of the main window.
-
property
run
¶
-
set_alt_image
(next_date=False, prev_date=False, alt_spec=False)[source]¶ Sets the current_image attribute to a linked image specified by one of the three boolean flags.
- Parameters
next_date – If True, sets the current_image to the next image by date
prev_date – If True, sets the current_image to the previous image by date
alt_spec – If True, sets the current_image to an alt spectrum image
-
set_current_image_by_well_number
(well_number)[source]¶ Set the current image to the
Image
instance associated with a specific well number.- Parameters
well_number (int) – Well number to display
-
property
total_slides
¶
-
update_slides_from_filters
(image_types, human, marco, favorite=False, sort_function=None)[source]¶ Creates new Carousel slides based on selected image filters. Sets the current_image attribute to the
Image
instance at the the current slide attribute of _carousel attribute.- Parameters
image_types (set or list) – Set of image classifications to include in results.
human (bool) – If True, image_types refers to human classification of the image.
marco (bool) – If True, image_types refers to the machine (MARCO) classification of the image.
-
polo.widgets.table_inspector module¶
-
class
polo.widgets.table_inspector.
TableInspector
(parent=None, run=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
TableInspector class displays a run’s data in a spreadsheet type view.
- Parameters
-
_assign_checkboxes_to_class
()[source]¶ Private method that assigns filtering checkboxs to an image classification from the IMAGE_CLASSIFICATION constant.
-
_set_column_options
()[source]¶ Private method that sets the availabe columns to display based on the attributes of the run stored in the run attribute. Adds a
QCheckBox
widget for each attribute.TODO: formating for private attributes to make them prettier
-
property
run
¶
-
property
selected_classifications
¶ Return image classifications that are currently selected.
- Returns
List of selected image classifications
- Return type
set
-
property
selected_headers
¶ Return the headers that have been selected by the user.
- Returns
Names of column headers that are currently selected
- Return type
set
polo.widgets.table_viewer module¶
-
class
polo.widgets.table_viewer.
TableViewer
(parent, run=None)[source]¶ Bases:
PyQt5.QtWidgets.QTableWidget
TableViewer instances override QTableWidget and provide a more convenient interface for translating the data in Run and HWIRun objects into a table format.
- Parameters
parent (QtWidget) – Parent widget
run (Run, optional) – Run to show in this table view, defaults to None
-
_make_header_map
(headers)[source]¶ Private method to map header keywords to their index (order). This method is required as headers are delivered as a set and we want them to be presented in a consistent order to the user.
- Parameters
headers (set) – Set of headers strings
- Returns
Dictionary of header strings mapped to indices
- Return type
dict
-
property
fieldnames
¶ Return the fieldnames for the current run. Should only be used when setting the values for the listWidget in a tableInspector instance as is expensive to call.
- Returns
list of fieldnames
- Return type
list
-
static
filter
(row, image_classes, human, marco)[source]¶ Helper method to determine if a row should be included based on the image filters the user has selected
- Parameters
row (dict) – row data
image_classes (set or list) – types of images to include, i.e Crystals, Clear
human (Bool) – If image_classes should be in reference to human classifier
marco (Bool) – If image_classes should be in reference to machine classifier
- Returns
If image should be filtered, False means do not filter image
- Return type
Bool
-
populate_table
(image_classes, human, marco)[source]¶ Populates the table and displays data to the user based on their header and image filtering selections.
- Parameters
image_classes (set or list) – types of images to include, i.e Crystals, Clear
human (Bool) – If image_classes should be in reference to human classifier
marco (Bool) – If image_classes should be in reference to machine classifier
- Returns
If image should be filtered, False means do not filter image
-
property
table_data
¶ Property to retrieve the current table fieldnames and table data using get_csv_data function of the RunCsvWriter class.
- Returns
fieldnames, table data
- Return type
tuple
polo.widgets.unit_combo module¶
-
class
polo.widgets.unit_combo.
UnitComboBox
(parent=None, base_unit=None, scalers={})[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget that is a combination of a spinbox and a comboBox that allows a user to select a value using the spinBox and a unit using the comboBox.
Example:
Lets say we want to create a UnitComboBox that allows someone to select a Molar concentration using micro-molar, milli-molar, centi-molar or molar.
# create the scaler dictionary s = { 'u': 1e-6, 'm': 1e-3, 'c': 1e-2 } # values are in reference to the base unit unit_combo = UnitComboBox( parent=None, base_unit='M', scalers=s )
- Parameters
parent (QWidget, optional) – Parent widget, defaults to None
base_unit (str, optional) – Base unit string, defaults to None
scalers (dict, optional) – Dictionary of prefixes to apply to the baseunit. Keys should be string prefixes and values should be value that scales the baseunit, defaults to {}
-
_set_unit_combobox_text
()[source]¶ Private method to add units to the unit comboBox based on the base_unit and the scalers attributes.
- Returns
Items added to the comboBox
- Return type
list
-
get_value
()[source]¶ Return a UnitValue constructed from the value of the spinBox value and unit from the comboBox.
- Returns
UnitValue constructed from current spinBox value and comboBox unit
- Return type
-
saved_scalers
= {'c': 0.01, 'm': 0.001, 'u': 1e-06}¶
-
property
scalers
¶ The current scalers.
- Returns
List of scaler values
- Return type
list
-
set_value
(value, *args)[source]¶ Set the spinBox value and the comboBox unit based on the value and unit of a UnitValue instance
- Parameters
value (UnitValue) – UnitValue
-
property
sorted_scalers
¶ Scalers sorted by their magnitude.
- Returns
List of scalers
- Return type
list
-
property
unit_combobox_text
¶ The text in unit comboBox which corresponds to a specific scaler.
- Returns
List of all scalers in the unit comboBox
- Return type
list