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
24 stars 11 forks source link

module 'pymaid' has no attribute 'split_axon_dendrite' (and others) #209

Closed eddie2612 closed 3 years ago

eddie2612 commented 3 years ago

Hello Phillipp,

I'm currently using the pymaid package but have encountered a few issues with some of the features not running correctly (similar to @michaelsmclayton and @pgibb96).

I'm running pymaid on Windows 10 Home (10.1.19041) and using Anaconda 3. When working my way through the pymaid tutorial, features like get_neuron and get_skids_by_annotation work perfectly with neurons that I've reconstructed. The problems arrive when I try to use the "split_axon_dendrite", "bending_flow" and "flow_centrality" features.

In all cases, I get a response as follows:


>>> split = pymaid.split_axon_dendrite(x, method= 'centrifugal', reroot_soma=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pymaid' has no attribute 'split_axon_dendrite'

I read that pymaid was updated and have installed the latest "python-catmaid" version that has been discussed (I think!)


>>> print(pymaid.__version__)

2.0.2

but I still have the same issues.

Thanks in advance!

schlegelp commented 3 years ago

Hi. split_axon_dendrite() is one of the functions that - as of version 2.0.0 - has been offloaded to navis. As a general rule of thumb: pymaid is for fetching the data, navis lets you manipulate/analyze it.

I did update pymaid's docs to reflect that but I just realized that they did not compile and therefore the old docs were still showing - mea culpa! I just fixed that and for example, pymaid's tutorial page should look like this now (you might have to hard refresh your browser by holding shift while clicking the refresh button):

Screenshot 2021-01-06 at 10 13 15

As you can see the tutorials relating to working with neuron data in general have been dropped, and can now be found in navis. The bottom line is this: you can use any navis function with your CatmaidNeurons and CatmaidNeuronLists. Since this is a big change, I'm sure there are still some uncaught bugs in the code or the docs - let me know if you find something that doesn't work.

Best, Philipp

PS: Cool that it works on Windows - did you have to do anything special to get it to run, or have you found any functionality (like 3D plotting) not to work properly?

eddie2612 commented 3 years ago

Hi. I see - thank you for the update!

I've switched over to navis and it looks like that solved a lot. For most neurons, the feature works perfectly however when I try with a set of motor neurons that I'm interested in I receive the following error:


>>> split = navis.split_axon_dendrite(x, metric = 'flow_centrality', split = 'distance', cellbodyfiber ='soma',reroot_soma = True, labels = True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\eddie\anaconda3\lib\site-packages\navis\morpho\manipulation.py", line 699, in split_axon_dendrite
    g.remove_nodes_from(dendrite)
UnboundLocalError: local variable 'dendrite' referenced before assignment

If I try changing the "split" parameter to 'prepost', I also receive an error as below:

>>> split = navis.split_axon_dendrite(x, metric = 'flow_centrality', split = 'prepost', cellbodyfiber ='soma',reroot_soma = True, labels = True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\eddie\anaconda3\lib\site-packages\navis\morpho\manipulation.py", line 684, in split_axon_dendrite
    dendrite = set.union(*[cc[i] for i in sm[sm.frac_prepost < 1].index.values])
TypeError: descriptor 'union' of 'set' object needs an argument

I even tried using the bending_flow algorithm but then I receive this error:

>>> split = navis.split_axon_dendrite(x, metric = 'bending_flow', split = 'distance', cellbodyfiber ='soma',reroot_soma = True, labels = True)
C:\Users\eddie\anaconda3\lib\site-packages\numpy\lib\arraysetops.py:580: FutureWarning:

elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\eddie\anaconda3\lib\site-packages\navis\morpho\manipulation.py", line 623, in split_axon_dendrite
    mmetrics.bending_flow(x)
  File "C:\Users\eddie\anaconda3\lib\site-packages\navis\morpho\mmetrics.py", line 555, in bending_flow
    raise ValueError(f'Unable to parse connector types for neuron {y.id}')
ValueError: Unable to parse connector types for neuron ....

Naively, I'm wondering if it has something to do with motor neurons not having any output synapses?

Best,

Eddie

P.S. Apart from the above, everything seems to work fine on Windows! I had a bit of trouble with pip and anaconda but I think that's more due to my lack of coding experience and I managed to find some helpful solutions online.

schlegelp commented 3 years ago

split_axon_dendrite works best if there is an intuitive split. It does perform poorly for incomplete neurons where either the dendrites or the axon are (partially) missing - such as your motor neurons. I should perhaps add a more helpful error message in cases where the neuron is clearly incomplete but it's really hard to cover any conceivable scenario.

eddie2612 commented 3 years ago

Ok, that makes sense. I should still be able to get some good work done with the package at any rate!

Thank you for all your help!

schlegelp commented 3 years ago

Hi @eddie2612. Can this issue be closed now?

eddie2612 commented 3 years ago

Hi @schlegelp Yes it can be closed. Thank you!