In [1]:
import pymaid
rm = pymaid.CatmaidInstance('server_url', 'api_token', 'http_user', 'http_password')
nl = pymaid.get_neurons('annotation:glomerulus DA1 right')
In [2]:
cont = pymaid.get_contributor_statistics(nl, separate=True)
cont.head()
Out[2]:
In [3]:
by_user = pymaid.get_user_contributions(nl)
by_user.head()
Out[3]:
In [4]:
time_inv = pymaid.get_time_invested(nl)
time_inv.head()
Out[4]:
In [5]:
import matplotlib.pyplot as plt
lh = pymaid.get_volume('LH_R')
lh.color = (240,240,240,.5)
nl_lh = nl.prune_by_volume(lh, inplace=False)
fig, ax = pymaid.plot2d([nl_lh, lh], connectors=False, linewidth=1.5)
plt.show()
In [6]:
time_lh = pymaid.get_time_invested(nl_lh)
time_lh.head()
Out[6]:
In [7]:
node_details = pymaid.get_node_details(nl_lh.nodes.treenode_id.values)
connector_details = pymaid.get_node_details(nl_lh.connectors.connector_id.values)
Out[7]:
In [8]:
user_list = pymaid.get_user_list().set_index('id').login.to_dict()
node_details['creator2'] = node_details.creator.map(user_list)
connector_details['creator2'] = connector_details.creator.map(user_list)
node_details.head()
Out[8]:
In [9]:
import pandas as pd
node_counts = node_details.groupby('creator2').node_id.count()
cn_counts = connector_details.groupby('creator2').node_id.count()
lh_counts = pd.concat([node_counts, cn_counts], axis=1, sort=True).fillna(0).astype(int)
lh_counts.columns=['nodes', 'connectors']
lh_counts.sort_values('nodes', ascending=False).head()
Out[9]:
In [10]:
import numpy as np
after_date = np.datetime64('2017-01-01')
# Get node details
node_details = pymaid.get_node_details(nl.nodes.treenode_id.values)
cn_details = pymaid.get_node_details(nl.connectors.connector_id.values)
# Subset to nodes/connectors created after given date
new_nodes = node_details[node_details.creation_time >= after_date].node_id.values
new_connectors = cn_details[cn_details.creation_time >= after_date].node_id.values
# Subset neurons to the new nodes/connectors
nl_new = nl.copy()
for n in nl_new:
pymaid.subset_neuron(n, new_nodes, inplace=True, remove_disconnected=False)
n.connectors = n.connectors[n.connectors.connector_id.isin(new_connectors)]
In [11]:
fig, ax = pymaid.plot2d(nl, color=(.8,.8,.8), connectors=False)
_ = pymaid.plot2d(nl_new, color='r', ax=ax, connectors=False, linewidth=1)
plt.show()
In [12]:
time_new = pymaid.get_time_invested(nl_new)
time_new.head()
Out[12]: