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

TypeError when trying to fetch connectors #217

Closed bdpedigo closed 2 years ago

bdpedigo commented 2 years ago

Hi @schlegelp - currently having some trouble with trying to pull some connectivity data from the FANC dataset (which I believe is public and I should not need any credentials for?).

I created a fresh environment and re-installed latest pymaid.

Code I'm trying to run

import pymaid

print("pymaid version:")
print(pymaid.__version__)
print()

pymaid.CatmaidInstance(
    server="https://fanc.catmaid.virtualflybrain.org/", api_token=None
)

skids = pymaid.get_skids_by_annotation("Paper: Phelps, Hildebrand, Graham et al. 2020")
print("# fetched neurons:")
print(len(skids))
print()

connectors = pymaid.get_connectors(skids)

Output

pymaid version:
2.0.6

INFO  : Global CATMAID instance set. Caching is ON. (pymaid)
# fetched neurons:
1198

Traceback (most recent call last):
  File "/Users/bpedigo/JHU_code/maggot_models/maggot_models/notebooks/try_pull_vnc.py", line 17, in <module>
    connectors = pymaid.get_connectors(skids)
  File "/Users/bpedigo/miniconda3/envs/test-pymaid/lib/python3.9/site-packages/pymaid/cache.py", line 316, in wrapper
    res = function(*args, **kwargs)
  File "/Users/bpedigo/miniconda3/envs/test-pymaid/lib/python3.9/site-packages/pymaid/fetch.py", line 1247, in get_connectors
    user_list = get_user_list(remote_instance=remote_instance)
  File "/Users/bpedigo/miniconda3/envs/test-pymaid/lib/python3.9/site-packages/pymaid/cache.py", line 316, in wrapper
    res = function(*args, **kwargs)
  File "/Users/bpedigo/miniconda3/envs/test-pymaid/lib/python3.9/site-packages/pymaid/fetch.py", line 3724, in get_user_list
    df = pd.DataFrame([[e[c] for c in columns] for e in user_list],
  File "/Users/bpedigo/miniconda3/envs/test-pymaid/lib/python3.9/site-packages/pymaid/fetch.py", line 3724, in <listcomp>
    df = pd.DataFrame([[e[c] for c in columns] for e in user_list],
  File "/Users/bpedigo/miniconda3/envs/test-pymaid/lib/python3.9/site-packages/pymaid/fetch.py", line 3724, in <listcomp>
    df = pd.DataFrame([[e[c] for c in columns] for e in user_list],
TypeError: string indices must be integers

Any ideas right away as to what could be causing this, or am I using pymaid incorrectly? If nothing jumps out to you I'm happy to look into it further. Looks like something related to pymaid user so I'm guessing I am just not logged in properly or something?

bdpedigo commented 2 years ago

Update - this does work:

neurons = pymaid.find_neurons(
    annotations="Paper: Phelps, Hildebrand, Graham et al. 2020"
)
pymaid.adjacency_matrix(neurons)

so maybe specific to the get_connectors function? Individual connectors aren't that important for me right now so I think this will work, but still curious about how to use that properly

schlegelp commented 2 years ago

Hi Ben! Your minimal example works for me. Best guess is that this is an issue with missing user data (that data is scrubbed for release on public CATMAID instances). I fixed a few bugs there a while ago (see e.g. b7661e4a1215c9995e3bc9329a9eda8b8872e5be) but haven't pushed a new release since.

With that said: I just released pymaid 2.1.0 which includes this fix. Let me know if that does it for you.

Two side notes:

  1. This new release now supports (and requires) navis >= 1.0.0 which came with a couple renamed functions
  2. With this release the default max_threads for CatmaidInstance went down from 100 to 10 to avoid connection warnings with the sometimes slower public CATMAID servers. If you server/internet connection supports that, you can of course go back up again.
bdpedigo commented 2 years ago

Awesome, with that release this looks to be working now. Thanks for the help!