dcnum.feat.feat_background.base

Attributes

mp_spawn

Classes

Background

Base class for background computation

Functions

get_available_background_methods()

Return dictionary of background computation methods

Module Contents

dcnum.feat.feat_background.base.mp_spawn = None
class dcnum.feat.feat_background.base.Background(input_data, output_path, compress=True, num_cpus=None, **kwargs)[source]

Bases: abc.ABC

Base class for background computation

Parameters:
  • input_data (array-like or pathlib.Path) – 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)

  • output_path (pathlib.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.

  • compress (bool) – Whether to compress background data. Set this to False for faster processing.

  • num_cpus (int) – Number of CPUs to use for median computation. Defaults to dcnum.common.cpu_count().

  • kwargs – Additional keyword arguments passed to the subclass.

logger
output_path
kwargs

background keyword arguments

num_cpus = None

number of CPUs used

image_proc

fraction of images that have been processed

hdin = None

HDF5Data instance for input data

h5in = None

input h5py.File

h5out = None

output h5py.File

paths_ref = []

reference paths for logging to the output .rtdc file

image_shape

shape of event images

image_count

number of images in the input data

writer
__enter__()[source]
__exit__(type, value, tb)[source]
abstractmethod check_user_kwargs(**kwargs)[source]

Implement this to check the kwargs during init

get_ppid()[source]

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
classmethod get_ppid_code()[source]
classmethod get_ppid_from_ppkw(kwargs)[source]

Return the PPID based on given keyword arguments for a subclass

static get_ppkw_from_ppid(bg_ppid)[source]

Return keyword arguments for any subclass from a PPID string

get_progress()[source]

Return progress of background computation, float in [0,1]

process()[source]

Perform the background computation

This irreversibly removes/overrides any “image_bg” and “bg_off” features defined in the output file self.h5out.

abstractmethod process_approach()[source]

The actual background computation approach

dcnum.feat.feat_background.base.get_available_background_methods()[source]

Return dictionary of background computation methods