Skip to content

Commit

Permalink
Comply with flake8 + testing debug
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximLippeveld committed Jan 14, 2022
1 parent d5d1567 commit b98f79e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/misc/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
x = df["feat_area_combined"]
y = df["feat_eccentricity_combined"]
plt.scatter(x, y, s=1, alpha=0.5)
plt.savefig("test.png")
plt.savefig("test.png")
6 changes: 3 additions & 3 deletions src/scip/features/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def _row(pixels, maximum_pixel_value, num_features):
)

out = numpy.full(shape=(num_features,), fill_value=None, dtype=float)
step = len(distances)*2
step = len(distances) * 2
for i, prop in enumerate(graycoprop_names):
v = graycoprops(glcm, prop=prop)
out[i*step:i*step+len(distances)] = v.mean(axis=1)
out[i*step+len(distances):(i+1)*step] = v.std(axis=1)
out[i * step:i * step + len(distances)] = v.mean(axis=1)
out[i * step + len(distances):(i + 1) * step] = v.std(axis=1)

s = sobel(pixels)
out[-4] = s.mean()
Expand Down
2 changes: 1 addition & 1 deletion src/scip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def channel_boundaries(quantiles, *, config, output):
pandas.DataFrame(data=data, index=index).to_csv(str(output / "channel_boundaries.csv"))


def main(
def main( # noqa: C901
*,
paths,
output,
Expand Down
9 changes: 4 additions & 5 deletions src/scip/masking/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from skimage.morphology import (
closing, disk, remove_small_holes, remove_small_objects, label)
from skimage.filters import threshold_otsu, sobel, gaussian
from skimage.segmentation import expand_labels
from scipy.stats import normaltest
from scip.utils.util import check

Expand All @@ -35,9 +34,9 @@ def get_mask(el, main, main_channel, smooth):
x = gaussian(x, sigma=smooth)
x = sobel(x)
x = closing(x, footprint=disk(2))
x = gaussian(x, sigma=smooth*2)
x = gaussian(x, sigma=smooth * 2)
x = threshold_otsu(x) < x
x = remove_small_holes(x, area_threshold=(x.shape[0]*x.shape[1])/4)
x = remove_small_holes(x, area_threshold=(x.shape[0] * x.shape[1]) / 4)
x = remove_small_objects(x, min_size=20)
x = label(x)
mask[main_channel], cc = x > 0, x.max()
Expand All @@ -56,9 +55,9 @@ def get_mask(el, main, main_channel, smooth):
if (normaltest(x.ravel()).pvalue < 0.05):
x = gaussian(x, sigma=smooth)
x = sobel(x)
x = gaussian(x, sigma=smooth*2)
x = gaussian(x, sigma=smooth * 2)
x = threshold_otsu(x) < x
x = remove_small_holes(x, area_threshold=(x.shape[0]*x.shape[1])/4)
x = remove_small_holes(x, area_threshold=(x.shape[0] * x.shape[1]) / 4)
x = remove_small_objects(x, min_size=20)
x = label(x)
mask[dim], cc = x > 0, x.max()
Expand Down
1 change: 1 addition & 0 deletions src/scip/masking/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def _regions_touching(arr):
else:
return idx[counts > limit]


@check
def remove_regions_touching_border(p, bbox_channel_index):
mask = numpy.empty_like(p["mask"])
Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import pytest
import numpy
from dask.distributed import (Client, LocalCluster)
import dask.bag

from dask.distributed import (Client, LocalCluster)
from scip.utils import util


Expand Down
2 changes: 1 addition & 1 deletion test/masking/test_bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_bounding_box(images_folder, cluster):
images_folder, channels=[0, 1, 2], partition_size=2)
bag = watershed.create_masks_on_bag(bag, noisy_channels=[0])
bag = bag.filter(partial(util.mask_predicate, bbox_channel_index=0))
bag = bag.map_partitions(util.bounding_box_partition, bbox_channel_index=0)
bag = bag.map_partitions(util.bounding_box_partition)

bag = bag.compute()

Expand Down

0 comments on commit b98f79e

Please sign in to comment.