Skip to content

Commit

Permalink
add test for stack.utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Henley13 committed May 5, 2020
1 parent ab94c2b commit c5ce909
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 66 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions bigfish/stack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-

"""
The bigfish.stack module includes function to read data, preprocess them and
The bigfish.stack module includes functions to read data, preprocess them and
build stack of images.
"""

from .utils import (check_array, check_df, check_recipe, check_parameter,
check_range_value,
get_offset_value, get_eps_float32)
get_margin_value, get_eps_float32)
from .io import (read_image, read_pickle, read_cell_json, read_rna_json,
read_dv,
save_image)
Expand Down Expand Up @@ -42,7 +42,7 @@


_utils = ["check_array", "check_df", "check_recipe", "check_parameter",
"check_range_value", "get_offset_value", "get_eps_float32"]
"check_range_value", "get_margin_value", "get_eps_float32"]

_io = ["read_image", "read_pickle", "read_cell_json", "read_rna_json",
"read_dv",
Expand Down
6 changes: 3 additions & 3 deletions bigfish/stack/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from scipy import ndimage as ndi

from .utils import check_array, check_parameter, get_offset_value
from .utils import check_array, check_parameter, get_margin_value

from skimage.measure import regionprops, find_contours
from skimage.draw import polygon_perimeter
Expand Down Expand Up @@ -473,7 +473,7 @@ def center_mask_coord(main, others=None):
dtype=[np.uint8, np.uint16, np.int64, bool])

# initialize parameter
marge = get_offset_value()
marge = get_margin_value()

# compute by how much we need to move the main object to center it
if main.shape[1] == 2:
Expand Down Expand Up @@ -691,7 +691,7 @@ def from_coord_to_frame(coord, external_coord=True):
check_parameter(external_coord=bool)

# initialize marge
marge = get_offset_value()
marge = get_margin_value()

# from 2D coordinates boundaries to binary boundaries
if external_coord:
Expand Down
10 changes: 5 additions & 5 deletions bigfish/stack/preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas as pd
from scipy import ndimage as ndi

from .utils import get_offset_value
from .utils import get_margin_value
from .augmentation import augment
from .preprocess import cast_img_float32
from .filter import mean_filter
Expand Down Expand Up @@ -272,8 +272,8 @@ def build_image(data, id_cell, image_shape=None, coord_refinement=True,

# build matrices
if image_shape is None:
max_x = cyt_coord[:, 0].max() + get_offset_value()
max_y = cyt_coord[:, 1].max() + get_offset_value()
max_x = cyt_coord[:, 0].max() + get_margin_value()
max_y = cyt_coord[:, 1].max() + get_margin_value()
image_shape = (max_x, max_y)
rna = np.zeros(image_shape, dtype=np.float32)
rna[rna_coord[:, 0], rna_coord[:, 1]] = 1.0
Expand Down Expand Up @@ -350,8 +350,8 @@ def _build_rna(data, id_cell, output_shape=None):
# get current shape
cyt_coord = data.loc[id_cell, "pos_cell"]
cyt_coord = np.array(cyt_coord, dtype=np.int64)
max_x = cyt_coord[:, 0].max() + get_offset_value()
max_y = cyt_coord[:, 1].max() + get_offset_value()
max_x = cyt_coord[:, 0].max() + get_margin_value()
max_y = cyt_coord[:, 1].max() + get_margin_value()
input_shape = (max_x, max_y)

if output_shape is not None:
Expand Down
Loading

0 comments on commit c5ce909

Please sign in to comment.