Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
09b7bfd
Update layers.py
JesusPinedaC Aug 12, 2022
ed832bb
Update convolutional.py
JesusPinedaC Aug 12, 2022
bc1f640
Update documentation
JesusPinedaC Aug 12, 2022
5fc6d0b
Update Transformer-based models
JesusPinedaC Aug 15, 2022
5b2775e
Delete classifying_MNIST_vit_tutorial.ipynb
JesusPinedaC Aug 15, 2022
c94f4c2
Create classifying_MNIST_vit_tutorial.ipynb
JesusPinedaC Aug 15, 2022
a96aa39
Update datasets.py
JesusPinedaC Aug 15, 2022
20a1fa5
Allows kwargs as inputs in single_layer_call
JesusPinedaC Sep 8, 2022
ba4f59f
Update embeddings.py
JesusPinedaC Sep 8, 2022
9cb49ed
masked transformers
JesusPinedaC Sep 8, 2022
11a8fd4
reformat transformer models
JesusPinedaC Sep 8, 2022
00b0e53
Merge branch 'develop' of https://github.com/softmatterlab/DeepTrack-…
JesusPinedaC Sep 8, 2022
22f64ae
Create trajectory_analysis_tutorial.ipynb
JesusPinedaC Sep 8, 2022
6567cff
Add Variational autoencoders
JesusPinedaC Sep 8, 2022
ce9dfc7
Add variational autoencoders
JesusPinedaC Sep 8, 2022
1b66ead
Update vae.py
JesusPinedaC Sep 9, 2022
1c0ee2a
Create MNIST_VAE_tutorial.ipynb
JesusPinedaC Sep 9, 2022
931c859
Update MNIST_VAE_tutorial.ipynb
JesusPinedaC Sep 9, 2022
87663ba
Create folder for course examples
JesusPinedaC Sep 9, 2022
b23cd86
Update README.md
JesusPinedaC Sep 9, 2022
0e26a3b
Update README.md
JesusPinedaC Sep 9, 2022
3ab83a0
Update examples
JesusPinedaC Sep 9, 2022
54c5185
Update README.md
JesusPinedaC Sep 9, 2022
01cb0ab
Update README.md
JesusPinedaC Sep 9, 2022
d1c7c12
Update MNIST VAE examples
JesusPinedaC Sep 9, 2022
15227ec
Merge branch 'dt/eth-cs-examples' of https://github.com/softmatterlab…
JesusPinedaC Sep 9, 2022
c8dfeb0
Added MLP regression example
BenjaminMidtvedt Sep 9, 2022
924053f
Merge branch 'dt/eth-cs-examples' of https://github.com/softmatterlab…
BenjaminMidtvedt Sep 9, 2022
3aefd86
Update README.md
JesusPinedaC Sep 9, 2022
d397eaa
Create image_segmentation_Unet.ipynb
JesusPinedaC Sep 10, 2022
bc7501f
Update README.md
JesusPinedaC Sep 10, 2022
2a511eb
Documented and tested cell_counting_tutorial.ipynb
Henrik-KM Sep 11, 2022
afdc583
improve dnn example
BenjaminMidtvedt Sep 15, 2022
652fbc8
Shift variant mie
BenjaminMidtvedt Sep 15, 2022
f112b29
Position mie scatterer correctly
BenjaminMidtvedt Sep 15, 2022
59d821d
implement set z
BenjaminMidtvedt Sep 15, 2022
c066edf
Merge branch 'dt/eth-cs-examples' of https://github.com/softmatterlab…
BenjaminMidtvedt Sep 18, 2022
39c02e4
implement mnist v1
BenjaminMidtvedt Sep 19, 2022
297b01f
implement z dependence
BenjaminMidtvedt Sep 20, 2022
4f6967a
remove logging
BenjaminMidtvedt Sep 20, 2022
c407990
Implement flattening methods
BenjaminMidtvedt Sep 20, 2022
b5301de
Implement pooling and resizing
BenjaminMidtvedt Sep 20, 2022
8bbfa24
Implement TensorflowDataset
BenjaminMidtvedt Sep 20, 2022
91f774f
Finalize MNIST
BenjaminMidtvedt Sep 20, 2022
5747b78
Implement Malaria classification
BenjaminMidtvedt Sep 20, 2022
f1d082f
alpha0 release
BenjaminMidtvedt Sep 22, 2022
61c76dd
fix batchsize in fit
BenjaminMidtvedt Sep 27, 2022
12f0a1a
implement dataset.take
BenjaminMidtvedt Sep 27, 2022
e84d92b
Implement datasets
BenjaminMidtvedt Sep 27, 2022
07268bd
fix phase in mie
BenjaminMidtvedt Sep 27, 2022
71d600a
Merge branch 'bm/mie-optics' into dt/eth-cs-examples
BenjaminMidtvedt Sep 27, 2022
eb100c4
Fix mie positioning and focusing
BenjaminMidtvedt Sep 27, 2022
e11515c
Commit to new branch
BenjaminMidtvedt Oct 4, 2022
28d899d
Merge branch 'develop' into bm/version-1.4.0
giovannivolpe Oct 4, 2022
d6081a0
add tensorflow datasets dependence
BenjaminMidtvedt Oct 4, 2022
eef9814
Merge branch 'bm/version-1.4.0' of https://github.com/softmatterlab/D…
BenjaminMidtvedt Oct 4, 2022
e0130eb
remove test
BenjaminMidtvedt Oct 4, 2022
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
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
**/.ipynb_checkpoints
**/__pycache__
deeptrack-app/*
*/datasets/*

paper-examples/models/*

build/*
dist/*
*.egg-info/
*/datasets/*
*/theory
_src/build/**/*

Expand All @@ -16,6 +15,11 @@ ParticleSizing
CellData
ParticleTracking
data/
datasets/
examples/**/*/models/
**/node_modules/

*.tif
*.png
*.jpg
*.jpeg
*.npy
3 changes: 3 additions & 0 deletions deeptrack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pint import UnitRegistry, Context
from .backend.pint_definition import pint_definitions


units = UnitRegistry(pint_definitions.split("\n"))

import tensorflow as tf
Expand All @@ -27,6 +28,7 @@
from .statistics import *
from .holography import *


from .image import strip

from . import (
Expand All @@ -39,4 +41,5 @@
backend,
test,
visualization,
datasets,
)
24 changes: 24 additions & 0 deletions deeptrack/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,30 @@ def image_to_crop(image):
)


class CropTight(Feature):
def __init__(self, eps=1e-10, **kwargs):
"""Crops input array to remove empty space.

Removes indices from the start and end of the array, where all values are below eps.

Currently only works for 3D arrays.

Parameters
----------
eps : float, optional
The threshold for considering a pixel to be empty, by default 1e-10"""
super().__init__(eps=eps, **kwargs)

def get(self, image, eps, **kwargs):
image = np.asarray(image)

image = image[..., np.any(image > eps, axis=(0, 1))]
image = image[np.any(image > eps, axis=(1, 2)), ...]
image = image[:, np.any(image > eps, axis=(0, 2)), :]

return image


class Pad(Augmentation):
"""Pads the image.

Expand Down
6 changes: 6 additions & 0 deletions deeptrack/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from deeptrack.datasets import (
detection_QuantumDots,
segmentation_ssTEM_drosophila,
regression_holography_nanoparticles,
segmentation_fluorescence_u2os,
)
3 changes: 3 additions & 0 deletions deeptrack/datasets/detection_QuantumDots/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""detection_QuantumDots dataset."""

