Skip to content

Commit

Permalink
Remove pixelwise updates for features
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Jul 6, 2015
1 parent be068fe commit 0536bb2
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 81 deletions.
12 changes: 0 additions & 12 deletions gala/features/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def update_node_cache(self, *args, **kwargs):
pass
def update_edge_cache(self, *args, **kwargs):
pass
def pixelwise_update_node_cache(self, *args, **kwargs):
pass
def pixelwise_update_edge_cache(self, *args, **kwargs):
pass
def compute_node_features(self, *args, **kwargs):
return np.array([])
def compute_edge_features(self, *args, **kwargs):
Expand Down Expand Up @@ -69,14 +65,6 @@ def update_edge_cache(self, g, e1, e2, dst, src):
for i, child in enumerate(self.children):
child.update_edge_cache(g, e1, e2, dst[i], src[i])

def pixelwise_update_node_cache(self, g, n, dst, idxs, remove=False):
for i, child in enumerate(self.children):
child.pixelwise_update_node_cache(g, n, dst[i], idxs, remove)

def pixelwise_update_edge_cache(self, g, n1, n2, dst, idxs, remove=False):
for i, child in enumerate(self.children):
child.pixelwise_update_edge_cache(g, n1, n2, dst[i], idxs, remove)

def compute_node_features(self, g, n, cache=None):
if cache is None: cache = g.node[n][self.default_cache]
features = []
Expand Down
9 changes: 0 additions & 9 deletions gala/features/contact.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ class Manager(base.Null):
def update_edge_cache(self, g, e1, e2, dst, src):
dst += src

def pixelwise_update_edge_cache(self, g, n1, n2, dst, idxs, remove=False):
if len(idxs) == 0: return
n1_idxs = np.array(list(g.extent(n1)))
n2_idxs = np.array(list(g.extent(n2)))
a = -1.0 if remove else 1.0
if self.oriented: ar = g.oriented_probabilities_r
else: ar = g.non_oriented_probabilities_r
dst += a * _compute_edge_cache(idxs, n1_idxs, n2_idxs, ar, self.thresholds)


cdef _compute_contact_matrix(double[:,:,:] totals, double volume_ratio_1,
double volume_ratio_2):
Expand Down
6 changes: 0 additions & 6 deletions gala/features/convex_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ def update_edge_cache(self, g, e1, e2, dst, src):
vol, tri = self.convex_hull_vol(allind, g)
dst = np.array([tri,vol])

def pixelwise_update_node_cache(self, g, n, dst, idxs, remove=False):
pass

def pixelwise_update_edge_cache(self, g, n1, n2, dst, idxs, remove=False):
pass

def compute_node_features(self, g, n, cache=None):
if cache is None:
cache = g.node[n][self.default_cache]
Expand Down
21 changes: 1 addition & 20 deletions gala/features/histogram.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,10 @@ class Manager(base.Null):
def update_edge_cache(self, g, e1, e2, dst, src):
dst += src

def pixelwise_update_node_cache(self, g, n, dst, idxs, remove=False):
if len(idxs) == 0: return
a = -1.0 if remove else 1.0
if self.oriented:
ar = g.max_probabilities_r
else:
ar = g.non_oriented_probabilities_r

dst += a * self.histogram(ar[idxs,:])

def pixelwise_update_edge_cache(self, g, n1, n2, dst, idxs, remove=False):
if len(idxs) == 0: return
a = -1.0 if remove else 1.0
if self.oriented:
ar = g.oriented_probabilities_r
else:
ar = g.non_oriented_probabilities_r

dst += a * self.histogram(ar[idxs,:])

def JS_divergence(self, p, q):
m = (p+q)/2
return (self.KL_divergence(p, m) + self.KL_divergence(q, m))/2

def KL_divergence(self, p, q):
"""Return the Kullback-Leibler Divergence between two histograms."""
kl = []
Expand Down
18 changes: 0 additions & 18 deletions gala/features/moments.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,6 @@ class Manager(base.Null):
def update_edge_cache(self, g, e1, e2, dst, src):
dst += src

def pixelwise_update_node_cache(self, g, n, dst, idxs, remove=False):
if len(idxs) == 0: return
a = -1.0 if remove else 1.0
if self.oriented:
ar = g.max_probabilities_r
else:
ar = g.non_oriented_probabilities_r
dst += a * self.compute_moment_sums(ar, idxs)

def pixelwise_update_edge_cache(self, g, n1, n2, dst, idxs, remove=False):
if len(idxs) == 0: return
a = -1.0 if remove else 1.0
if self.oriented:
ar = g.max_probabilities_r
else:
ar = g.non_oriented_probabilities_r
dst += a * self.compute_moment_sums(ar, idxs)

def compute_node_features(self, g, n, cache=None):
if cache is None:
cache = g.node[n][self.default_cache]
Expand Down
16 changes: 0 additions & 16 deletions gala/features/squiggliness.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,3 @@ def update_edge_cache(self, g, e1, e2, dst, src):
(dst[np.newaxis,self.ndim:], src[np.newaxis,self.ndim:]),
axis=0).max(axis=0)

def pixelwise_update_edge_cache(self, g, n1, n2, dst, idxs, remove=False):
if remove:
pass
# dst = self.create_edge_cache(g, n1, n2)
if len(idxs) == 0: return
b = np.concatenate(
self.compute_bounding_box(idxs, g.watershed.shape))
self.update_edge_cache(g, (n1,n2), None, dst, b)

def compute_edge_features(self, g, n1, n2, cache=None):
if cache is None:
cache = g[n1][n2][self.default_cache]
m, M = cache[:self.ndim], cache[self.ndim:]
plane_surface = np.sort(M-m)[1:].prod() * (3.0-g.pad_thickness)
return np.array([len(g[n1][n2]['boundary']) / plane_surface])

0 comments on commit 0536bb2

Please sign in to comment.