berenslab / MorphoPy

GNU General Public License v3.0
34 stars 11 forks source link

Error when running the "persistence_test" notebook #109

Closed mstimberg closed 4 years ago

mstimberg commented 4 years ago

(Issue opened as part of openjournals/joss-reviews#2339)

I tried running the persistence_test notebook, but it fails in code cell 7 with

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-29bf43365550> in <module>
      9         df = pd.DataFrame()
     10         for n in neurites:
---> 11             df = df.append(fp.get_persistence(n, f=feature))
     12 
     13         p[feature.__name__] = copy.copy(df)

/mnt/data/anaconda2/envs/morphopy/lib/python3.8/site-packages/computation/feature_presentation.py in get_persistence(neurontree, f)
     38     # set the initial value for leaf nodes
     39     for l in L:
---> 40         v[l] = f(G, l, R)
     41 
     42     while R not in A:

<ipython-input-2-6637ac925df1> in radial_distance(G, u, v)
      1 # A selection of filter functions
      2 def radial_distance(G, u, v):
----> 3     n = G.node[u]['pos']
      4     r = G.node[v]['pos']
      5 

AttributeError: 'DiGraph' object has no attribute 'node'
Visdoom commented 4 years ago

Hi @mstimberg ,

good catch, this error is caused by the changed API of the networkx package between 1.11 and 2.X. I will update the functions to make them work with either version.