Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
- docs: fix broken logo in README, inconsistent background note and
incomplete gating description, building the docs from the
repository root, and typos in the changelog
- docs: fix typos and broken markup in docstrings and comments
0.31.2
- fix: online gates for `size_x` and `size_y` were ignored (regression in 0.16.6)
- fix: "pipeline:dcnum yield" and "experiment:event count" were set to
Expand Down
1 change: 1 addition & 0 deletions dcnum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base library for deformability cytometry postprocessing

MIT License

Copyright (c) 2023 Paul Müller
Expand Down
3 changes: 2 additions & 1 deletion dcnum/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def __init__(self,
structure:

- ``module``

- ``submod_1``
- ``submod_2``

If ``submod_1`` would like to lazily import ``submod_2``::

submod_2 = LazyLoader("submod_2", sibling==__name__)
submod_2 = LazyLoader("submod_2", sibling=__name__)
action_before_import: Callable
Called before the import.
action_after_import: Callable
Expand Down
2 changes: 1 addition & 1 deletion dcnum/feat/feat_background/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, input_data, output_path, compress=True, num_cpus=None,
----------
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
the "events/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
Expand Down
10 changes: 5 additions & 5 deletions dcnum/feat/feat_background/bg_roll_median.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ def __init__(self, input_data, output_path, kernel_size=100,

1. There is one big shared array ``shared_input`` that contains
the image data for each batch.
2. User specifies batch size (10000) and kernel size (default
is 100)
2. User specifies batch size (default is 10000) and kernel size
(default is 100)
3. There is a second shared array ``shared_output`` that contains
the median values corresponding to the data in ``shared_input``.
4. Background computation is done by copying the input images
from a file into the shared array.
5. The input array is split into and workers compute the
5. The input array is split into pixel slices and workers compute the
rolling median for each point in ``shared_input``.

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
the "events/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
Expand Down Expand Up @@ -332,7 +332,7 @@ def compute_median_for_slice(shared_input, shared_output, kernel_size,
"""
input_size = output_size + kernel_size
# perform median filter on input data
# write median data into output array. Nnote that the values at
# write median data into output array. Note that the values at
# filtered[-kernel_size:] are just junk data, but we keep it to
# make the code simpler.
shared_output[:output_size, job_slice] = ndi.median_filter(
Expand Down
8 changes: 4 additions & 4 deletions dcnum/feat/feat_background/bg_sparse_median.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, input_data, output_path, kernel_size=200,
----------
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
the "events/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
Expand Down Expand Up @@ -180,13 +180,13 @@ def __init__(self, input_data, output_path, kernel_size=200,
self.shared_input = np.ctypeslib.as_array(
self.shared_input_raw).reshape(kernel_size, -1)
"""numpy array reshaped view on ``self.shared_input_raw``.
The First axis enumerating the events
The first axis enumerating the events
"""

self.shared_output = np.ctypeslib.as_array(
self.shared_output_raw).reshape(self.image_shape)
"""numpy array reshaped view on ``self.shared_output_raw``.
The First axis enumerating the events
The first axis enumerating the events
"""

self.worker_counter = mp_spawn.Value("q", 0)
Expand Down Expand Up @@ -351,7 +351,7 @@ def process_approach(self):
# assigned the background image closest in time (they may be
# assigned an image up to a few seconds away). This is intended
# and should not be changed: The background is generally
# consiered stable. Minimal changes in focus don't affect the
# considered stable. Minimal changes in focus don't affect the
# center of the ROI significantly.
bg_idx = np.zeros(self.image_count, dtype=int)
idx0 = 0
Expand Down
2 changes: 1 addition & 1 deletion dcnum/feat/feat_contour/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def contour_single_opencv(mask):
"""Return the contour for a boolean mask image containg *one* blob"""
"""Return the contour for a boolean mask image containing *one* blob"""

cv_im = np.asarray(mask * 255, dtype=np.uint8)
# determine the contour information using opencv
Expand Down
2 changes: 1 addition & 1 deletion dcnum/feat/feat_contour/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def vol_revolve(r, z, point_scale=1.):
V = \frac{h \cdot \pi}{3} \cdot (R^2 + R \cdot r + r^2)

Where :math:`h` is the height of the cone and :math:`r` and
``R`` are the smaller and larger radii of the truncated cone.
:math:`R` are the smaller and larger radii of the truncated cone.

Each line segment of the contour resembles one truncated cone. If
the z-step is positive (counter-clockwise contour), then the
Expand Down
24 changes: 12 additions & 12 deletions dcnum/feat/feat_texture/tex_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ def haralick_texture_features(
avg and ptp):
https://earlglynn.github.io/RNotes/package/EBImage/Haralick-Textural-Features.html

- 1. ``tex_asm``: (1) Angular Second Moment
- 2. ``tex_con``: (2) Contrast
- 3. ``tex_cor``: (3) Correlation
- 4. ``tex_var``: (4) Variance
- 5. ``tex_idm``: (5) Inverse Difference Moment
- 6. ``tex_sva``: (7) Sum Variance
- 7. ``tex_sen``: (8) Sum Entropy
- 8. ``tex_ent``: (9) Entropy
- 9. ``tex_den``: (11) Difference Entropy
- 10. ``tex_f12``: (12) Information Measure of Correlation 1
- 11. ``tex_f13``: (13) Information Measure of Correlation 2
1. ``tex_asm``: (1) Angular Second Moment
2. ``tex_con``: (2) Contrast
3. ``tex_cor``: (3) Correlation
4. ``tex_var``: (4) Variance
5. ``tex_idm``: (5) Inverse Difference Moment
6. ``tex_sva``: (7) Sum Variance
7. ``tex_sen``: (8) Sum Entropy
8. ``tex_ent``: (9) Entropy
9. ``tex_den``: (11) Difference Entropy
10. ``tex_f12``: (12) Information Measure of Correlation 1
11. ``tex_f13``: (13) Information Measure of Correlation 2
"""
# make sure we have a boolean array
mask = np.asarray(mask, dtype=bool)
Expand All @@ -45,7 +45,7 @@ def haralick_texture_features(
# Background-corrected brightness values
image_corr = np.asarray(image, dtype=np.int16) - image_bg
else:
raise ValueError("Please specify either `image_cor` or both "
raise ValueError("Please specify either `image_corr` or both "
"`image` and `image_bg`")

tex_dict = {}
Expand Down
2 changes: 1 addition & 1 deletion dcnum/feat/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def gate_feature(self,
``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
Note that ``np.logical_and`` can deal with mixed argument types
(scalar and array).
"""
bound_lo, bound_up = self.box_gates[feat]
Expand Down
2 changes: 1 addition & 1 deletion dcnum/feat/queue_event_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self,
extract_kwargs:
Keyword arguments for the extraction process. See the
keyword-only arguments in
:func:`QueueEventExtractor.get_events_from_masks`.
:meth:`QueueEventExtractor.get_events_from_masks`.
logger:
Logger to use
"""
Expand Down
12 changes: 6 additions & 6 deletions dcnum/logic/chunk_slot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def acquire_task_lock(self,
"""Acquire the lock for performing a task

Return the start and stop indices for which the lock was acquired.
If no lock could be acquired, return `(0, 0)`. The returned
If no lock could be acquired, return ``(0, 0)``. The returned
indices might not match the input batch size: Locks for
contiguous indices are returned based on availability.
"""
Expand All @@ -184,7 +184,7 @@ def acquire_task_lock(self,
# array that monitors the progress of the current state
progress_array = np.ctypeslib.as_array(self._task_progress_array)
with self._task_reserve_lock:
# combined array with frames are completed or are in use
# combined array with frames that are completed or in use
used_array = np.logical_or(reserve_array, progress_array)
if self._state.value != req_state:
# wrong state
Expand Down Expand Up @@ -223,7 +223,7 @@ def release_task_lock(self, start, stop, task_done=True):

Releasing the task lock is done after completing the
task for which a lock was required. This method also updates the
progress (see `get_progress`) for the current task. Only release
progress (see ``get_progress``) for the current task. Only release
the task lock if you acquired it before.
"""
if task_done:
Expand All @@ -238,9 +238,9 @@ def get_progress(self):
"""Return the progress of the current task

Return a value between 0 and 1. If processing is done in batches
(`batch_size` set in `acquire_task_lock`), this returns the
fraction of frames for which `release_task_lock` was called
with `task_done=True`.
(``batch_size`` set in ``acquire_task_lock``), this returns the
fraction of frames for which ``release_task_lock`` was called
with ``task_done=True``.
"""
progress_array = np.ctypeslib.as_array(self._task_progress_array)
return float(np.sum(progress_array)) / self.length
12 changes: 6 additions & 6 deletions dcnum/logic/ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def run_pipeline(self):
def task_background(self):
"""Perform background computation task

This populates the file `self.path_temp_in` with the 'image_bg'
This populates the file ``self.path_temp_in`` with the 'image_bg'
feature.
"""
self.logger.info("Starting background computation")
Expand Down Expand Up @@ -695,7 +695,7 @@ def task_enforce_basin_strategy(self):
# We achieve this by keeping a specific order and only copying
# those features that we don't already have in the output file.
feats_raw = [
# background data from the temporary input image
# background data from the temporary input file
[self.dtin.h5, ["bg_off"], "critical"],
[self.draw.h5, self.draw.features_scalar_frame, "optional"],
[self.draw.h5, ["image", "bg_off"], "optional"],
Expand Down Expand Up @@ -919,10 +919,10 @@ def task_segment_extract(self):
w_dcs = UniversalWorker.get_worker_dedications(self.job, num_universal)

# The number of ChunkSlots defines how well workers can operate in
# parallel. This should be higher than the number states a ChunkSlot
# can have to prevent workers from waiting on each other. Seven slots
# results in a shared memory usage of roughly 1GB for a standard
# blood measurement (image chunks of (1000, 80, 32).
# parallel. This should be higher than the number of states a
# ChunkSlot can have to prevent workers from waiting on each other.
# Seven slots result in a shared memory usage of roughly 1GB for a
# standard blood measurement (image chunks of (1000, 80, 32)).
if self.job["debug"]:
num_slots = 1
else:
Expand Down
10 changes: 5 additions & 5 deletions dcnum/logic/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __setstate__(self, state):
self.kwargs.update(copy.deepcopy(state))

def assert_pp_codes(self):
"""Sanity check of `self.kwargs`"""
"""Sanity check of ``self.kwargs``"""
# PPID classes with only one option
for cls, key in [
(HDF5Data, "data_code"),
Expand Down Expand Up @@ -253,15 +253,15 @@ def validate(self):

Returns
-------
True:
for testing convenience
bool
Always True (for testing convenience)

Raises
------
dcnum.segm.SegmenterNotApplicableError:
dcnum.segm.SegmenterNotApplicableError
the segmenter is incompatible with the input path
"""
# Check segmenter applicability applicability
# Check segmenter applicability
seg_cls = self.get_segmenter_class()
with HDF5Data(self.kwargs["path_in"]) as hd:
seg_cls.validate_applicability(
Expand Down
12 changes: 6 additions & 6 deletions dcnum/logic/slot_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def write_queue_size(self):

A large number indicates a slow writer which can be
a result of a slow hard disk or a slow CPU (since
is used compression). Used for preventing
compression is used). Used for preventing
OOM events by stalling data processing when the writer is slow.
"""
return self.get_counter_value("write_queue_size")
Expand Down Expand Up @@ -306,7 +306,7 @@ def increment_counter_value(self,
increment:
By how much the counter should be incremented
timeout:
Timeout for acquiring a lock (if `lock` is not set)
Timeout for acquiring a lock (if ``lock`` is not set)
lock:
A locked lock for the given counter. The lock will not be
released after incrementing the value.
Expand Down Expand Up @@ -367,7 +367,7 @@ def reserve_slot_for_task(self,
state_warden
Context manager that enforces setting the next state or
None if no chunk slot could be reserved.
Usage:
Usage::

if state_warden is not None:
with state_warden as (chunk_slot, batch_range):
Expand All @@ -376,7 +376,7 @@ def reserve_slot_for_task(self,
stop_index=batch_range[1]
)

The `batch_range` indices are defined by the `batch_size`
The ``batch_range`` indices are defined by the ``batch_size``
parameter.

This context manager will automatically set the slot
Expand Down Expand Up @@ -641,7 +641,7 @@ def task_label_masks(self,
Returns
-------
did_something : bool
Whether masks where converted to labels
Whether masks were converted to labels
"""
did_something = False
cs = self.find_slot(state="m")
Expand Down Expand Up @@ -688,7 +688,7 @@ def task_process_labels(self,

logger = logger or logging.getLogger(__name__)

# Comput labels from this ChunkSlot
# Process labels from this ChunkSlot
batch_size = 100
if cs is not None and cs.state == "l":
while True:
Expand Down
2 changes: 1 addition & 1 deletion dcnum/logic/universal_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def __init__(self, *args, **kwargs):

def start(self):
"""Start the process with single-threaded library settings"""
# Set all relevant os environment variables such libraries in the
# Set all relevant os environment variables such that libraries in the
# new process only use single-threaded computation.
with RequestSingleThreaded():
mp_spawn.Process.start(self)
2 changes: 1 addition & 1 deletion dcnum/meta/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def register_search_path(topic: str,

Search paths are a global solution for organizing the locations
of resources that are part of an analysis pipeline. For instance,
if the location of such a file that depends on where your pipeline is
if the location of such a file depends on where your pipeline is
running, you can register multiple search paths and the file will
be found using :func:`find_file`.
"""
Expand Down
2 changes: 1 addition & 1 deletion dcnum/read/detect_flicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def detect_flickering(image_data: np.ndarray | HDF5Data,
height of the ROI in pixels for which to search for flickering;
the entire width of the image is used
brightness_threshold: float
brightness difference between individual ROIs median and median
brightness difference between an individual ROI's median and median
of all ROI medians leading to a positive flickering event
count_threshold: int
minimum number of flickering events that would lead to a positive
Expand Down
2 changes: 1 addition & 1 deletion dcnum/read/hdf5_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def concatenated_hdf5_data(paths: list[pathlib.Path],
If `None`, then the dataset is created in memory. If `True`
(default), create a file on disk. If a pathlib.Path is specified,
the dataset is written to that file. Note that datasets in memory
are likely not pickable (so don't use them for multiprocessing).
are likely not ``pickle``able (so don't use them for multiprocessing).
compute_frame:
Whether to compute the "events/frame" feature, taking the frame
data from the input files and properly incrementing them along
Expand Down
Loading
Loading