Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cell tracking functionality #140

Merged
merged 128 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from 124 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
6d94a42
adding Dylan tweaks
MekWarrior Jul 6, 2018
5c27dfd
Merge branch 'master' into cell_tracking
MekWarrior Jul 6, 2018
a92e2b1
merged latest siamese updates with changes in master
MekWarrior Jul 6, 2018
c995ae9
linting
MekWarrior Jul 6, 2018
cd13b4c
counting training/testing pairs in function
willgraf Jul 6, 2018
fb38702
changes to the siamese model architecture and data generator
MekWarrior Jul 7, 2018
469bd38
linting
MekWarrior Jul 9, 2018
dd64f9c
adding centroid data and division detection
MekWarrior Aug 7, 2018
173893b
Merge branch 'master' into cell_tracking
MekWarrior Aug 7, 2018
477c5bb
Added Testing for the Siamese Model
MekWarrior Aug 11, 2018
21219c6
updated troubleshooting
MekWarrior Aug 11, 2018
ee2f7b1
Integrating DVV refactoring
MekWarrior Aug 13, 2018
f8137aa
Added tracking via cost matrix and lap
MekWarrior Aug 14, 2018
916638b
DVV tweaks to data gen, model, cost matrix
MekWarrior Aug 15, 2018
e62993c
DVV tweaks to tracking
MekWarrior Aug 15, 2018
2f28a25
cost matrix updates
MekWarrior Sep 6, 2018
d58e68a
Merge branch 'master' into cell_tracking
MekWarrior Sep 6, 2018
98f7388
Merging latest changes to master and adding neighborhoods to tracking
MekWarrior Sep 7, 2018
5dedf87
cleaning up the tracking-master merge
MekWarrior Sep 7, 2018
e185219
including a test notebook
MekWarrior Sep 8, 2018
1d1f9f8
adding testing notebooks
MekWarrior Sep 17, 2018
11eb716
Merge branch 'master' into cell_tracking
willgraf Sep 19, 2018
88cdb9e
merge from master
willgraf Sep 21, 2018
a703fe4
Siamese generator transform sync & added features
enricozb Oct 2, 2018
63bcaeb
pulled TrackingGeneratorTests notebook changes
enricozb Oct 10, 2018
0f7541e
confusion matrix & fixed non-augmentation bug
enricozb Oct 27, 2018
9bdb277
Added future neighborhood to tracker.py
enricozb Oct 30, 2018
663c30d
Sync notebooks & image_generator
enricozb Oct 31, 2018
3c86bab
partial cell_tracker fix
enricozb Nov 3, 2018
cd54b9a
cell_tracker potential fix
enricozb Nov 3, 2018
4555d31
Fixed cell_tracker + neighborhood size changes
enricozb Nov 6, 2018
bbbe3c1
Pushing notebooks
enricozb Nov 6, 2018
7989da3
model, comments and nomenclature update
MekWarrior Nov 9, 2018
e75d14b
universal generator for tracking data and minor data gen updates
MekWarrior Nov 15, 2018
dbd3b67
Added cell_tracker dataframe output
enricozb Nov 16, 2018
83eb6a6
occupancy grids -> neighborhoods
enricozb Nov 16, 2018
8c43137
Adding caliban script
enricozb Nov 16, 2018
4267206
Added swap & create_track
enricozb Nov 16, 2018
6641dc3
TrackingTest notebook update
enricozb Nov 16, 2018
a2654d5
image norm update
MekWarrior Nov 17, 2018
3071b2c
Merge branch 'cell_tracking' of https://www.github.com/vanvalenlab/de…
MekWarrior Nov 17, 2018
813754d
Adding .trks support + bug fixes
enricozb Dec 3, 2018
3901d29
Merge branch 'cell_tracking' of https://www.github.com/vanvalenlab/de…
MekWarrior Dec 5, 2018
d52f013
minor updates to make tracking data
MekWarrior Dec 5, 2018
d1581ce
minor notebook additions
MekWarrior Dec 13, 2018
d44d4a6
minor data change
MekWarrior Jan 3, 2019
28c1050
trks diagnostic info cell added
MekWarrior Jan 11, 2019
4455e83
cleaning up notebooks
MekWarrior Jan 18, 2019
e629fd1
Merge branch 'master' into cell_tracking
MekWarrior Jan 18, 2019
b76da98
finishing clean up and resolving merge bugs
MekWarrior Jan 18, 2019
ec13b0f
testing merge master result
MekWarrior Jan 22, 2019
cb83c43
Merge branch 'master' into cell_tracking
MekWarrior Jan 22, 2019
6fe1304
Complete merge with master and validated performance
MekWarrior Jan 23, 2019
35078b5
add seed as training param for sample and conv
willgraf Jan 23, 2019
9113bff
update file_name_save to new-style model_name
willgraf Jan 23, 2019
180f1d7
remove useless else block
willgraf Jan 23, 2019
72c9183
remove augmentation comments and add zoom_range
willgraf Jan 23, 2019
4d396f7
small touchups for count_pairs (should be moved to utils folder for t…
willgraf Jan 23, 2019
2a258db
create data flow before calling model.fit()
willgraf Jan 23, 2019
421cadd
convert file_name_save to model_path
willgraf Jan 23, 2019
76b57c5
add TensorBoard callback
willgraf Jan 23, 2019
4a5f810
changed filepath variables
willgraf Jan 23, 2019
c2b28c7
remove unused import
willgraf Jan 23, 2019
2abf0ff
import regionprops and rename varialbe "regionprops" to rprops
willgraf Jan 23, 2019
c33c27e
missed extra paranthesis
willgraf Jan 23, 2019
063e1e0
missed comma
willgraf Jan 23, 2019
40a1ad8
linted
willgraf Jan 23, 2019
f237a61
linted distance transform (and simplified?)
willgraf Jan 23, 2019
e3fd269
linted model_zoo
willgraf Jan 23, 2019
57759c7
linted image data generators
willgraf Jan 23, 2019
8a78be6
linted
willgraf Jan 23, 2019
f42e9b3
more linting
willgraf Jan 23, 2019
80d1bf6
no more magic number
willgraf Jan 23, 2019
564a6b8
improve `mode` comment for siamese daughter
willgraf Jan 23, 2019
047be56
update get_data from master
willgraf Jan 23, 2019
4a03481
updated comments
willgraf Jan 23, 2019
b14bdd1
fixed get_data bug
willgraf Jan 23, 2019
8984137
weak tests for centroid distance transform
willgraf Jan 23, 2019
44c9139
moved count_pairs to tracking_utils and tested it
willgraf Jan 23, 2019
d0f3087
fix np.squeeze in regionprops
willgraf Jan 23, 2019
6b3eaca
ignore tracking.py from coverage reports
willgraf Jan 23, 2019
f0e68b9
dont use label as a var name as it is imported as a function
willgraf Jan 23, 2019
15c7535
touchups
willgraf Jan 24, 2019
0ae3374
first tests. TODO flow correctness with lineage data
willgraf Jan 24, 2019
396df92
full tracking utils coverage
willgraf Jan 24, 2019
4b5f929
Siamese Doc Strings
willgraf Jan 24, 2019
4f41da4
raise ValueError if daughters is not provided
willgraf Jan 24, 2019
81b6b2c
PEP8 line length
willgraf Jan 24, 2019
c62fe87
add TODO for create_track_ids
willgraf Jan 24, 2019
bce5a3d
channels first enabled
willgraf Jan 24, 2019
938c75b
line length issues
willgraf Jan 24, 2019
7c87cf7
add daughters to test cases
willgraf Jan 24, 2019
d6e2fd6
remove unused import
willgraf Jan 24, 2019
2b613cd
changed raw and tracked to X and y. changed order of imports
willgraf Jan 25, 2019
88548ea
tests for get_data siamese and load_trks
willgraf Jan 25, 2019
4be3882
Added example tracked datasets
MekWarrior Jan 31, 2019
7c9a122
Add example notebook and begin troubleshooting PR-related changes
MekWarrior Feb 2, 2019
354d5c8
Prep a tracking example notebook
MekWarrior Feb 5, 2019
dc763f9
fixing merge bugs
MekWarrior Feb 6, 2019
28440e3
Fixed _fetch_frames bug
enricozb Feb 7, 2019
24b5286
Will's updates
willgraf Feb 7, 2019
0cbfee9
Fixed _fetch_frames bug
enricozb Feb 7, 2019
a84d1d9
ISBI test
MekWarrior Feb 7, 2019
9f69a4d
Merge branch 'cell_tracking' of https://www.github.com/vanvalenlab/de…
MekWarrior Feb 7, 2019
d0405b1
Merge branch 'cell_tracking' of github.com:vanvalenlab/deepcell-tf in…
enricozb Feb 7, 2019
d7f6ebe
Merge branch 'cell_tracking' of https://www.github.com/vanvalenlab/de…
MekWarrior Feb 7, 2019
0e01d83
readme related tracking changes
MekWarrior Feb 8, 2019
083c0e9
fixed blank future frames for division cells
enricozb Feb 8, 2019
a21d7d0
Merge branch 'cell_tracking' of github.com:vanvalenlab/deepcell-tf in…
enricozb Feb 8, 2019
2d60077
typo in readme and clean example notebook
MekWarrior Feb 8, 2019
9e79330
export utils for multi-input models
enricozb Feb 9, 2019
639eddf
finished tracking example notebook
MekWarrior Feb 9, 2019
68fad99
minimize model.predict use
enricozb Feb 9, 2019
ad08e23
Merge branch 'cell_tracking' of github.com:vanvalenlab/deepcell-tf in…
enricozb Feb 9, 2019
528ed64
move trk related functions to tracking_utils
MekWarrior Feb 9, 2019
3639a4e
Merge branch 'cell_tracking' of github.com:vanvalenlab/deepcell-tf in…
enricozb Feb 9, 2019
0d26b01
tracking utils fixes
MekWarrior Feb 23, 2019
abd88af
fixed future areas in cell-features
enricozb Feb 23, 2019
0c3c677
Merge branch 'cell_tracking' of github.com:vanvalenlab/deepcell-tf in…
enricozb Feb 23, 2019
2591fb3
remove future areas 'quick fix'
enricozb Feb 23, 2019
6869b6d
update datasets, tracking utils, and example notebooks
MekWarrior Mar 1, 2019
e49d692
Merge branch 'master' into cell_tracking
MekWarrior Mar 1, 2019
fef4fc9
update readme images
MekWarrior Mar 1, 2019
dd1d5fa
Finished example tracking notebook
MekWarrior Mar 5, 2019
ee3c00a
PEP8 changes for cell_tracking (#148)
willgraf Mar 6, 2019
8292eac
fix data for data gen test
MekWarrior Mar 6, 2019
2258a6a
in _sub_area, if channels_first, just roll axis to pretend channels_l…
willgraf Mar 6, 2019
da57f17
updated data shape for speed, fixed feature names, and tried to dummy…
willgraf Mar 6, 2019
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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ omit =
deepcell/utils/testing_utils.py
deepcell/datasets/*
deepcell/notebooks/*
deepcell/tracking.py
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ DeepCell is neural network library for single cell analysis, written in Python a

DeepCell aids in biological analysis by automatically segmenting and classifying cells in optical microscopy images. The framework processes raw images and uniquely annotates each cell in the image. These annotations can be used to quantify a variety of cellular properties.

Read the documentaiton at [deepcell.readthedocs.io](https://deepcell.readthedocs.io)
Read the documentation at [deepcell.readthedocs.io](https://deepcell.readthedocs.io)

For more information on deploying DeepCell in the cloud [refer to the DeepCell Kiosk documentation](https://deepcell-kiosk.readthedocs.io)

## Examples

Raw Image | Segmented and Tracked
:-------------------------:|:-------------------------:
![](/docs/images/raw.gif) | ![](/docs/images/tracked.gif)

## Getting Started

The fastest way to get started with DeepCell is to run the latest docker image:
Expand Down Expand Up @@ -41,6 +47,10 @@ This will start a jupyter session, with several example notebooks detailing vari

* [3D Watershed - Sample Based.ipynb](scripts/watershed/Watershed%20Transform%203D%20Sample%20Based.ipynb)

### Cell Tracking in Live Cell Imaging

* [Tracking Example.ipynb](scripts/tracking/Tracking%20Example.ipynb)

## DeepCell for Developers

DeepCell uses `nvidia-docker` and `tensorflow` to enable GPU processing.
Expand Down
1 change: 1 addition & 0 deletions deepcell/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from __future__ import division
from __future__ import print_function

from deepcell.datasets import tracked
from deepcell.datasets import hek293
from deepcell.datasets import hela_s3
from deepcell.datasets import mousebrain
Expand Down
38 changes: 38 additions & 0 deletions deepcell/datasets/tracked/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2016-2019 The Van Valen Lab at the California Institute of
# Technology (Caltech), with support from the Paul Allen Family Foundation,
# Google, & National Institutes of Health (NIH) under Grant U24CA224309-01.
# All rights reserved.
#
# Licensed under a modified Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.github.com/vanvalenlab/deepcell-tf/LICENSE
#
# The Work provided may be used for non-commercial academic purposes only.
# For any other use of the Work, including commercial use, please contact:
# vanvalenlab@gmail.com
#
# Neither the name of Caltech nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Builtin Datasets"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from deepcell.datasets.tracked import nih_3t3
from deepcell.datasets.tracked import hela_s3
from deepcell.datasets.tracked import hek293

del absolute_import
del division
del print_function
71 changes: 71 additions & 0 deletions deepcell/datasets/tracked/hek293.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2016-2019 The Van Valen Lab at the California Institute of
# Technology (Caltech), with support from the Paul Allen Family Foundation,
# Google, & National Institutes of Health (NIH) under Grant U24CA224309-01.
# All rights reserved.
#
# Licensed under a modified Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.github.com/vanvalenlab/deepcell-tf/LICENSE
#
# The Work provided may be used for non-commercial academic purposes only.
# For any other use of the Work, including commercial use, please contact:
# vanvalenlab@gmail.com
#
# Neither the name of Caltech nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tracked HEK293 Nuclear Dataset with lineage data for each batch."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os

try:
from tensorflow.python.keras.utils.data_utils import get_file
except ImportError: # tf v1.9 moves conv_utils from _impl to keras.utils
from tensorflow.python.keras._impl.keras.utils.data_utils import get_file

from deepcell.utils.data_utils import get_data


def load_tracked_data(path='HEK293.trks', test_size=.2, seed=0):
"""Loads the tracked HEK293 dataset.

# Args:
path: path where to cache the dataset locally
(relative to ~/.keras/datasets).
test_size: fraction of data to reserve as test data
seed: the seed for randomly shuffling the dataset

Returns:
Tuple of Numpy arrays: `(x_train, y_train), (x_test, y_test)`.
"""
basepath = os.path.expanduser(os.path.join('~', '.keras', 'datasets'))
prefix = path.split(os.path.sep)[:-1]
data_dir = os.path.join(basepath, *prefix) if prefix else basepath
if not os.path.exists(data_dir):
os.makedirs(data_dir)
elif not os.path.isdir(data_dir):
raise IOError('{} exists but is not a directory'.format(data_dir))

path = get_file(path,
origin='https://deepcell-data.s3.amazonaws.com/tracked/HEK293.trks',
file_hash='d19e0fe144633a08d41cf6695e11f72b')

train_dict, test_dict = get_data(path, mode='siamese_daughters',
test_size=test_size, seed=seed)

x_train, y_train = train_dict['X'], train_dict['y']
x_test, y_test = test_dict['X'], test_dict['y']
return (x_train, y_train), (x_test, y_test)
71 changes: 71 additions & 0 deletions deepcell/datasets/tracked/hela_s3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2016-2019 The Van Valen Lab at the California Institute of
# Technology (Caltech), with support from the Paul Allen Family Foundation,
# Google, & National Institutes of Health (NIH) under Grant U24CA224309-01.
# All rights reserved.
#
# Licensed under a modified Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.github.com/vanvalenlab/deepcell-tf/LICENSE
#
# The Work provided may be used for non-commercial academic purposes only.
# For any other use of the Work, including commercial use, please contact:
# vanvalenlab@gmail.com
#
# Neither the name of Caltech nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tracked HeLa S3 Nuclear Dataset with lineage data for each batch."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os

try:
from tensorflow.python.keras.utils.data_utils import get_file
except ImportError: # tf v1.9 moves conv_utils from _impl to keras.utils
from tensorflow.python.keras._impl.keras.utils.data_utils import get_file

from deepcell.utils.data_utils import get_data


def load_tracked_data(path='HeLa_S3.trks', test_size=.2, seed=0):
"""Loads the tracked HeLa-S3 dataset.

# Args:
path: path where to cache the dataset locally
(relative to ~/.keras/datasets).
test_size: fraction of data to reserve as test data
seed: the seed for randomly shuffling the dataset

Returns:
Tuple of Numpy arrays: `(x_train, y_train), (x_test, y_test)`.
"""
basepath = os.path.expanduser(os.path.join('~', '.keras', 'datasets'))
prefix = path.split(os.path.sep)[:-1]
data_dir = os.path.join(basepath, *prefix) if prefix else basepath
if not os.path.exists(data_dir):
os.makedirs(data_dir)
elif not os.path.isdir(data_dir):
raise IOError('{} exists but is not a directory'.format(data_dir))

path = get_file(path,
origin='https://deepcell-data.s3.amazonaws.com/tracked/HeLa_S3.trks',
file_hash='590ee37d3c703cfe029a2e60c9dc777b')

train_dict, test_dict = get_data(path, mode='siamese_daughters',
test_size=test_size, seed=seed)

x_train, y_train = train_dict['X'], train_dict['y']
x_test, y_test = test_dict['X'], test_dict['y']
return (x_train, y_train), (x_test, y_test)
71 changes: 71 additions & 0 deletions deepcell/datasets/tracked/nih_3t3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2016-2019 The Van Valen Lab at the California Institute of
# Technology (Caltech), with support from the Paul Allen Family Foundation,
# Google, & National Institutes of Health (NIH) under Grant U24CA224309-01.
# All rights reserved.
#
# Licensed under a modified Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.github.com/vanvalenlab/deepcell-tf/LICENSE
#
# The Work provided may be used for non-commercial academic purposes only.
# For any other use of the Work, including commercial use, please contact:
# vanvalenlab@gmail.com
#
# Neither the name of Caltech nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tracked 3T3 Nuclear Dataset from the NIH with lineage data for each batch."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os

try:
from tensorflow.python.keras.utils.data_utils import get_file
except ImportError: # tf v1.9 moves conv_utils from _impl to keras.utils
from tensorflow.python.keras._impl.keras.utils.data_utils import get_file

from deepcell.utils.data_utils import get_data


def load_tracked_data(path='3T3_NIH.trks', test_size=.2, seed=0):
"""Loads the tracked 3T3-NIH dataset.

# Args:
path: path where to cache the dataset locally
(relative to ~/.keras/datasets).
test_size: fraction of data to reserve as test data
seed: the seed for randomly shuffling the dataset

Returns:
Tuple of Numpy arrays: `(x_train, y_train), (x_test, y_test)`.
"""
basepath = os.path.expanduser(os.path.join('~', '.keras', 'datasets'))
prefix = path.split(os.path.sep)[:-1]
data_dir = os.path.join(basepath, *prefix) if prefix else basepath
if not os.path.exists(data_dir):
os.makedirs(data_dir)
elif not os.path.isdir(data_dir):
raise IOError('{} exists but is not a directory'.format(data_dir))

path = get_file(path,
origin='https://deepcell-data.s3.amazonaws.com/tracked/3T3_NIH.trks',
file_hash='0d90ad370e1cb9655727065ada3ded65')

train_dict, test_dict = get_data(path, mode='siamese_daughters',
test_size=test_size, seed=seed)

x_train, y_train = train_dict['X'], train_dict['y']
x_test, y_test = test_dict['X'], test_dict['y']
return (x_train, y_train), (x_test, y_test)
Loading