dcnum.feat.feat_background.base =============================== .. py:module:: dcnum.feat.feat_background.base Attributes ---------- .. autoapisummary:: dcnum.feat.feat_background.base.mp_spawn Classes ------- .. autoapisummary:: dcnum.feat.feat_background.base.Background Functions --------- .. autoapisummary:: dcnum.feat.feat_background.base.get_available_background_methods Module Contents --------------- .. py:data:: mp_spawn :value: None .. py:class:: Background(input_data, output_path, compress=True, num_cpus=None, **kwargs) Bases: :py:obj:`abc.ABC` Base class for background computation :param input_data: The input data can be either a path to an HDF5 file with the "evtens/image" dataset or an array-like object that behaves like an image stack (first axis enumerates events) :type input_data: array-like or pathlib.Path :param output_path: Path to the output file. If `input_data` is a path, you can set `output_path` to the same path to write directly to the input file. The data are written in the "events/image_bg" dataset in the output file. :type output_path: pathlib.Path :param compress: Whether to compress background data. Set this to False for faster processing. :type compress: bool :param num_cpus: Number of CPUs to use for median computation. Defaults to `dcnum.common.cpu_count()`. :type num_cpus: int :param kwargs: Additional keyword arguments passed to the subclass. .. py:attribute:: logger .. py:attribute:: output_path .. py:attribute:: kwargs background keyword arguments .. py:attribute:: num_cpus :value: None number of CPUs used .. py:attribute:: image_proc fraction of images that have been processed .. py:attribute:: hdin :value: None HDF5Data instance for input data .. py:attribute:: h5in :value: None input h5py.File .. py:attribute:: h5out :value: None output h5py.File .. py:attribute:: paths_ref :value: [] reference paths for logging to the output .rtdc file .. py:attribute:: image_shape shape of event images .. py:attribute:: image_count number of images in the input data .. py:attribute:: writer .. py:method:: __enter__() .. py:method:: __exit__(type, value, tb) .. py:method:: check_user_kwargs(**kwargs) :abstractmethod: Implement this to check the kwargs during init .. py:method:: get_ppid() Return a unique background pipeline identifier The pipeline identifier is universally applicable and must be backwards-compatible (future versions of dcnum will correctly acknowledge the ID). The segmenter pipeline ID is defined as:: KEY:KW_BACKGROUND Where KEY is e.g. "sparsemed" or "rollmed", and KW_BACKGROUND is a list of keyword arguments for `check_user_kwargs`, e.g.:: kernel_size=100^batch_size=10000 which may be abbreviated to:: k=100^b=10000 .. py:method:: get_ppid_code() :classmethod: .. py:method:: get_ppid_from_ppkw(kwargs) :classmethod: Return the PPID based on given keyword arguments for a subclass .. py:method:: get_ppkw_from_ppid(bg_ppid) :staticmethod: Return keyword arguments for any subclass from a PPID string .. py:method:: get_progress() Return progress of background computation, float in [0,1] .. py:method:: process() Perform the background computation This irreversibly removes/overrides any "image_bg" and "bg_off" features defined in the output file `self.h5out`. .. py:method:: process_approach() :abstractmethod: The actual background computation approach .. py:function:: get_available_background_methods() Return dictionary of background computation methods