from .detection_QuantumDots import DetectionQuantumdots
2 changes: 2 additions & 0 deletions deeptrack/datasets/detection_QuantumDots/checksums.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://drive.google.com/file/d/1naaoxIaAU1F_rBaI-I1pB1K4Sp6pq_Jv/view?usp=sharing 67850 95f52b3bbfbf1b2fe7f213021fbd63bdf5040a4dc099ef6903243feb849f06c6 view
https://drive.google.com/u/1/uc?id=1naaoxIaAU1F_rBaI-I1pB1K4Sp6pq_Jv&export=download 543855765 375476e7a70fa3c1a8f91f2e4035b896b8d8acb1800dae2e1e028c2db485a030 QuantumDots.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""detection_QuantumDots dataset."""

import tensorflow_datasets as tfds
from . import detection_QuantumDots


class DetectionQuantumdotsTest(tfds.testing.DatasetBuilderTestCase):
"""Tests for detection_QuantumDots dataset."""
# TODO(detection_QuantumDots):
DATASET_CLASS = detection_QuantumDots.DetectionQuantumdots
SPLITS = {
'train': 3, # Number of fake train example
'test': 1, # Number of fake test example
}

# If you are calling `download/download_and_extract` with a dict, like:
# dl_manager.download({'some_key': 'http://a.org/out.txt', ...})
# then the tests needs to provide the fake output paths relative to the
# fake data directory
# DL_EXTRACT_RESULT = {'some_key': 'output_file1.txt', ...}


if __name__ == '__main__':
tfds.testing.test_main()
69 changes: 69 additions & 0 deletions deeptrack/datasets/detection_QuantumDots/detection_QuantumDots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""detection_QuantumDots dataset."""

import tensorflow_datasets as tfds
import tensorflow as tf
import numpy as np

# TODO(detection_QuantumDots): Markdown description that will appear on the catalog page.
_DESCRIPTION = """
Sequential images of quantum dots in a fluorescent microscope. The dataset is unlabeled.
"""

# TODO(detection_QuantumDots): BibTeX citation
_CITATION = """
"""


class DetectionQuantumdots(tfds.core.GeneratorBasedBuilder):
"""DatasetBuilder for detection_QuantumDots dataset."""

VERSION = tfds.core.Version("1.0.0")
RELEASE_NOTES = {
"1.0.0": "Initial release.",
}

def _info(self) -> tfds.core.DatasetInfo:
"""Returns the dataset metadata."""
# TODO(detection_QuantumDots): Specifies the tfds.core.DatasetInfo object
return tfds.core.DatasetInfo(
builder=self,
description=_DESCRIPTION,
features=tfds.features.FeaturesDict(
{
# These are the features of your dataset like images, labels ...
"image": tfds.features.Image(
shape=(1200, 1200, 1),
dtype=tf.uint16,
),
}
),
# If there's a common (input, target) tuple from the
# features, specify them here. They'll be used if
# `as_supervised=True` in `builder.as_dataset`.
supervised_keys=None, # Set to `None` to disable
homepage="https://dataset-homepage/",
citation=_CITATION,
)

def _split_generators(self, dl_manager: tfds.download.DownloadManager):
"""Returns SplitGenerators."""
# TODO(detection_QuantumDots): Downloads the data and defines the splits
path = dl_manager.download_and_extract(
"https://drive.google.com/u/1/uc?id=1naaoxIaAU1F_rBaI-I1pB1K4Sp6pq_Jv&export=download"
)

# TODO(detection_QuantumDots): Returns the Dict[split names, Iterator[Key, Example]]
return {
"train": self._generate_examples(path / "QuantumDots"),
}

def _generate_examples(self, path):
"""Yields examples."""
tifpath = path / "Qdots.tif"

image_stack = tfds.core.lazy_imports.tifffile.imread(tifpath)
image_stack = np.expand_dims(image_stack, axis=-1)
for i, image in enumerate(image_stack):
yield str(i), {
"image": image,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""regression_holography_nanoparticles dataset."""

from .regression_holography_nanoparticles import RegressionHolographyNanoparticles
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO(regression_holography_nanoparticles): If your dataset downloads files, then the checksums
# will be automatically added here when running
# `tfds build --register_checksums`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""regression_holography_nanoparticles dataset."""

import tensorflow_datasets as tfds
import tensorflow as tf
import numpy as np

