Commit 7c535fcb authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

updating celldb

parent 5ae044fd
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment