In [1]:
drive_path = '/home/kameron/work/allen/data/sdk_new_100'
import os
from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache
# When downloading 3D connectivity data volumes, what resolution do you want (in microns)?
# Options are: 10, 25, 50, 100
resolution_um=100
# The manifest file is a simple JSON file that keeps track of all of
# the data that has already been downloaded onto the hard drives.
# If you supply a relative path, it is assumed to be relative to your
# current working directory.
manifest_file = os.path.join(drive_path, "manifest.json")
mcc = MouseConnectivityCache(manifest_file=manifest_file, resolution=resolution_um)
# open up a pandas dataframe of all of the experiments
all_experiments = mcc.get_experiments(dataframe=True)
print "%d total experiments" % len(all_experiments)
# take a look at what we know about an experiment with a primary motor injection
all_experiments.loc[122642490]
Out[1]:
In [2]:
import allensdk
In [3]:
help(mcc.get_experiments)
In [4]:
#stree = mcc.get_structure_tree()
In [5]:
# grab the Ontology instance
ontology = mcc.get_ontology()
# get some info on the isocortex
isocortex = ontology['Isocortex']
isocortex_mask, _ = mcc.get_structure_mask(isocortex['id'])
In [6]:
import numpy as np
np.sum(isocortex_mask)
Out[6]:
In [7]:
help(np.repeat)
In [9]:
import h5py
vi = h5py.File(r'/home/kameron/work/allen/data/ccf_2017/dorsal_flatmap_paths_10.h5', 'r')
lut = vi['view lookup'][:]
paths = vi['paths'][:]
vi.close()
In [10]:
print lut.max()
print lut.shape
print paths.max()
print paths.shape
In [10]:
experiment_id = 181599674
# projection density: number of projecting pixels / voxel volume
pd, pd_info = mcc.get_projection_density(experiment_id)
In [11]:
pd_info
Out[11]:
In [12]:
pd.shape
Out[12]:
In [13]:
from skimage.transform import rescale
test = rescale(pd, 10, order=0)
test.shape
Out[13]:
In [14]:
from scipy.ndimage import zoom
pdrep = zoom(pd,10,order=0)
In [16]:
import skimage
skimage.__version__
Out[16]:
In [15]:
pdrep.shape
Out[15]:
In [17]:
132*80*114*10**3
Out[17]:
In [18]:
# calculate output array
output_pd = np.zeros(lut.shape, dtype=pdrep.dtype)
# all pixels in surface view with a stream line
ind = np.where(lut > -1)
ind = zip(ind[0], ind[1])
for curr_ind in ind:
curr_path_id = lut[curr_ind]
curr_path = paths[curr_path_id, :]
curr_pd_line = pdrep.flat[curr_path]
curr_max_ind = curr_path[np.argmax(curr_pd_line)]
output_pd[curr_ind] = pdrep.flat[curr_max_ind]
In [20]:
import matplotlib.pyplot as plt
plt.imshow(output_pd)
plt.show()
In [23]:
drive_path = '/home/kameron/work/allen/data/sdk_new_10'
# When downloading 3D connectivity data volumes, what resolution do you want (in microns)?
# Options are: 10, 25, 50, 100
resolution_um=10
# The manifest file is a simple JSON file that keeps track of all of
# the data that has already been downloaded onto the hard drives.
# If you supply a relative path, it is assumed to be relative to your
# current working directory.
manifest_file = os.path.join(drive_path, "manifest.json")
mcc10 = MouseConnectivityCache(manifest_file=manifest_file, resolution=resolution_um)
In [ ]:
experiment_id = 181599674
# projection density: number of projecting pixels / voxel volume
pd, pd_info = mcc10.get_projection_density(experiment_id)
In [ ]:
pd.shape
In [ ]:
pd.dtype
In [ ]:
pd_info
In [ ]:
# calculate output array
output_pd = np.zeros(lut.shape, dtype=pd.dtype)
# all pixels in surface view with a stream line
ind = np.where(lut > -1)
ind = zip(ind[0], ind[1])
for curr_ind in ind:
curr_path_id = lut[curr_ind]
curr_path = paths[curr_path_id, :]
curr_pd_line = pd.flat[curr_path]
curr_max_ind = curr_path[np.argmax(curr_pd_line)]
output_pd[curr_ind] = pd.flat[curr_max_ind]
In [ ]:
import matplotlib.pyplot as plt
plt.imshow(output_pd)
In [ ]:
plt.show()