Skip to content

Commit

Permalink
Merge pull request #139 from BBQuercus/release_0.1.3
Browse files Browse the repository at this point in the history
Release 0.1.3
  • Loading branch information
BBQuercus authored Mar 17, 2022
2 parents d99df1a + 26d9b26 commit 7a425f5
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.2
current_version = 0.1.3
commit = False
tag = True

Expand Down
6 changes: 3 additions & 3 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: "deepblink"
version: 0.1.2
version: 0.1.3
source:
path: ..

Expand All @@ -13,11 +13,11 @@ build:

requirements:
build:
- python>=3.6,<3.8
- python>=3.6,<3.9
- pip
- setuptools
run:
- python>=3.6,<3.8
- python>=3.6,<3.9
- matplotlib>=3.0.0
- requests>=2.0.0
- numpy>=1.17.0
Expand Down
2 changes: 1 addition & 1 deletion deepblink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- util: Basic utility functions not fitting into a category.
"""

__version__ = "0.1.2"
__version__ = "0.1.3"

from . import augment
from . import cli
Expand Down
8 changes: 7 additions & 1 deletion deepblink/cli/_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def _parse_args_visualize(
)
group2 = parser.add_argument_group(f"{Color.optional}Optional{Color.end}")
group2.add_argument(
"-ds",
"--dataset",
type=FileType(["npz"]),
default=None,
Expand All @@ -436,6 +437,7 @@ def _parse_args_visualize(
),
)
group2.add_argument(
"-s",
"--subset",
type=str,
default="train",
Expand All @@ -446,6 +448,7 @@ def _parse_args_visualize(
),
)
group2.add_argument(
"-idx",
"--index",
type=int,
default=None,
Expand All @@ -455,6 +458,7 @@ def _parse_args_visualize(
),
)
group2.add_argument(
"-i",
"--image",
type=FileType(EXTENSIONS),
default=None,
Expand All @@ -465,12 +469,14 @@ def _parse_args_visualize(
),
)
group2.add_argument(
"-p",
"--prediction",
type=FileType(["csv"]),
default=None,
help=(
"Prediction csv file (output from deepBlink predict) to visualize. "
"[default: None]"
"Will try to find the image's corresponding csv file if not given. "
"[default: image.csv]"
),
)
_add_utils(parser)
3 changes: 1 addition & 2 deletions deepblink/cli/_parseutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class Color:
end = "\033[0m" if ispos else ""


# TODO find a simpler and safer solution
def _add_utils(parser: argparse.ArgumentParser):
"""A very hacky way of trying to move this group to the bottom of help text."""
group = parser.add_argument_group(f"{Color.general}General utilities{Color.end}")
Expand All @@ -173,7 +172,7 @@ def _add_utils(parser: argparse.ArgumentParser):
"-V",
"--version",
action="version",
version="%(prog)s 0.1.2",
version="%(prog)s 0.1.3",
help="Show %(prog)s's version number.",
)
group.add_argument(
Expand Down
2 changes: 0 additions & 2 deletions deepblink/cli/_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ def path_output(self) -> str:
outpath = self.path_input
return outpath

# TODO solve double definition of replace_chars here and in ShapeType
# TODO solve mypy return type bug
@property
def shape(self) -> List[str]:
"""Resolve input shape."""
Expand Down
7 changes: 3 additions & 4 deletions deepblink/cli/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ def get_pixel_size(
return (pixel_size, pixel_size)

# Try to predict pixel size
size = (1.0, 1.0)
try:
size = predict_pixel_size(image)
logger.debug(f"using predicted pixel size {size}")
return size
except (ValueError, KeyError, IndexError) as e:
logger.warning(
f"\U000026A0 {e} encountered. Pixel size for image {image} could not be predicted."
)

logger.debug(f"defaulting pixel size to {size}")
return (1.0, 1.0)
logger.debug(f"defaulting pixel size to {size}")
return size
7 changes: 6 additions & 1 deletion deepblink/cli/_visualize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""CLI submodule for visualization."""

import logging
import os
import random

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -42,7 +43,7 @@ def __call__(self):
if self.dataset is not None:
self.logger.info("\U0001F5BC Visualizing dataset provided.")
self.visualize_dataset()
elif self.image is not None and self.prediction is not None:
elif self.image is not None:
self.logger.info("\U0001F5BC visualizing image provided.")
self.visualize_image()
else:
Expand Down Expand Up @@ -91,6 +92,10 @@ def visualize_image(self):
image = load_image(self.image)
if image.ndim != 2:
self.logger.error("invalid image dimension")

if self.prediction is None:
self.prediction = f"{os.path.splitext(self.image)[0]}.csv"
self.logger.debug("using same name prediction file")
df = load_prediction(self.prediction)
coords = df[["x [px]", "y [px]"]].values

Expand Down
2 changes: 2 additions & 0 deletions deepblink/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def load_model(fname: Union[str, "os.PathLike[str]"]) -> tf.keras.models.Model:

def load_prediction(fname: Union[str, "os.PathLike[str]"]) -> pd.DataFrame:
"""Import a prediction file (output from deepBlink predict) as pandas dataframe."""
if not os.path.isfile(fname):
raise ValueError(f"File must exist - '{fname}' does not.")
df = pd.read_csv(fname)
if any([c in df.columns for c in ["x [µm]", "y [µm]"]]):
raise ValueError(
Expand Down
1 change: 1 addition & 0 deletions deepblink/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def predict_shape(shape: tuple) -> str:
return order


# TODO account for resolution unit (µm / cm)
def predict_pixel_size(fname: Union[str, "os.PathLike[str]"]) -> Tuple[float, float]:
"""Predict the pixel size based on tifffile metadata."""
if not os.path.splitext(fname)[1] == ".tif":
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
year = "2020"
author = "Bastian Eichenberger"
copyright = f"{year}, {author}"
version = release = "0.1.2"
version = release = "0.1.3"

pygments_style = "trac"
templates_path = ["."]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
setup(
# Description
name="deepblink",
version="0.1.2",
version="0.1.3",
license="MIT",
description="Threshold independent detection and localization of diffraction-limited spots.",
long_description_content_type="text/plain",
Expand Down

0 comments on commit 7a425f5

Please sign in to comment.