Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deeptrack/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def update_properties(self, image, number_of_updates, **kwargs):
for prop in image.properties:
if "position" in prop:
position = np.array(prop["position"])
position[..., 0] = image.shape[1] - position[..., 0]
position[..., 0] = image.shape[0] - position[..., 0]
prop["position"] = position


Expand Down
5 changes: 3 additions & 2 deletions deeptrack/noises.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def __init__(

def get(self, image, snr, background, **kwargs):
image[image < 0] = 0

peak = np.abs(np.max(image) - background)
immax = np.max(image)
peak = np.abs(immax - background)

rescale = snr ** 2 / peak ** 2
rescale = np.clip(rescale, 1e-10, np.inf)
noisy_image = Image(np.random.poisson(image * rescale) / rescale)
noisy_image.properties = image.properties
return noisy_image
16 changes: 9 additions & 7 deletions deeptrack/optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .image import Image, pad_image_to_fft
from .types import ArrayLike, PropertyLike

import scipy.ndimage
from scipy.ndimage import convolve


Expand Down Expand Up @@ -555,7 +556,7 @@ def get(self, illuminated_volume, limits, fields, **kwargs):

K = 2 * np.pi / kwargs["wavelength"]

field_z = [_get_position(field, return_z=True)[-1] for field in fields]
field_z = [field.get_property("z") for field in fields]
field_offsets = [field.get_property("offset_z", default=0) for field in fields]

z = z_limits[1]
Expand Down Expand Up @@ -687,12 +688,13 @@ def _get_position(image, mode="corner", return_z=False):
# Extracts the position of the upper left corner of a scatterer
num_outputs = 2 + return_z

if mode == "corner":
# Probably unecessarily complicated expression
shift = (
np.ceil((np.array(image.shape) - 1) / 2)
- (1 - np.mod(image.shape, 2)) * 0.5
)
if mode == "corner" and image.size > 0:

shift = scipy.ndimage.measurements.center_of_mass(np.abs(np.array(image)))

if np.isnan(shift).any():
shift = np.array(image.shape) / 2

else:
shift = np.zeros((num_outputs))

Expand Down
1,336 changes: 801 additions & 535 deletions paper-examples/2-single_particle_tracking.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Sphinx==2.2.0
pydata-sphinx-theme
numpydoc
scikit-image
pint
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
with open("README.md", "r") as fh:
long_description = fh.read()

required = ["tensorflow", "numpy", "scipy"]
required = ["tensorflow", "numpy", "scipy", "scikit-image", "pint"]
installed = [pkg.key for pkg in pkg_resources.working_set]
if (
not "tensorflow" in installed
Expand All @@ -16,7 +16,7 @@

setuptools.setup(
name="deeptrack", # Replace with your own username
version="0.11.0",
version="0.11.3",
author="Benjamin Midtvedt",
author_email="benjamin.midtvedt@physics.gu.se",
description="A deep learning oriented microscopy image simulation package",
Expand Down