Skip to content

Commit

Permalink
Validate parent lineage field as well as daughters. (#76)
Browse files Browse the repository at this point in the history
* Validate parent field as well as daughters.

* Bump version to 0.5.0rc2
  • Loading branch information
willgraf committed Sep 21, 2021
1 parent 05a7196 commit 6414e1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions deepcell_tracking/utils.py
Expand Up @@ -535,6 +535,27 @@ def is_valid_lineage(y, lineage):
cell_label, daughter))
return False

# TODO: test parent in lineage
parent = cell_lineage.get('parent')
if parent:
try:
parent_lineage = lineage[parent]
except KeyError:
warnings.warn('Parent {} is not present in the lineage'.format(
cell_lineage['parent']))
return False
try:
last_parent_frame = parent_lineage['frames'][-1]
first_daughter_frame = cell_lineage['frames'][0]
except IndexError: # frames is empty?
warnings.warn('Cell {} has no frames'.format(parent))
return False
# Check that daughter's start frame is one larger than parent end frame
if first_daughter_frame - last_parent_frame != 1:
warnings.warn('lineage {} has daughter {} before parent.'.format(
cell_label, daughter))
return False

return True # all cell lineages are valid!


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -37,7 +37,7 @@
readme = f.read()


VERSION = '0.5.0-rc.1'
VERSION = '0.5.0-rc.2'
NAME = 'DeepCell_Tracking'
DESCRIPTION = 'Tracking cells and lineage with deep learning.'
LICENSE = 'LICENSE'
Expand Down

0 comments on commit 6414e1d

Please sign in to comment.