Skip to content

Commit 89e5132

Browse files
committed
Add more info in the new synapse detection pipeline
1 parent ad478ef commit 89e5132

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

biapy/config/config.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ def __init__(self, job_dir: str, job_identifier: str):
7272
# - 'F' stands for 'Flow' where, for each instance, contains the distance values to its center of mass for each dimension.
7373
#
7474
#### For "synapse" type of instances ####
75-
# Possible options: 'BF'. This variable defines the channels to be used to represent synapse instances based on the input
75+
# Possible options: 'B' and 'BF' (still experimental). This variable defines the channels to be used to represent synapse instances based on the input
7676
# synapse sites. The meaning of each letter is a follows:
77-
# - 'B' stands for 'Binary mask', it is a binary representation of each postsynaptic site
78-
# - 'F' stands for 'Flow' and contains the distance values to the corresponding presynaptic site (of each postsynaptic
79-
# site) for each dimension.
77+
# * In 'B', the first and second channels represent the pre and post points as 3D points, respectively.
78+
#
79+
# * In 'BF':
80+
# - 'B' stands for 'Binary mask', it is a binary representation of each postsynaptic site
81+
# - 'F' stands for 'Flow' and contains the distance values to the corresponding presynaptic site (of each postsynaptic
82+
# site) for each dimension.¡
8083
_C.PROBLEM.INSTANCE_SEG.DATA_CHANNELS = "BC"
8184
# Whether to mask the distance channel to only calculate the loss in those regions where the binary mask
8285
# defined by B channel is present
@@ -145,10 +148,10 @@ def __init__(self, job_dir: str, job_identifier: str):
145148
# Options available:
146149
# * 'auto' to decide the threshold to be applied by measuring it with Otsu
147150
# * 'manual' to set a fixed threshold defined by 'PROBLEM.INSTANCE_SEG.SYNAPSES.MIN_TH_TO_BE_PEAK'
148-
# * 'relative_by_patch' to use 'PROBLEM.INSTANCE_SEG.SYNAPSES.MIN_TH_TO_BE_PEAK' but relative to the maximum value in the predicted data.
149-
# More info in https://scikit-image.org/docs/0.25.x/api/skimage.feature.html#skimage.feature.peak_local_max and
151+
# * 'relative_by_patch' to use 'PROBLEM.INSTANCE_SEG.SYNAPSES.MIN_TH_TO_BE_PEAK' but relative to the maximum value in the predicted patch
152+
# data. More info in https://scikit-image.org/docs/0.25.x/api/skimage.feature.html#skimage.feature.peak_local_max and
150153
# https://scikit-image.org/docs/0.23.x/api/skimage.feature.html#skimage.feature.blob_log (see 'threshold_rel' argument description)
151-
# * 'relative' to use 'PROBLEM.INSTANCE_SEG.SYNAPSES.MIN_TH_TO_BE_PEAK' but relative to the maximum value in the predicted data.
154+
# * 'relative' to use 'PROBLEM.INSTANCE_SEG.SYNAPSES.MIN_TH_TO_BE_PEAK' but relative to the maximum value in the whole predicted data.
152155
# More info in https://scikit-image.org/docs/0.25.x/api/skimage.feature.html#skimage.feature.peak_local_max and
153156
# https://scikit-image.org/docs/0.23.x/api/skimage.feature.html#skimage.feature.blob_log (see 'threshold_rel' argument description)
154157
_C.PROBLEM.INSTANCE_SEG.SYNAPSES.TH_TYPE = "auto"

biapy/data/post_processing/post_processing.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ def erode_seed_and_foreground():
391391
)
392392
return segm
393393

394-
def create_synapses(data: NDArray,
394+
def create_synapses(
395+
data: NDArray,
395396
channels: str,
396397
point_creation_func: str = "peak_local_max",
397398
min_th_to_be_peak: List[float] = [0.2],
@@ -403,19 +404,49 @@ def create_synapses(data: NDArray,
403404
relative_th_value: bool = False,
404405
) -> Tuple[NDArray, Dict]:
405406
"""
406-
Convert binary foreground probability maps and instance contours to instance masks via watershed segmentation
407-
algorithm.
408-
409-
Implementation based on `PyTorch Connectomics' process.py
410-
<https://github.com/zudi-lin/pytorch_connectomics/blob/master/connectomics/utils/process.py>`_.
407+
Creates synapses pre/post points from the given ``data``.
411408
409+
Find more info regarding ``min_distance``, ``min_sigma`` and ``exclude_border`` arguments in
410+
`peak_local_max <https://scikit-image.org/docs/0.25.x/api/skimage.feature.html#skimage.feature.peak_local_max>`__
411+
and `blob_log <https://scikit-image.org/docs/0.25.x/api/skimage.feature.html#skimage.feature.blob_log>`__
412+
functions.
413+
412414
Parameters
413415
----------
414416
data : 4D Numpy array
415417
Binary foreground labels and contours data to apply watershed into. E.g. ``(397, 1450, 2000, 2)``.
416418
417419
channels : str
418420
Channel type used. Possible options: ``A``, ``C``, ``BC``, ``BCM``, ``BCD``, ``BCDv2``, ``Dv2`` and ``BDv2``.
421+
422+
point_creation_func : str, optional
423+
Function to be used in the pre/post point creation. Options: ["peak_local_max", "blob_log"]
424+
425+
min_th_to_be_peak : List of float, optional
426+
Minimum values for each channel in ``data`` to be used as the minimum when creating the points.
427+
428+
min_distance : int, optional
429+
The minimal allowed distance separating peaks. To find the maximum number of peaks, use ``min_distance=1``.
430+
431+
min_sigma : int, optional
432+
The minimum standard deviation for Gaussian kernel. Keep this low to detect smaller blobs. The standard deviations
433+
of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for
434+
all axes.
435+
436+
max_sigma : int, optional
437+
The maximum standard deviation for Gaussian kernel. Keep this high to detect larger blobs. The standard deviations
438+
of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for
439+
all axes.
440+
441+
num_sigma : int, optional
442+
The number of intermediate values of standard deviations to consider between ``min_sigma`` and ``max_sigma``.
443+
444+
exclude_border: bool, optional
445+
To exclude border-pixels of the border of the image.
446+
447+
relative_th_value : bool, optional
448+
To use ``min_th_to_be_peak`` as a relative threshold to the maximum value, i.e. ``threshold_rel`` is set instead of
449+
``threshold_abs`` in the ``peak_local_max`` or ``blob_log`` call.
419450
"""
420451
assert channels in [
421452
"B",

0 commit comments

Comments
 (0)