navis-org / pymaid

Python library to interface with CATMAID servers. Fully interoperable with navis.
https://pymaid.readthedocs.io/en/latest/
GNU General Public License v3.0
23 stars 11 forks source link

pymaid.connectivity.cable_overlap raises KeyError exception #212

Closed kuanawanda closed 3 years ago

kuanawanda commented 3 years ago

KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

This seems to be a result of changes in how Pandas deals with indexing. As suggested in the link above, the following edits in pymaid.connectivity seems to fix this issue (lines 347-348).

  #nA_in_dist = nA._dps.loc[ixA[distA != float('inf')]]
  #nB_in_dist = nB._dps.loc[ixB[distB != float('inf')]]
  nA_in_dist = nA._dps.reindex(ixA[distA != float('inf')])
  nB_in_dist = nB._dps.reindex(ixB[distB != float('inf')])`

I also tried using navis.cable_overlap instead but it seems that this function requires neuron.dps attribute to exist. Currently, it doesn't seem like CatmaidNeuron objects pulled from pymaid.get_neuron have this attribute.

schlegelp commented 3 years ago

Unfortunately, it's not as easy as reindexing since we really don't expect missing indices there. That being said: I should remove pymaid.cable_overlap since it has the exact same functionality as navis.cable_overlap.

navis.cable_overlap was indeed broken but has already been fixed on Github. So if you uninstall your navis and re-install from Github you should be able to use that function:

$ pip3 uninstall navis -y
$ pip3 install git+git://github.com/schlegelp/navis@master

If that still doesn't cut it, please share a minimal working example and the versions of navis and pymaid on your machine.

kuanawanda commented 3 years ago

Thanks @schlegelp! Updating to the new version of navis fixed both issues for me.