Skip to content

Commit

Permalink
refactor stack and detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Henley13 committed May 5, 2020
1 parent 077453f commit 3091a1c
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 23 deletions.
82 changes: 59 additions & 23 deletions bigfish/detection/__init__.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,68 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
The bigfish.detection module includes function to detect RNA spot in 2-d and
3-d.
"""

from .spot_detection import (
log_lm, local_maximum_detection, spots_thresholding, compute_snr,
from_threshold_to_snr, get_sigma, log_cc, get_cc)
from .cluster_decomposition import (
gaussian_3d, precompute_erf, build_reference_spot_3d,
initialize_spot_parameter_3d, objective_function, fit_gaussian_3d,
simulate_fitted_gaussian_3d, fit_gaussian_mixture, filter_clusters,
decompose_clusters, run_decomposition)
from .foci_detection import (
convert_spot_coordinates, cluster_spots, extract_foci)


_spots = ["log_lm", "local_maximum_detection", "spots_thresholding",
"compute_snr", "from_threshold_to_snr", "get_sigma", "log_cc",
"get_cc", "filter_cc"]

_clusters = ["gaussian_3d", "precompute_erf", "build_reference_spot_3d",
"initialize_spot_parameter_3d", "objective_function",
"fit_gaussian_3d", "simulate_fitted_gaussian_3d",
"fit_gaussian_mixture", "filter_clusters", "decompose_clusters",
"run_decomposition"]

_foci = ["convert_spot_coordinates", "cluster_spots", "extract_foci"]
from .spot_detection import log_lm
from .spot_detection import local_maximum_detection
from .spot_detection import spots_thresholding
from .spot_detection import compute_snr
from .spot_detection import from_threshold_to_snr
from .spot_detection import get_sigma
from .spot_detection import log_cc
from .spot_detection import get_cc
from .spot_detection import log_lm
from .spot_detection import log_lm
from .spot_detection import log_lm

from .cluster_decomposition import gaussian_3d
from .cluster_decomposition import precompute_erf
from .cluster_decomposition import build_reference_spot_3d
from .cluster_decomposition import initialize_spot_parameter_3d
from .cluster_decomposition import objective_function
from .cluster_decomposition import fit_gaussian_3d
from .cluster_decomposition import simulate_fitted_gaussian_3d
from .cluster_decomposition import fit_gaussian_mixture
from .cluster_decomposition import filter_clusters
from .cluster_decomposition import decompose_clusters
from .cluster_decomposition import run_decomposition

from .foci_detection import convert_spot_coordinates
from .foci_detection import cluster_spots
from .foci_detection import extract_foci


_spots = [
"log_lm",
"local_maximum_detection",
"spots_thresholding",
"compute_snr",
"from_threshold_to_snr",
"get_sigma",
"log_cc",
"get_cc",
"filter_cc"]

_clusters = [
"gaussian_3d",
"precompute_erf",
"build_reference_spot_3d",
"initialize_spot_parameter_3d",
"objective_function",
"fit_gaussian_3d",
"simulate_fitted_gaussian_3d",
"fit_gaussian_mixture",
"filter_clusters",
"decompose_clusters",
"run_decomposition"]

_foci = [
"convert_spot_coordinates",
"cluster_spots",
"extract_foci"]

__all__ = _spots + _clusters + _foci
2 changes: 2 additions & 0 deletions bigfish/detection/cluster_decomposition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
Functions to fit gaussian functions to the detected RNA spots, especially in
Expand Down
2 changes: 2 additions & 0 deletions bigfish/detection/foci_detection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
Functions to fit gaussian functions to the detected RNA spots, especially in
Expand Down
4 changes: 4 additions & 0 deletions bigfish/detection/spot_detection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
Class and functions to detect RNA spots in 2-d and 3-d.
Expand All @@ -15,6 +17,7 @@
# TODO complete documentation methods
# TODO add sanity check functions
# TODO improve documentation with optional output
# TODO add function to calibrate psf

# ### LoG detection ###

Expand Down Expand Up @@ -96,6 +99,7 @@ def local_maximum_detection(image, minimum_distance):
stack.check_parameter(minimum_distance=(float, int))

# compute the kernel size (centered around our pixel because it is uneven)
# TODO use tuple with a different size for each axis
kernel_size = int(2 * minimum_distance + 1)

# apply maximum filter to the original image
Expand Down
Empty file.
17 changes: 17 additions & 0 deletions bigfish/detection/tests/test_spot_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
Unitary tests for bigfish.stack.filter submodule.
"""

import pytest

import numpy as np
import bigfish.stack as stack

from bigfish.stack.filter import _define_kernel

from numpy.testing import assert_array_equal
from numpy.testing import assert_allclose
2 changes: 2 additions & 0 deletions bigfish/stack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
The bigfish.stack module includes functions to read data, preprocess them and
Expand Down
2 changes: 2 additions & 0 deletions bigfish/stack/augmentation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
Functions to augment the data (images or coordinates).
Expand Down
2 changes: 2 additions & 0 deletions bigfish/stack/filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""Filter functions."""

Expand Down
2 changes: 2 additions & 0 deletions bigfish/stack/illumination.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""Illumination correction functions."""

Expand Down
2 changes: 2 additions & 0 deletions bigfish/stack/postprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""
Functions used to format and clean any intermediate results loaded in or
Expand Down
2 changes: 2 additions & 0 deletions bigfish/stack/projection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Author: Arthur Imbert <[email protected]>
# License: BSD 3 clause

"""2-d projection functions."""

Expand Down

0 comments on commit 3091a1c

Please sign in to comment.