Source code for pyfibre.core.base_multi_image_analyser
from abc import abstractmethod
import os
from traits.api import ABCHasTraits, Instance, provides
from .i_multi_image import IMultiImage
from .i_multi_image_analyser import IMultiImageAnalyser
[docs]@provides(IMultiImageAnalyser)
class BaseMultiImageAnalyser(ABCHasTraits):
"""Class that provides analysis instructions for a particular
BaseMultiImage class"""
#: Reference to multi image under analysis
multi_image = Instance(IMultiImage)
database_names = []
[docs] @abstractmethod
def image_analysis(self, *args, **kwargs):
"""Perform analysis on data"""
[docs] @abstractmethod
def create_metrics(self, *args, **kwargs):
"""Create metrics from multi-image components that can be
generated upon end of analysis"""
[docs] @abstractmethod
def save_databases(self, databases):
"""Save databases that have been generated by the analysis
Parameters
----------
databases: list(pd.DataFrame)
List of pandas dataframes generated by the analysis
"""
[docs] @abstractmethod
def load_databases(self):
"""Loads and returns databases that have been generated by
the analysis
Returns
-------
databases: list(pd.DataFrame)
List of pandas dataframes generated by the analysis
"""
@property
def analysis_path(self):
"""Identifies folder that will be used to store analysis
files"""
return os.path.join(
self.multi_image.path,
'-'.join([self.multi_image.name, 'pyfibre', 'analysis'])
)
[docs] def make_directories(self):
"""Creates required directories for analysis"""
if not os.path.exists(self.analysis_path):
os.mkdir(self.analysis_path)