core

Defines central classes that are re-used throughout the findmycells package (findmycells.core)

Handling data processing

The following two classes, ProcessingObject and ProcessingStrategy, provide the blueprints for all processing strategies and objects that are used throughout the findmycells package. As you can see in the corresponding processing step modules (i.e. “preprocess”, “segment”, or “quantify”), these abstract base classes provide the basic structure of the more specific objects and strategies in each of these modules (e.g. QuantificationObject and QuantificationStrategy within the “quantify” module inherit from ProcessingObject and ProcessingStrategy, respectively). While this makes these two classes highly relevant for any developer, regular users of findmycells won´t be interacting with them, even if they want to use the API instead of the GUI.


source

ProcessingObject

 ProcessingObject ()

Abstract base class (inherits from ABC) that defines the general structure of ProcessingObjects in findmycells. A ProcessingObject combines all information needed for the corresponding processing step, i.e. what files are supposed to be processed & how. It also interfaces to the database of the project, such that it can automatically update the database with the latest progress.

Associated public methods:


source

ProcessingObject.export_current_gui_config_values

 ProcessingObject.export_current_gui_config_values ()

Passes the function call further to the GUIConfigs object to extract the current configs.


source

ProcessingObject.initialize_gui_configs_and_widget

 ProcessingObject.initialize_gui_configs_and_widget ()

Constructs a GUIConfigs from the respectively specified properties and uses the GUIConfigs.construct_widget method to build the associated widget and sets it as attribute (self.widget).


source

ProcessingObject.prepare_for_processing

 ProcessingObject.prepare_for_processing (file_ids:List[str],
                                          database:findmycells.database.Da
                                          tabase)
Type Details
file_ids typing.List[str] A list with the file_ids of all files that need to be processed
database Database The database of the findmycells project
Returns None

source

ProcessingObject.run_all_strategies

 ProcessingObject.run_all_strategies (strategies:List,
                                      strategy_configs:List[Dict])

Runs all ProcessingStrategies that were passed upon initialization (i.e. self.strategies). For this, the corresponding ProcessingStrategy objects will be initialized and their “.run()” method will be called, while passing “self” as “processing_object”. Finally, it updates the database and deletes the ProcessingStrategy object to clear it from memory.


source

ProcessingObject.update_database

 ProcessingObject.update_database (mark_as_completed:bool=True)

For each microscopy file that had to be processed (self.file_ids), the database will be updated with the respective processing progress information. Interfaces back to the abstract method “self.add_processing_specific_infos_to_updates()” that enables the corresponding subclasses to add more specific details before triggering the update method of the database.

For developers:

Associated properties that need to be implemented in subclasses inheriting from ProcessingObject. Feel free to check out the available implementations to see how this should look like, for instance in the “findmycells.preprocessing.specs” or “findmycells.segmentation.specs” submodules.


source

ProcessingObject.default_configs

 ProcessingObject.default_configs ()

Abstract method that requires its subclasses to define the default_configs as a property of the class. Thus, this will specify all configuration options that come with each subclass, while simultaneously also providing default values for each option and, moreover, defining what types of values are allowed for each option. Check out the implementation of DefaultConfigs in the configs module, or have a look at how this is implemented in one of the processing sub-modules, for instance in the “specs.py” file in the preprocessing sub-module.


source

ProcessingObject.descriptions

 ProcessingObject.descriptions ()

Descriptions that will be used as “description” parameter in the created widgets.


source

ProcessingObject.processing_type

 ProcessingObject.processing_type ()

Abstract property. Will be used in the database to keep track of the processing progress of the project. Has to be a string that matches with an available processing module (i.e. “preprocessing”, “segmentation”, “postprocessing”, “quantification”).


source

ProcessingObject.tooltips

 ProcessingObject.tooltips ()

Additional information that can be displayed as tooltip by the respective widget. Unfortunately, tooltips are not available for all widget types in the ipywidgets version that is used by findmycells.


source

ProcessingObject.widget_names

 ProcessingObject.widget_names ()

Defines which widgets will be created (e.g. “Checkbox” or “Dropdown”). See GUIConfigs to see a full list of available options.

Associated abstract methods that need to be implemented in subclasses inheriting from ProcessingObject:


source

ProcessingObject._add_processing_specific_infos_to_updates

 ProcessingObject._add_processing_specific_infos_to_updates (updates:Dict)

Abstract method that that requires its subclasses to define what updates need to be passed to the database, in addition to those that are already covered by the corresponding ProcessingStrategies or the “self.update_database()” method. If there are no more information to add, simply return the input ‘updates’ dictionary without any alterations.

Returns a dictionary with all updates that need to be passed to the database.

Type Details
updates typing.Dict A dictionary with updates that need to be passed to the database
Returns typing.Dict A dictionary with all updates that need to be passed to the database

source

ProcessingObject._processing_specific_preparations

 ProcessingObject._processing_specific_preparations ()

Allows to keep the init() method clear of any functions, which is required to be able to just instantiate a representative object to create its GUI widget (using the GUIConfigs set as attribute). Will be called in the prepare_for_processing() method and, thus, still enable processing step specific computations before the strategies are executed.

Leave as “pass” if nothing needs to be done here.





source

ProcessingStrategy

 ProcessingStrategy ()

