jni / ray

Automatic segmentation of electron microscopy volumes
Other
31 stars 10 forks source link

feature manager update breaks mean, sem and n features #7

Closed jni closed 13 years ago

jni commented 13 years ago

The mean, sem and n feature used the makeshift 'sump' feature caches that have now been deprecated. Therefore, a lot of code is broken because of the cache update.

jni commented 13 years ago

feature_set_a has been updated to use the feature-cache key in the node and edge dictionaries, as of f51458a62ac6e8b7a6ab9decc34b3de3dc366527.

However, some feature-caches are not being updated during the agglomeration process:

python -m pdb ./classify.py -t 1.0 -o random_priority -c ada tmp/2dml/ws.h5 tmp/2dml/gt250.h5 tmp/2dml/prob.h5 tmp/2dml/ada.pck

Traceback (most recent call last):
  File "/Library/Frameworks/EPD64.framework/Versions/7.0/lib/python2.7/pdb.py", line 1314, in main
    pdb._runscript(mainpyfile)
  File "/Library/Frameworks/EPD64.framework/Versions/7.0/lib/python2.7/pdb.py", line 1233, in _runscript
    self.run(statement)
  File "/Library/Frameworks/EPD64.framework/Versions/7.0/lib/python2.7/bdb.py", line 383, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "./classify.py", line 4, in <module>
    import sys, os, argparse
  File "./agglo.py", line 317, in learn_agglomerate
    features.append(feature_map_function(self, n1, n2).ravel())
  File "./classify.py", line 224, in feature_set_a
    mb, sb, lb = mean_sem_and_n_from_cache_dict(g[n1][n2])
  File "./classify.py", line 198, in mean_sem_and_n_from_cache_dict
    n, s1, s2 = d['feature-cache'][:3]
KeyError: 'feature-cache'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /Volumes/Projects/ray/classify.py(198)mean_sem_and_n_from_cache_dict()
-> n, s1, s2 = d['feature-cache'][:3]
(Pdb) u
> /Volumes/Projects/ray/classify.py(224)feature_set_a()
-> mb, sb, lb = mean_sem_and_n_from_cache_dict(g[n1][n2])
(Pdb) p n1, n2
(31516, 5204)
(Pdb) p g.has_edge(n1, n2)
True
(Pdb) p g[n1][n2]
{'qlink': [0.04494528187511959, True, 5204, 31516], 'boundary': set([25315]), 'weight': 0.04494528187511959}
(Pdb) p g.feature_manager
<classify.MomentsFeatureManager object at 0x10ab6d590>
(Pdb) p g.feature_manager.cache_length()
*** TypeError: TypeError("'int' object is not callable",)
(Pdb) p g.feature_manager.cache_length
5
(Pdb) p g.feature_manager.cache_length > 0
True
(Pdb) g.number_of_edges()
*** TypeError: 'int' object is not callable
(Pdb) p g.number_of_edges()
*** TypeError: TypeError("'int' object is not callable",)
(Pdb) p g.number_of_edges
<bound method Rag.number_of_edges of <agglo.Rag object at 0x10ab6da90>>
(Pdb) p g.number_of_edges()
*** TypeError: TypeError("'int' object is not callable",)
(Pdb) p len(g.edges())
69825
(Pdb) p len([(u,v) for u,v in g.edges() if g[u][v].haskey('feature-cache')])
*** AttributeError: AttributeError("'dict' object has no attribute 'haskey'",)
(Pdb) p len([(u,v) for u,v in g.edges() if g[u][v].has_key('feature-cache')])
69822
jni commented 13 years ago

Fixed! in 538cee9c932e22cf1d03e32d08c62591340b05de agglo.Rag.refine_post_merge_boundaries() was not properly creating a new feature cache when a new edge had been created.