dcnum.feat

Feature computation

Submodules

Classes

QueueEventExtractor

Event extraction from label images

Gate

Gate feature data

Package Contents

class dcnum.feat.QueueEventExtractor(slot_register: dcnum.logic.SlotRegister, pixel_size: float, gate: dcnum.feat.gate.Gate, event_queue: multiprocessing.Queue, extract_kwargs: dict | None = None, logger: logging.Logger | None = None)[source]

Event extraction from label images

This class is used for extracting events from label images. Events are appended to the event_queue for the writer.

Parameters:
  • slot_register (.logic.slot_register.SlotRegister) – Chunk slot register

  • pixel_size – Imaging pixel size

  • gate (.gate.Gate) – Gating rules.

  • event_queue – Queue in which the worker puts the extracted event feature data.

  • extract_kwargs – Keyword arguments for the extraction process. See the keyword-only arguments in QueueEventExtractor.get_events_from_masks().

  • logger – Logger to use

slot_register

Chunk slot register

pixel_size

Imaging pixel size

gate

Gating information

event_queue

queue with event-wise feature dictionaries

logger
extract_kwargs = None

Feature extraction keyword arguments.

get_events_from_masks(masks, chunk_slot, sub_index, *, brightness: bool = True, haralick: bool = True, volume: bool = True)[source]

Get events dictionary, performing event-based gating

get_masks_from_label(label)[source]

Get masks, performing mask-based gating

get_ppid()[source]

Return a unique feature extractor pipeline identifier

The pipeline identifier is universally applicable and must be backwards-compatible (future versions of dcnum will correctly acknowledge the ID).

The feature extractor pipeline ID is defined as:

KEY:KW_APPROACH

Where KEY is e.g. “legacy”, and KW_APPROACH is a list of keyword-only arguments for get_events_from_masks, e.g.:

brightness=True^haralick=True

which may be abbreviated to:

b=1^h=1
classmethod get_ppid_code()[source]
classmethod get_ppid_from_ppkw(kwargs)[source]

Return the pipeline ID for this event extractor

static get_ppkw_from_ppid(extr_ppid)[source]
process_label(index)[source]

Process one label image, extracting masks and features

class dcnum.feat.Gate(data, *, online_gates: bool = False, size_thresh_mask: int | None = None)[source]

Gate feature data

Parameters:
  • data (.hdf5_data.HDF5Data) – dcnum data instance

  • online_gates (bool) – set to True to enable gating with “online” gates stored in the input file; online gates are applied in real-time deformability cytometry before writing data to disk during a measurement

  • size_thresh_mask (int) – Only masks with more pixels than size_thresh_mask are considered to be a valid event; Originally, the bin area min / trig_thresh value defaulted to 200 which is too large; defaults to 10 or the original value in case online_gates is set.

_default_size_thresh_mask = 10

the default value for size_thresh_mask if not given as kwarg

box_gates

box gating (value range for each feature)

kwargs

gating keyword arguments

_extract_online_gates(data)[source]
property features

Sorted list of feature gates defined

get_ppid()[source]

Return a unique gating pipeline identifier

The pipeline identifier is universally applicable and must be backwards-compatible (future versions of dcnum will correctly acknowledge the ID).

The gating pipeline ID is defined as:

KEY:KW_GATE

Where KEY is e.g. “online_gates”, and KW_GATE is the corresponding value, e.g.:

online_gates=True^size_thresh_mask=5
classmethod get_ppid_code()[source]
classmethod get_ppid_from_ppkw(kwargs)[source]

return full pipeline identifier from the given keywords

static get_ppkw_from_ppid(gate_ppid)[source]
gate_event(event)[source]

Return None if the event should not be used, else event

gate_events(events)[source]

Return boolean array with events that should be used

gate_feature(feat: str, data: numbers.Number | numpy.ndarray)[source]

Return boolean indicating whether data value is in box gate

data may be a number or an array. If no box filter is defined for feat, True is always returned. Otherwise, either a boolean or a boolean array is returned, depending on the type of data. Not that np.logical_and can deal with mixed argument types (scalar and array).

gate_mask(mask, mask_sum=None)[source]

Gate the mask, return False if the mask should not be used

Parameters:
  • mask (2d ndarray) – The boolean mask image for the event.

  • mask_sum (int) – The sum of the mask (if not specified, it is computed)