Abstract base class that defines the general structure of ProcessingStrategies in findmycells. A ProcessingStrategy combines all functions that are required for one particular processing step, e.g. ConvertTo8Bit is a ProcessingStrategy in the “preprocess” module and converts the corresponding images into 8-bit.

Associated public methods:


source

ProcessingStrategy.export_current_gui_config_values

 ProcessingStrategy.export_current_gui_config_values ()

Passes the function call further to the GUIConfigs object to extract the current configs.


source

ProcessingStrategy.initialize_gui_configs_and_widget

 ProcessingStrategy.initialize_gui_configs_and_widget ()

Constructs a GUIConfigs from the respectively specified properties and uses the GUIConfigs.construct_widget method to build the associated widget and sets it as attribute (self.widget).


source

ProcessingStrategy.update_tracking_histories

 ProcessingStrategy.update_tracking_histories
                                               (processing_object:__main__
                                               .ProcessingObject,
                                               strategy_configs:Dict)

For developers:

Associated properties that need to be implemented in subclasses inheriting from ProcessingStrategy. Feel free to check out the available implementations to see how this should look like, for instance in the “findmycells.preprocessing.specs” & “findmycells.preprocessing.strategies” submodules.


source

ProcessingStrategy.default_configs

 ProcessingStrategy.default_configs ()

Abstract method that requires its subclasses to define the default_configs as a property of the class. Thus, this will specify all configuration options that come with each subclass, while simultaneously also providing default values for each option and, moreover, defining what types of values are allowed for each option. Check out the implementation of DefaultConfigs in the configs module, or have a look at how this is implemented in one of the processing sub-modules, for instance in the “specs.py” file in the preprocessing sub-module.


source

ProcessingStrategy.descriptions

 ProcessingStrategy.descriptions ()

Descriptions that will be used as “description” parameter in the created widgets.


source

ProcessingStrategy.processing_type

 ProcessingStrategy.processing_type ()

Abstract property. Will be used for instance in the database to keep track of the processing progress of the project. Has to be a string that matches with an available processing module (i.e. “preprocessing”, “segmentation”, “postprocessing”, “quantification”).


source

ProcessingStrategy.tooltips

 ProcessingStrategy.tooltips ()

Additional information that can be displayed as tooltip by the respective widget. Unfortunately, tooltips are not available for all widget types in the ipywidgets version that is used by findmycells.


source

ProcessingStrategy.widget_names

 ProcessingStrategy.widget_names ()

Defines which widgets will be created (e.g. “Checkbox” or “Dropdown”). See GUIConfigs to see a full list of available options.


source

ProcessingStrategy.dropdown_option_value_for_gui

 ProcessingStrategy.dropdown_option_value_for_gui ()

This string will be used as the option in the strategy selection dropdown in the GUI of findmycells.

Associated abstract methods that need to be implemented in subclasses inheriting from ProcessingStrategy:


source

ProcessingStrategy.run

 ProcessingStrategy.run (processing_object:__main__.ProcessingObject,
                         strategy_configs:Dict)

Here comes the code that actually does the processing of the data.


source

ProcessingStrategy._add_strategy_specific_infos_to_updates

 ProcessingStrategy._add_strategy_specific_infos_to_updates (updates:Dict)

Allows to add processing specific information that is deemed relevant to the FileHistory objects in the Database. If there are no relevant information, simply return the “updates” dictionary again without changes.




Handling data import

Furthermore, the following two classes DataLoader and DataReader will be re-used throughout the findmycells package to load data into your findmycells project. You can find the specific implementations of DataReaders in the findmycells.reader module.


source

DataReader

 DataReader ()

Abstract base class that defines the general structure of DataReader subclasses. Essentially, it demands the corresponding subclasses to define the “readable_filetype_extensions” attribut, as well as the “set_optional_configs()” and the “read()” methods.

Associated public methods (all abstract methods, that need to be implemented):


source

DataReader.read

 DataReader.read (filepath:pathlib.Path, reader_configs:Dict)

This method eventually reads the data stored at the given filepath applying the specified configs. The returned datatype will be different for each DataReader subclass, e.g. a numpy array of a specific shape for MicroscopyImageReaders, or a shapely Polygon for ROIReaders.


source

DataReader.assert_correct_output_format

 DataReader.assert_correct_output_format (output:Any)

Run an assert to validate that the data was actually read in the correct way and that the created output matches the intended format!





source

DataLoader

 DataLoader ()

Works as an interface between whatever needs to import data (e.g. a PreprocessingObject) and the DataReaders. It will look for an adequate reader implemented for the specific data type (i.e. filetype) at hand.

Associated public methods:


source

DataLoader.determine_reader

 DataLoader.determine_reader (file_extension:str,
                              data_reader_module:module)

Check whether there is a reader implemented in the requested reader submodule that can handle the specified filetype inferred from its extension. For developers: new readers will only be recognized, if their class names end with ‘Reader’. Please check out one of the implemented ones (e.g.  findmycells.readers.microscopy_images.CZIReader).


source

DataLoader.load

 DataLoader.load (data_reader_class:__main__.DataReader,
                  filepath:Union[pathlib.PosixPath,pathlib.WindowsPath],
                  reader_configs:Dict)

Uses the provided DataReader subclass to import the data.