A count of the total number of mitochondria within the bounds (694×1794, 1750×2460, 1004×1379).
In [1]:
import ndio.remote.neurodata as neurodata
nd = neurodata()
In [2]:
token_mito = "kasthuri2015_ramon_v4"
channel_mito = 'mitochondria'
We can count annotated mitochondria by referencing the mitochondria
channel:
In [3]:
'''
Mitochondria count
A count of the total number of mitochondria within the bounds (694×1794, 1750×2460, 1004×1379).
'''
import numpy as np
from datetime import datetime
startTime = datetime.now()
# Get cylinder 1 mask
token_green = 'kat11greencylinder'
token_red = 'kat11redcylinder'
token_mojo = 'kat11mojocylinder'
channel = 'annotation'
res = 3
pixel_dim = 0.003*(2**res)*0.003*(2**res)*0.030 #can get from LIMS
imsize = nd.get_image_size(token_red, resolution=res)
offset = nd.get_image_offset(token_red, resolution=res)
# Known bounds - TODO get from LIMS
xbox = [694,1794];
ybox = [1750, 2460];
zbox = [1004, 1379];
# Get mitochondria in "core region"
mask = nd.get_volume(token_red, channel, xbox[0],xbox[1],ybox[0],ybox[1],zbox[0],zbox[1],resolution=res)
# count unique mitochondria - TODO - split apart different labels
In [4]:
mito = nd.get_volume(token_mito, channel_mito, xbox[0],xbox[1],ybox[0],ybox[1],zbox[0],zbox[1],resolution=res)
# Mask volume
mito.cutout[mask.cutout == 0] = 0
In [5]:
mito_id = np.unique(mito.cutout) - 1 #to account for bg
import pylab as plt
%matplotlib inline
plt.imshow(mito.cutout[:,:,100].T)
plt.show()
print 'Total number of mitochondria in cylinder 1 is: ' + str(len(mito_id))
In [6]:
# Get all dendrite source data and mask it (following code examples above)
import ndio.ramon as ramon
import time
import ndio
start = time.time()
token = 'kasthuri2015_ramon_v4'
channel = 'neurons'
res = 3
id_segment = nd.get_ramon_ids(token, channel, ramon_type=ramon.RAMONSegment)
id_neuron = nd.get_ramon_ids(token, channel, ramon_type=ramon.RAMONNeuron)
print 'Number of RAMON segments (unique objects) is: ' + str(len(id_segment))
print 'In the 3 volume cylinder we identified {} (RAMON) neurons'.format(len(id_neuron))
# Retrieve metadata for all objects
# Get all segments
channel = 'neurons'
segAll = nd.get_ramon(token,channel,id_segment)
print '\ntime elapsed so far: ' + str(time.time()-start)
# Mask masked volume for 1) inhib dendrites 2) excitatory dendrites - see claim 12
# count mito in 1) and 2) by voxel and by percentage
In [7]:
'''
Count Dendrite Things
'''
# TODO: Maybe count difference based on cylinder of interest
dendrite_neurites = []
dendrite_neurons = []
dendrite_excitatory_neurites = []
dendrite_smooth_neurites = []
spine = 0
spine_id = []
for x in segAll:
if x.segmentclass == 2:
dendrite_neurites.append(x.id)
dendrite_neurons.append(x.neuron)
if x.kvpairs['segment_subtype'] == 'spiny':
dendrite_excitatory_neurites.append(x.id)
if x.kvpairs['segment_subtype'] == 'smooth':
dendrite_smooth_neurites.append(x.id)
if x.kvpairs['is_spine'] is '1':
spine += 1
spine_id.append(x.id)
In [8]:
segdata = nd.get_cutout(token, channel, xbox[0],xbox[1],ybox[0],ybox[1],zbox[0],zbox[1],resolution=res)
def ismember(A, B):
return [ np.sum(a == B) for a in A ]
segAll[mask == 0] = 0
excitatory_mask = ismember(dendrite_excitatory_neurites,segdata)
inhibitory_mask = ismember(dendrite_smooth_neurites,segdata)
spine_mask = ismember(spine_id,segAll)
In [9]:
print spine_mask
'''
Mitochondria occupy twice as much volume in inhibitory dendrites than in excitatory dendrites
(only in cylinder 1)
'''
plt.imshow(segdata[:,:,100].T)
plt.show()
'''
Only very rarely (n = 3/1,425) do mitochondria reside in dendritic spines
'''
# Get all spines (see claim 12)
# Get all data and mask it (following code examples above)
# Mask masked volume for spines
# For each spine is there a mito? How many total spines?
#print '3/1425'
Out[9]:
In [10]:
print "There are {} mitochondria total in the annotated volume.".format(len(mito_id))
In [ ]: