def get_cell_morphXYZ(cell_id): from allensdk.core.cell_types_cache import CellTypesCache from allensdk.core.swc import Marker import pprint ctc = CellTypesCache(manifest_file='cell_types/manifest.json') morph = ctc.get_reconstruction(cell_id) markers = ctc.get_reconstruction_markers(cell_id) x = [] y = [] z = [] for n in morph.compartment_list: #print(n['type']) #type=1, soma; type=2, axon; type=3, dendrite; type=4,apical dendrite if n['type'] == 4 or n['type'] == 3 or n['type'] == 1: x.append(n['x'] - morph.soma["x"]) y.append(n['y'] - morph.soma["y"]) z.append(n['z'] - morph.soma["z"]) morph_data = np.array(np.column_stack((x, y, z))) morph_soma = [morph.soma["x"], morph.soma["y"], morph.soma["z"]] return (morph_data, morph_soma)
# In[9]: import matplotlib.pyplot as plt # In[10]: single_cell_morphology.soma # Note that the type field refers to the type of neuronal compartment. The values can be 1 for the soma, 2 for the axon, 3 for dendrites, and 4 for apical dendrites (if present). # Morphologies now also come with marker files, which contains points of interest in the reconstruction. The marker file contains locations where dendrites have been truncated due to slicing and when axons were not reconstructed. The name field indicates the type of marker (10 for dendrite truncation, 20 for no reconstruction). # In[11]: markers = ctc.get_reconstruction_markers(cell_id) markers # In[12]: # Import necessary toolbox from allensdk.core.swc import Marker # Set up our plot fig, axes = plt.subplots(1, 2, sharey=True, sharex=True, figsize=(10, 10)) axes[0].set_aspect('equal') axes[1].set_aspect('equal') # Make a line drawing of x-y and y-z views for n in single_cell_morphology.compartment_list: for c in single_cell_morphology.children_of(n):