In [1]:
import pymaid
import matplotlib.pyplot as plt
rm = pymaid.CatmaidInstance('server_url', 'api_token', 'http_user', 'http_password')
nl = pymaid.get_neurons('annotation:glomerulus DA1 right excitatory')
In [2]:
nl.reroot(nl.soma, inplace=True)
In [3]:
cut = pymaid.cut_neuron(nl[0], 'SCHLEGEL_LH')
cut
Out[3]:
In [4]:
# Change skeleton ID of one of the fragments
cut[0].skeleton_id = '123456'
In [5]:
# Plot neuron fragments
fig, ax = pymaid.plot2d(cut, connectors=False, linewidth=1.5)
# Annotate cut point
cut_coords = nl[0].nodes.set_index('treenode_id').loc[ nl[0].tags['SCHLEGEL_LH'], ['x','y'] ].values[0]
ax.annotate('cut point', xy=(cut_coords[0], -cut_coords[1]),
xytext=(cut_coords[0], -cut_coords[1]-20000), va='center', ha='center',
arrowprops=dict(facecolor='black', shrink=0.01, width=1),
)
plt.show()
In [6]:
cut = nl.prune_proximal_to('SCHLEGEL_LH', inplace=False)
cut.head()
Out[6]:
In [7]:
# Plot whole neurons first
fig, ax = pymaid.plot2d(nl, connectors=False, linewidth=.5, color='k')
# Add pruned branches in red
fig, ax = pymaid.plot2d(cut, connectors=False, linewidth=1, color='r', ax=ax)
# Annotate cut point
cut_coords = nl[0].nodes.set_index('treenode_id').loc[ nl[0].tags['SCHLEGEL_LH'], ['x','y'] ].values[0]
ax.annotate('cut point', xy=(cut_coords[0], -cut_coords[1]),
xytext=(cut_coords[0], -cut_coords[1]-20000), va='center', ha='center',
arrowprops=dict(facecolor='black', shrink=0.01, width=1),
)
plt.show()
In [8]:
branch_points = nl[0].nodes[nl[0].nodes.type=='branch'].treenode_id.values
cut = pymaid.cut_neuron(nl[0], branch_points)
cut.head()
Out[8]:
In [9]:
# Change the skeleton IDs, to prevent a big mess
for i, n in enumerate(cut):
n.skeleton_id = str(i)
In [10]:
# Plot neuron fragments
fig, ax = pymaid.plot2d(cut, connectors=False, linewidth=1.5)
plt.show()