Mapping

!pip install vfb-connect --upgrade
# Import libs and initialise API objects
from vfb_connect.cross_server_tools import VfbConnect
import pandas as pd

vc = VfbConnect()

import pymaid
import navis

navis.set_pbars(jupyter=False)
pymaid.set_pbars(jupyter=False)

# Connect to the VFB CATMAID server hosting the FAFB data
rm = pymaid.connect_catmaid(server="https://fafb.catmaid.virtualflybrain.org/", api_token=None, max_threads=10)

# Test call to see if connection works 
print(f'Server is running CATMAID version {rm.catmaid_version}')

# Many functions return JSON-compatible nested data structures. This function coverts them to DataFrame.
def summary_2_df(summary, sort=None):
    """Convert summary to DataFrame.  Optionally specify a set of columns to sort as a list of strings"""
    if sort:
        return pd.DataFrame.from_records(summary).sort_values(sort)
    else:
        return pd.DataFrame.from_records(summary)
WARNING: Could not load OpenGL library.
INFO  : Global CATMAID instance set. Caching is ON. (pymaid)
Server is running CATMAID version 2020.02.15-925-gf56795c9c

Mapping

Use case: If I have a single neuron, how can I find other neurons of the same or similar type within or between data sources?

Mapping via common parent type

# lets take some examples from a discovery query on the previous spreadhseet
sayin_tab = pd.DataFrame.from_records(vc.get_instances_by_dataset('Sayin2019', summary=True))
sayin_tab

label symbol id tags parents_label parents_id data_source accession templates dataset license
0 OA-VPM3 (FAFB:1329078) VFB_001001dr Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 catmaid_fafb 1329078 JRC2018Unisex Sayin2019 https://creativecommons.org/licenses/by-sa/4.0...
1 OA-VPM4 (FAFB:1191261) VFB_001001dq Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM4 neuron FBbt_00110152 catmaid_fafb 1191261 JRC2018Unisex Sayin2019 https://creativecommons.org/licenses/by-sa/4.0...
oct_VPM3 = summary_2_df(vc.get_instances('octopaminergic VPM3 neuron', summary=True))
oct_VPM3

label symbol id tags parents_label parents_id data_source accession templates dataset license
0 OA-VPM3(NO2/NO3)_R - 329566174 VFB_jrchk10d Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 neuprint_JRC_Hemibrain_1point1 329566174 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
1 OA-VPM3(NO2/NO3)_L - 5813061260 VFB_jrchk10e Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 neuprint_JRC_Hemibrain_1point1 5813061260 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
2 OA-VPM3 (FAFB:1329078) VFB_001001dr Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 catmaid_fafb 1329078 JRC2018Unisex Sayin2019 https://creativecommons.org/licenses/by-sa/4.0...
oct_VPM3_images = vc.neo_query_wrapper.get_images(oct_VPM3['id'], stomp=True, template='JRC2018Unisex', image_folder = 'oct_VPM3b')
oct_VPM3_images

label symbol id tags parents_label parents_id data_source accession templates dataset license filename
0 OA-VPM3 (FAFB:1329078) VFB_001001dr Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 catmaid_fafb 1329078 JRC2018Unisex Sayin2019 https://creativecommons.org/licenses/by-sa/4.0... OA_VPM3__FAFB_1329078_.swc
1 OA-VPM3(NO2/NO3)_L - 5813061260 VFB_jrchk10e Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 neuprint_JRC_Hemibrain_1point1 5813061260 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le... OA_VPM3_NO2_NO3__L___5813061260.swc
2 OA-VPM3(NO2/NO3)_R - 329566174 VFB_jrchk10d Entity|Octopaminergic|Adult|Anatomy|has_image|... octopaminergic VPM3 neuron FBbt_00110151 neuprint_JRC_Hemibrain_1point1 329566174 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le... OA_VPM3_NO2_NO3__R___329566174.swc
oct_VPM3_images = vc.get_images_by_type('octopaminergic VPM3 neuron', stomp=True, template='JRC2018Unisex', image_folder = 'oct_VPM3')
nl = navis.read_swc('./oct_VPM3')
navis.plot3d(nl)
Running query: FBbt:00110151
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00110151&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 3