Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Saad Jbabdi
CellCounting
Commits
7c535fcb
Commit
7c535fcb
authored
Sep 16, 2018
by
Saad Jbabdi
Browse files
updating celldb
parent
5ae044fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
CellCounting/utils/db.py
View file @
7c535fcb
...
...
@@ -3,17 +3,24 @@
import
numpy
as
np
import
os
import
sys
class
CellDB
(
object
):
def
__init__
(
self
,
infile
=
None
):
def
__init__
(
self
,
images
=
[],
counts
=
[]):
self
.
images
=
images
self
.
cell_counts
=
counts
if
(
counts
==
[]):
self
.
cell_yn
=
[]
else
:
self
.
cell_yn
=
self
.
cell_counts
>
0
def
clear
(
self
):
self
.
images
=
[]
self
.
cell_counts
=
[]
self
.
cell_yn
=
[]
return
if
(
infile
!=
None
):
self
.
load
(
infile
)
# Merge list of celldb objects
def
merge
(
self
,
dblist
):
shape
=
dblist
[
0
].
images
.
shape
[
1
:]
...
...
@@ -30,6 +37,8 @@ class CellDB(object):
self
.
cell_counts
=
np
.
concatenate
(
self
.
cell_counts
,
np
.
array
(
counts
)[:])
self
.
cell_yn
=
self
.
cell_counts
>
0
self
.
summary
()
return
...
...
@@ -96,11 +105,20 @@ class CellDB(object):
return
# Load from numpy
def
load
(
self
,
infile
):
celldb
=
np
.
load
(
infile
)
self
.
images
=
celldb
[
'images'
]
self
.
cell_counts
=
celldb
[
'counts'
]
self
.
cell_yn
=
celldb
[
'counts'
]
>
0
def
load
(
self
,
infiles
,
overwrite
=
True
):
dblist
=
[]
if
(
overwrite
==
True
):
self
.
clear
()
for
f
in
infiles
:
print
(
'load {} into DB'
.
format
(
f
))
celldb_np
=
np
.
load
(
f
)
celldb
=
CellDB
(
celldb_np
[
'images'
],
celldb_np
[
'counts'
])
print
(
'Append'
)
dblist
.
append
(
celldb
)
self
.
merge
(
dblist
)
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment