microscope_automation.util package¶
Submodules¶
microscope_automation.util.automation_exceptions module¶
Classes for exceptions Do not name module exceptions. It will conflict with system exceptions. Created on Jun 7, 2017
@author: winfriedw
-
exception
microscope_automation.util.automation_exceptions.AutofocusError(message=None, error_component=None, focus_reference_obj_id=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.HardwareErrorException if autofocus failed.
-
exception
microscope_automation.util.automation_exceptions.AutofocusNoReferenceObjectError(message=None, error_component=None, focus_reference_obj_id=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutofocusErrorException if no reference object was selected for autofocus
- Input:
focus_reference_obj_id: Sample object used as reference for autofocus
message: Test to display as error message
-
exception
microscope_automation.util.automation_exceptions.AutofocusNotSetError(message=None, error_component=None, focus_reference_obj_id=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutofocusErrorException if objective was changed since autofocus was initialized
- Input:
focus_reference_obj_id: Sample object used as reference for autofocus
message: Test to display as error message
-
exception
microscope_automation.util.automation_exceptions.AutofocusObjectiveChangedError(message=None, error_component=None, focus_reference_obj_id=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutofocusErrorException if objective was changed since autofocus was initialized
- Input:
focus_reference_obj_id: Sample object used as reference for autofocus
message: Test to display as error message
- Output:
none
-
exception
microscope_automation.util.automation_exceptions.AutomationError(message=None, error_component=None)[source]¶ Bases:
ExceptionBase exception for all errors in package microscopeautomation
-
exception
microscope_automation.util.automation_exceptions.CrashDangerError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException if danger for hardware was detected.
-
exception
microscope_automation.util.automation_exceptions.ExperimentError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.HardwareErrorException for failures experiment execution.
-
exception
microscope_automation.util.automation_exceptions.ExperimentNotExistError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.ExperimentErrorException for failures experiment execution.
-
exception
microscope_automation.util.automation_exceptions.FileExistsError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException if file exists to prevent overriding it.
-
exception
microscope_automation.util.automation_exceptions.HardwareCommandNotDefinedError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException if experiment is not defined for this microscope.
-
exception
microscope_automation.util.automation_exceptions.HardwareDoesNotExistError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.HardwareErrorException if hardware was not defined.
-
exception
microscope_automation.util.automation_exceptions.HardwareError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException for failures in hardware.
-
exception
microscope_automation.util.automation_exceptions.HardwareNotReadyError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException if hardware is not ready for experiment.
-
exception
microscope_automation.util.automation_exceptions.IOError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException for I/O errors.
-
exception
microscope_automation.util.automation_exceptions.LoadNotDefinedError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.HardwareErrorException if load position for focus drive is not defined.
-
exception
microscope_automation.util.automation_exceptions.MetaDataNotSavedError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorException if data could not be saved to meta data file.
-
exception
microscope_automation.util.automation_exceptions.ObjectiveNotDefinedError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.HardwareErrorException if selected objective was not defined.
-
exception
microscope_automation.util.automation_exceptions.StopCollectingError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.AutomationErrorStop collecting sample positions.
-
exception
microscope_automation.util.automation_exceptions.WorkNotDefinedError(message=None, error_component=None)[source]¶ Bases:
microscope_automation.util.automation_exceptions.HardwareErrorException if work position for focus drive is not defined.
microscope_automation.util.automation_messages_form_layout module¶
QDialog boxes and other messages for Microscope Automation package based on formlayout https://pypi.python.org/pypi/formlayout http://pythonhosted.org/formlayout/index.html# https://github.com/PierreRaybaut/formlayout http://pyqt.sourceforge.net/Docs/PyQt4/ https://wiki.qt.io/PySide
Requires PyQt4 or PyQt5, set installed API below
Created on Jun 23, 2016
@author: winfriedw
-
microscope_automation.util.automation_messages_form_layout.check_box_message(message, checkBoxList, return_code=False)[source]¶ Ask user to operate microscope manually and allows option to abort script.
- Input:
message: Message that will be displayed
- checkBoxList: list with check box names and settings in form:
[(‘Choice 1’, True), (‘Choice 2’, False)
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
new_check_box_list: User pressed ok result is updated checkBoxList
-
microscope_automation.util.automation_messages_form_layout.error_message(message, return_code=False, blocking=True)[source]¶ Show error message and allows option to abort script.
- Input:
message: Message that will be displayed
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
blocking: if True use modal dialog for error reporting, otherwise print(message)
- Return:
0: User selected to abort script
1: User pressed ok
-1: User pressed ok and selected ‘Ignore’
-
microscope_automation.util.automation_messages_form_layout.file_select_dialog(directory, file_pattern=None, comment=None, return_code=False)[source]¶ List all files in directory and select one.
- Input:
directory: path to directory with files
file_pattern: string with regular expression. If file matches expression it will be pre-selected.
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Output:
file_path: path to selected file
-
microscope_automation.util.automation_messages_form_layout.information_message(title, message, return_code=False)[source]¶ Displays information to user and allows option to abort script.
- Input:
title: Title of dialog box
message: Message that will be displayed
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
1: User pressed ok
-
microscope_automation.util.automation_messages_form_layout.operate_message(message, return_code=False)[source]¶ Ask user to operate microscope manually and allows option to abort script.
- Input:
message: Message that will be displayed
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
1: User pressed ok
-
microscope_automation.util.automation_messages_form_layout.pull_down_select_dialog(item_list, message)[source]¶ Show all items from itemList in pulldown menu and allow user to select one item.
- Input:
itemList: list of strings to display in pull down menu
message: string with instructions to user
- Output:
selected_item: item selected by user
-
microscope_automation.util.automation_messages_form_layout.read_string(title, label, default, return_code=False)[source]¶ Ask for user input and allows option to abort script.
- Input:
title: Title of dialog box
label: Text to display in front of sting input field
default: default input
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
1: User pressed ok
-
microscope_automation.util.automation_messages_form_layout.select_message(message, count=None, return_code=False)[source]¶ Interrupt script and wait for user to continue.
- Input:
message: Message that will be displayed
count: number of collected positions
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
resultDict: dictionary of form {‘Include’: True/False, ‘Continue’: True/False}
-
microscope_automation.util.automation_messages_form_layout.setup_message(message, return_code=False)[source]¶ Displays information about setup error and allows option to abort script.
- Input:
message: Message that will be displayed
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
1: User pressed ok
-
microscope_automation.util.automation_messages_form_layout.stop_script(message_text=None, allow_continue=False)[source]¶ Script will stop all Microscope action immediately and ask user to stop execution of script or to continue.
- Input:
message_text: Message to user explaining why processing should be stopped.
allow_continue: if True, allow user to continue. Default: False
- Output:
none if user selects ‘Continue’, otherwise calls sys.exit()
-
microscope_automation.util.automation_messages_form_layout.value_calibration_form(title, comment, default, *form_fields)[source]¶ Attribute selection dialog for value calibration Last result value will always be True or False for whether the value(s) were acceptable
- Input:
title: title for the form
comment: comment for the form
form_fields: variable length argument list for all fields to be changed
- Output:
result: contents of the calibration form
-
microscope_automation.util.automation_messages_form_layout.wait_message(message, return_code=False)[source]¶ Interrupt script and wait for user to continue.
- Input:
message: Message that will be displayed
return_code: if True, will return after cancel with code 0, otherwise will call sys.exit()
- Return:
0: User selected to abort script
True: User pressed ok and want’s to continue to wait after each image
False: User pressed ok and want’s to cancel wait times
microscope_automation.util.error_handling module¶
Tools for error handling and logging Created on Jul 31, 2016
@author: winfriedw
-
microscope_automation.util.error_handling.setup_logger(prefs, log_level='DEBUG')[source]¶ Initialize logger. Will work over multiple modules
see https://docs.python.org/2/howto/logging-cookbook.html#using-logging-in-multiple-modules
microscope_automation.util.get_path module¶
Collection of functions to return path for settings, logfile, and data Created on Aug 8, 2016
@author: winfriedw
-
microscope_automation.util.get_path.add_suffix(file_path, suffix)[source]¶ Add suffix to end of file name.
- Input:
file_path: path to file name
suffix: suffix to put between end of filename and file extension
- Output:
new_file_path: file_path with suffix
-
microscope_automation.util.get_path.get_calibration_path(prefs)[source]¶ Return path to calibration information e.g. blackreference images
- Input:
prefs: Preferences object created from YAML file
- Output:
calibration_path: path to calibration directory
-
microscope_automation.util.get_path.get_colony_dir_path(prefs, barcode=None)[source]¶ Return path to directory with .csv file with colony positions and features.
- Input:
prefs: Preferences object created from YAML file
barcode: Use the plate barcode to make the folder
- Output:
colonyDir: path to log file
-
microscope_automation.util.get_path.get_colony_file_path(prefs, colony_file, barcode=None)[source]¶ Return path to file with colony information typically produced by CellProfiler based on Celigo platescanner data.
- Input:
prefs: Preferences object created from YAML file
colony_file: path to .csv file with colony data
barcode: Use the plate barcode to make the folder
- Output:
colony_file_path: complete path to colony file
-
microscope_automation.util.get_path.get_colony_remote_dir_path(prefs)[source]¶ Return path to directory with .csv file with colony positions and features on network.
- Input:
prefs: Preferences object created from YAML file
- Output:
colony_dir_path: path to log file
-
microscope_automation.util.get_path.get_daily_folder(prefs, barcode=None)[source]¶ Find folder for daily settings and results. Create folder if not existing.
- Input:
prefs: Preferences object created from YAML file
barcode: Use the plate barcode to make the folder
- Output:
daily_path: path to daily folder. No ‘/’ at end.
-
microscope_automation.util.get_path.get_experiment_path(prefs, dir=False)[source]¶ Return path to experiment.
- Input:
prefs: Preferences object created from YAML file
dir: if true return path to experiments directory, otherwise to experiment file. Default: False
- Output:
experiment_path: path to experiment
-
microscope_automation.util.get_path.get_hardware_settings_path(prefs)[source]¶ Return path to .yml file with microscope specifications from preferences file.
- Input:
prefs: Preferences object created from YAML file
- Output:
hardwarePath: path to layout file
-
microscope_automation.util.get_path.get_images_path(prefs, sub_dir=None, barcode=None)[source]¶ Return path to directory for images. Create directory if not available
- Input:
prefs: Preferences object created from YAML file
sub_dir: Sub-directory for images. Will create folder with this name
barcode: Use the plate barcode to make the folder
- Output:
references_path: path to directory for reference images for specific well
-
microscope_automation.util.get_path.get_log_file_path(prefs)[source]¶ Return path to log file.
- Input:
prefs: Preferences object created from YAML file
- Output:
log_file_path: path to log file
-
microscope_automation.util.get_path.get_meta_data_path(prefs, barcode=None)[source]¶ Return path for meta data.
- Input:
prefs: Preferences object created from YAML file
barcode: Use the plate barcode to make the folder
- Output:
meta_data_file: path to log file
-
microscope_automation.util.get_path.get_position_csv_path(prefs, barcode=None)[source]¶ Function to get the file path for the csv files where all the positions are stored after segmentation.
- Input:
prefs: preferences
barcode: Use the plate barcode to make the folder
- Output:
paths: file paths for the files
-
microscope_automation.util.get_path.get_recovery_settings_path(prefs)[source]¶ Returns the file path to save the pickled dictionary after interruption
- Input:
prefs: Preferences object created from YAML file
- Output:
file_path: path to recovery settings
-
microscope_automation.util.get_path.get_references_path(prefs, barcode=None)[source]¶ Return path to directory for reference images. Create directory if not available
- Input:
prefs: Preferences object created from YAML file
barcode: Use the plate barcode to make the folder
- Output:
references_path: path to directory for reference images for specific well
-
microscope_automation.util.get_path.get_valid_path_from_prefs(prefs, key, search_dir=True, validate=False)[source]¶ Read list of paths from prefs and return first valid match.
- Input:
prefs: Preferences object created from YAML file
key: key for pathlist in preferences.yml
search_dir: if True search for directory, otherwise for file
- Output:
return_path: path to valid file or directory
-
microscope_automation.util.get_path.get_well_edge_path(prefs, barcode=None)[source]¶ Return path to folder where well edge images are saved. Used to determine the well’s center.
- Input:
prefs: Preferences object created from YAML file
- Output:
well_edge_path: path to calibration directory
-
microscope_automation.util.get_path.set_up_settings_folders(prefs, keys=['PathCalibration', 'RecoverySettingsFilePath', 'LogFilePath', 'PathDailyFolder'])[source]¶ Checks if the folders specified in preferences exist and makes them if not
- Input:
prefs: Preferences object created from YAML file
- Output:
none
-
microscope_automation.util.get_path.set_up_subfolders(parent_folder_path, subfolder)[source]¶ Set the Subfolders for imaging folder - e.g. TapeOnly and Failed QC
- Input:
parent_folder_path: Image Folder Path
subfolder: folder to create, can be list of multiple folders
- Output:
subfolders: list of full path of subfolders created
microscope_automation.util.image_AICS module¶
Module with class ImageAICS to wrap image data as numpy arrays and meta data as dictionaries. Add display methods Created on Jul 11, 2016
@author: winfriedw
-
class
microscope_automation.util.image_AICS.ImageAICS(data=None, meta=None)[source]¶ Bases:
objectstore and display image data
-
add_meta(meta)[source]¶ Add meta data. Use keys as defined in OME-XML.
- Input:
meta: dictionary with meta data
- Output:
none
-
create_file_name(template)[source]¶ Create file name based on meta data and template.
- Input:
template: string with filename with path for saved image in original format or tuple with path to directory and template for file name
- Output:
filePath: file name and path for image
-
get_data()[source]¶ retrieve image data as numpy array.
- Input:
none
- Output:
data: numpy array with image data
-
get_meta(key=None)[source]¶ Retrieve meta data. Use keys as defined in OME-XML.
- Input:
none
- Output:
meta: dictionary with meta data
-
parse_file_template(template)[source]¶ Create file name based on meta data and template.
- Input:
template: string with filename
- Output:
fileName: file name for image
-
microscope_automation.util.load_image_czi module¶
microscope_automation.util.software_state module¶
File to keep track of the state of the software.
@author: winfriedw
-
class
microscope_automation.util.software_state.DiagnosticPickler(file, protocol=None, fix_imports=True, buffer_callback=None)[source]¶ Bases:
_pickle.Pickler
-
class
microscope_automation.util.software_state.State(recovery_file_path=None)[source]¶ Bases:
object-
add_last_experiment_object(exp_object_name)[source]¶ Add objects to the list for last experiment objects to keep track of which cells have already been imaged. To be able to pick up exactly where we left off
- Input:
exp_object_list: list of experiment objects to add for the next experiment
- Output:
none
-
add_next_experiment_object(experiment_name, exp_object_list)[source]¶ Add objects to the list for next experiment objects.
- Input:
experiment_name: name of experiment to add
exp_object_list: list of experiment objects to add for the next experiment
- Output:
none
-
add_unpickled_objects(base_object)[source]¶ Function to add Zen object back
- Input
base_object: The reference object or next experiment object to rehydrate
- Output:
none
-
eliminate_unpickled_objects(base_object)[source]¶ Remove unpickled objects from given object
- Input:
base_object: Object that needs to be pruned
- Output:
none
-
prune_object_dict()[source]¶ Function to strip away the Zen microscope object from each level of the sample object tree.
Reason - there are some objects in microscope class (communication object) that can’t be pickled.
- Input:
object_dict: The dictionary that needs to be filtered.
- Output:
object_dict: The filtered dictionary.
-
recover_objects(file_path)[source]¶ Function to return next objects dictionary and the reference object by unpickling the file.
- Input:
filepath: path to the pickled file
- Output:
tuple of recovered objects in the form (next_experiment_objects, reference_object, last_experiment_objects, hardware_status_dict)
-
rehydrate_removed_references()[source]¶ In case of auto save, we need the Zen object to be added back (it was removed before pickling)
- Input:
none
- Output:
none
-
Module contents¶
Utility package for Microscope Automation.