# TODO(regression_holography_nanoparticles): Markdown description that will appear on the catalog page.
_DESCRIPTION = """
"""

# TODO(regression_holography_nanoparticles): BibTeX citation
_CITATION = """
"""


class RegressionHolographyNanoparticles(tfds.core.GeneratorBasedBuilder):
"""DatasetBuilder for regression_holography_nanoparticles dataset."""

VERSION = tfds.core.Version("1.0.0")
RELEASE_NOTES = {
"1.0.0": "Initial release.",
}

def _info(self) -> tfds.core.DatasetInfo:
"""Returns the dataset metadata."""
# TODO(regression_holography_nanoparticles): Specifies the tfds.core.DatasetInfo object
return tfds.core.DatasetInfo(
builder=self,
description=_DESCRIPTION,
features=tfds.features.FeaturesDict(
{
# These are the features of your dataset like images, labels ...
"image": tfds.features.Tensor(shape=(64, 64, 2), dtype=tf.float64),
"radius": tfds.features.Scalar(tf.float64),
"refractive_index": tfds.features.Scalar(tf.float64),
}
),
# If there's a common (input, target) tuple from the
# features, specify them here. They'll be used if
# `as_supervised=True` in `builder.as_dataset`.
supervised_keys=(
"image",
"radius",
"refractive_index",
), # Set to `None` to disable
homepage="https://dataset-homepage/",
citation=_CITATION,
)

def _split_generators(self, dl_manager: tfds.download.DownloadManager):
"""Returns SplitGenerators."""
# TODO(regression_holography_nanoparticles): Downloads the data and defines the splits
path = dl_manager.download_and_extract(
"https://drive.google.com/u/1/uc?id=1LJqWYmLj93WYLKaLm_yQFmiR1FZHhf1r&export=download"
)

# TODO(regression_holography_nanoparticles): Returns the Dict[split names, Iterator[Key, Example]]
return {
"train": self._generate_examples(path, "train"),
"test": self._generate_examples(path, "test"),
}

def _generate_examples(self, path, split):
"""Yields examples."""
# TODO(regression_holography_nanoparticles): Yields (key, example) tuples from the dataset

if split == "train":
data = np.load(path / "training_set.npy")
radius = np.load(path / "training_radius.npy")
refractive_index = np.load(path / "training_n.npy")
elif split == "test":
data = np.load(path / "validation_set.npy")
radius = np.load(path / "validation_radius.npy")
refractive_index = np.load(path / "validation_n.npy")
else:
raise ValueError("Split not recognized:", split)

for idx in range(data.shape[0]):
yield str(idx), {
"image": data[idx],
"radius": radius[idx],
"refractive_index": refractive_index[idx],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""regression_holography_nanoparticles dataset."""

import tensorflow_datasets as tfds
from . import regression_holography_nanoparticles


class RegressionHolographyNanoparticlesTest(tfds.testing.DatasetBuilderTestCase):
"""Tests for regression_holography_nanoparticles dataset."""
# TODO(regression_holography_nanoparticles):
DATASET_CLASS = regression_holography_nanoparticles.RegressionHolographyNanoparticles
SPLITS = {
'train': 3, # Number of fake train example
'test': 1, # Number of fake test example
}

# If you are calling `download/download_and_extract` with a dict, like:
# dl_manager.download({'some_key': 'http://a.org/out.txt', ...})
# then the tests needs to provide the fake output paths relative to the
# fake data directory
# DL_EXTRACT_RESULT = {'some_key': 'output_file1.txt', ...}


if __name__ == '__main__':
tfds.testing.test_main()
3 changes: 3 additions & 0 deletions deeptrack/datasets/segmentation_fluorescence_u2os/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""segmentation_fluorescence_u2os dataset."""

from .segmentation_fluorescence_u2os import SegmentationFluorescenceU2os
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO(segmentation_fluorescence_u2os): If your dataset downloads files, then the checksums
# will be automatically added here when running
# `tfds build --register_checksums`.
Loading