In [6]:
import os
from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache
import numpy as np
import h5py
import time
import nrrd
drive_path = os.path.join(os.getenv('HOME'), 'work/allen/data/sdk_new_100')
# When downloading 3D connectivity data volumes, what resolution do you want (in microns)?
# Options are: 10, 25, 50, 100
resolution_um=10
# Downsampling factor
stride = 4
# 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")
# Start processing data
mcc = MouseConnectivityCache(manifest_file = manifest_file,
resolution = resolution_um)
ontology = mcc.get_ontology()
# Injection structure of interest
isocortex = ontology['Isocortex']
# open up a pandas dataframe of all of the experiments
experiments = mcc.get_experiments(dataframe = True,
injection_structure_ids = [isocortex['id'].values[0]],
cre = False)
print "%d total experiments" % len(experiments)
def downsample(arr, stride):
assert type(stride) is int, "stride should be integer"
return arr[0::stride, 0::stride]
/home/kamdh/anaconda2/lib/python2.7/site-packages/ipykernel_launcher.py:26: VisibleDeprecationWarning: Function get_ontology is deprecated. Use get_structure_tree instead.
126 total experiments
In [7]:
## Laplacians
view_paths_fn = os.path.join(os.getenv('HOME'), 'work/allen/data/TopView/top_view_paths_10.h5')
view_paths_file = h5py.File(view_paths_fn, 'r')
view_lut = view_paths_file['view lookup'][:]
view_paths = view_paths_file['paths'][:]
view_paths_file.close()
## Compute size of each path to convert path averages to sums
norm_lut = np.zeros(view_lut.shape, dtype=int)
ind = np.where(view_lut != -1)
ind = zip(ind[0], ind[1])
for curr_ind in ind:
curr_path_id = view_lut[curr_ind]
curr_path = view_paths[curr_path_id, :]
norm_lut[curr_ind] = np.sum(curr_path > 0)
In [8]:
view_lut = downsample(view_lut, stride)
#norm_lut = downsample(norm_lut, stride)
In [9]:
print norm_lut.shape
(1320, 1140)
In [10]:
data_mask = np.where(view_lut != -1)
# Right indices
right = np.zeros(view_lut.shape, dtype=bool)
right[:, int(view_lut.shape[1]/2):] = True
# Right hemisphere data
hemi_R_mask = np.where(np.logical_and(view_lut != -1, right))
# Left hemisphere data
hemi_L_mask = np.where(np.logical_and(view_lut != -1, np.logical_not(right)))
nx = len(hemi_R_mask[0])
ny = len(data_mask[0])
In [11]:
print nx, ny
22377 44478
In [12]:
def laplacian_2d(mask):
'''
Generate the laplacian matrix for a given region's voxels. This is the
graph laplacian of the neighborhood graph.
Parameters
----------
mask
Returns
-------
L: num voxel x num voxel laplacian csc_matrix in same order as voxels
in the region mask
'''
def possible_neighbors(vox):
neighbors = np.tile(vox, (4,1))
neighbors += [[1,0],
[0,1],
[-1,0],
[0,-1]]
return neighbors
import scipy.sparse as sp
voxels = np.array(mask).T
num_vox = len(mask[0])
# num_vox=voxels.shape[0]
vox_lookup = {tuple(vox): idx for idx, vox in enumerate(voxels)}
L = sp.lil_matrix((num_vox, num_vox))
for idx, vox in enumerate(voxels):
candidates = possible_neighbors(vox)
deg = 0
for nei in candidates:
try:
idx_nei = vox_lookup[ tuple(nei) ]
deg += 1
L[idx, idx_nei] = 1
except KeyError:
continue
L[idx, idx] = -deg
return L.tocsc()
In [13]:
Lx = laplacian_2d(hemi_R_mask)
Ly = laplacian_2d(data_mask)
print Ly.shape
print Ly.nnz
print ny
(44478, 44478)
221328
44478
In [ ]:
X = np.zeros((nx, len(experiments)))
Y = np.zeros((ny, len(experiments)))
Omega = np.zeros((ny, len(experiments)))
expt_drop_list = []
t0 = time.time()
#eid = experiments.iloc[5].id
#row = experiments.iloc[5]
index = 0
for eid, row in experiments.iterrows():
print "\nRow %d\nProcessing experiment %d" % (index,eid)
print row
data_dir = os.path.join(os.getenv('HOME'),
"work/allen/data/sdk_new_100/experiment_%d/" % eid)
# get and remap injection data
in_fn = data_dir + "injection_density_top_view_%d.nrrd" % int(resolution_um)
print "reading " + in_fn
in_d_s_full = nrrd.read(in_fn)[0]
flat_vol = np.nansum(in_d_s_full * norm_lut) * (10./1000.)**3
expt_union = mcc.get_experiment_structure_unionizes(eid, hemisphere_ids = [3], is_injection = True,
structure_ids = [isocortex['id'].values[0]])
full_vol = float(expt_union['projection_volume'])
in_d_s = downsample(in_d_s_full, stride)
# get and remap projection data
pr_fn = data_dir + "projection_density_top_view_%d.nrrd" % int(resolution_um)
print "reading " + pr_fn
pr_d_s = downsample(nrrd.read(pr_fn)[0], stride)
# fill matrices
X[:, index] = in_d_s[hemi_R_mask]
Y[:, index] = pr_d_s[data_mask]
this_Omega = (in_d_s[data_mask] > Omega_thresh).astype(int)
Omega[:, index] = this_Omega
# drop experiments without much injection volume
if np.abs(flat_vol - full_vol) / full_vol * 100 > volume_fraction:
print "warning, dropping experiment"
print "flat_vol = %f\nfull_vol = %f" % (flat_vol, full_vol)
expt_drop_list.append(index)
index += 1
t1 = time.time()
total = t1 - t0
print "%0.1f minutes elapsed" % (total/60.)
Row 0
Processing experiment 180435652
gender M
id 180435652
injection-coordinates [7820, 4250, 9870]
injection-structures [{u'abbreviation': u'TEa', u'color': u'15B0B3'...
product-id 5
strain C57BL/6J
structure-abbrev ECT
structure-color 0D9F91
structure-id 895
structure-name Ectorhinal area
transgenic-line
Name: 180435652, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180435652/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180435652/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.007292
full_vol = 1.010350
Row 1
Processing experiment 180436360
gender M
id 180436360
injection-coordinates [4800, 4720, 8980]
injection-structures [{u'abbreviation': u'AId', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev VISC
structure-color 11AD83
structure-id 677
structure-name Visceral area
transgenic-line
Name: 180436360, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180436360/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180436360/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.017682
full_vol = 1.128610
Row 2
Processing experiment 180719293
gender M
id 180719293
injection-coordinates [3140, 3330, 7390]
injection-structures [{u'abbreviation': u'AId', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 180719293, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180719293/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180719293/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.320894
full_vol = 1.081620
Row 3
Processing experiment 180709942
gender M
id 180709942
injection-coordinates [3360, 3120, 7520]
injection-structures [{u'abbreviation': u'MOp', u'color': u'1F9D5A'...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 180709942, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180709942/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180709942/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.250544
full_vol = 0.793079
Row 4
Processing experiment 180917660
gender M
id 180917660
injection-coordinates [5570, 4540, 9540]
injection-structures [{u'abbreviation': u'AIp', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev VISC
structure-color 11AD83
structure-id 677
structure-name Visceral area
transgenic-line
Name: 180917660, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180917660/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180917660/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.006089
full_vol = 1.295040
Row 5
Processing experiment 180916954
gender M
id 180916954
injection-coordinates [4800, 1220, 5930]
injection-structures [{u'abbreviation': u'ACAd', u'color': u'40A666...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 180916954, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180916954/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180916954/projection_density_top_view_10.nrrd
Row 6
Processing experiment 100141780
gender M
id 100141780
injection-coordinates [4070, 2600, 7500]
injection-structures [{u'abbreviation': u'MOp', u'color': u'1F9D5A'...
product-id 5
strain C57BL/6J
structure-abbrev MOp
structure-color 1F9D5A
structure-id 985
structure-name Primary motor area
transgenic-line
Name: 100141780, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100141780/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100141780/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.124878
full_vol = 0.195324
Row 7
Processing experiment 180720175
gender M
id 180720175
injection-coordinates [5710, 670, 6420]
injection-structures [{u'abbreviation': u'SSp-ll', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev MOp
structure-color 1F9D5A
structure-id 985
structure-name Primary motor area
transgenic-line
Name: 180720175, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180720175/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180720175/projection_density_top_view_10.nrrd
Row 8
Processing experiment 180717881
gender M
id 180717881
injection-coordinates [4580, 3610, 8670]
injection-structures [{u'abbreviation': u'SSp-m', u'color': u'18806...
product-id 5
strain C57BL/6J
structure-abbrev SSp-m
structure-color 188064
structure-id 345
structure-name Primary somatosensory area, mouth
transgenic-line
Name: 180717881, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180717881/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180717881/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.061807
full_vol = 1.020160
Row 9
Processing experiment 127084296
gender M
id 127084296
injection-coordinates [4880, 1800, 6920]
injection-structures [{u'abbreviation': u'MOp', u'color': u'1F9D5A'...
product-id 5
strain C57BL/6J
structure-abbrev MOp
structure-color 1F9D5A
structure-id 985
structure-name Primary motor area
transgenic-line
Name: 127084296, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_127084296/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_127084296/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.217949
full_vol = 0.335456
Row 10
Processing experiment 112306316
gender M
id 112306316
injection-coordinates [3000, 3600, 6690]
injection-structures [{u'abbreviation': u'FRP', u'color': u'268F45'...
product-id 5
strain C57BL/6J
structure-abbrev ORBl
structure-color 248A5E
structure-id 723
structure-name Orbital area, lateral part
transgenic-line
Name: 112306316, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112306316/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112306316/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.000000
full_vol = 0.316564
Row 11
Processing experiment 180709230
gender M
id 180709230
injection-coordinates [2360, 3870, 7100]
injection-structures [{u'abbreviation': u'AId', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev ORBl
structure-color 248A5E
structure-id 723
structure-name Orbital area, lateral part
transgenic-line
Name: 180709230, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180709230/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180709230/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.000000
full_vol = 0.650687
Row 12
Processing experiment 180074890
gender M
id 180074890
injection-coordinates [6760, 4320, 9510]
injection-structures [{u'abbreviation': u'AIp', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev VISC
structure-color 11AD83
structure-id 677
structure-name Visceral area
transgenic-line
Name: 180074890, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180074890/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180074890/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.003745
full_vol = 0.390115
Row 13
Processing experiment 112952510
gender M
id 112952510
injection-coordinates [3430, 1930, 6140]
injection-structures [{u'abbreviation': u'ACAd', u'color': u'40A666...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 112952510, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112952510/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112952510/projection_density_top_view_10.nrrd
Row 14
Processing experiment 112596790
gender M
id 112596790
injection-coordinates [3840, 4160, 8250]
injection-structures [{u'abbreviation': u'AId', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev AId
structure-color 219866
structure-id 104
structure-name Agranular insular area, dorsal part
transgenic-line
Name: 112596790, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112596790/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112596790/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.000000
full_vol = 0.397903
Row 15
Processing experiment 112951804
gender M
id 112951804
injection-coordinates [6890, 2260, 8670]
injection-structures [{u'abbreviation': u'SSp-bfd', u'color': u'188...
product-id 5
strain C57BL/6J
structure-abbrev SSp-bfd
structure-color 188064
structure-id 329
structure-name Primary somatosensory area, barrel field
transgenic-line
Name: 112951804, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112951804/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112951804/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.185936
full_vol = 0.388083
Row 16
Processing experiment 141603190
gender M
id 141603190
injection-coordinates [4100, 1810, 6110]
injection-structures [{u'abbreviation': u'ACAd', u'color': u'40A666...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 141603190, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_141603190/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_141603190/projection_density_top_view_10.nrrd
Row 17
Processing experiment 180718587
gender M
id 180718587
injection-coordinates [5200, 1310, 7300]
injection-structures [{u'abbreviation': u'SSp-ll', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev SSp-ul
structure-color 188064
structure-id 369
structure-name Primary somatosensory area, upper limb
transgenic-line
Name: 180718587, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180718587/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180718587/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.651254
full_vol = 1.020620
Row 18
Processing experiment 113036264
gender M
id 113036264
injection-coordinates [5600, 3510, 9100]
injection-structures [{u'abbreviation': u'SSp-m', u'color': u'18806...
product-id 5
strain C57BL/6J
structure-abbrev SSs
structure-color 188064
structure-id 378
structure-name Supplemental somatosensory area
transgenic-line
Name: 113036264, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_113036264/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_113036264/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.066885
full_vol = 0.557927
Row 19
Processing experiment 100141796
gender M
id 100141796
injection-coordinates [9370, 2450, 9080]
injection-structures [{u'abbreviation': u'VISl', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISli
structure-color 08858C
structure-id 312782574
structure-name Laterointermediate area
transgenic-line
Name: 100141796, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100141796/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100141796/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.053267
full_vol = 0.178449
Row 20
Processing experiment 112514915
gender M
id 112514915
injection-coordinates [6600, 3010, 9160]
injection-structures [{u'abbreviation': u'SSp-bfd', u'color': u'188...
product-id 5
strain C57BL/6J
structure-abbrev SSs
structure-color 188064
structure-id 378
structure-name Supplemental somatosensory area
transgenic-line
Name: 112514915, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112514915/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112514915/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.062696
full_vol = 0.300054
Row 21
Processing experiment 146593590
gender M
id 146593590
injection-coordinates [5180, 1790, 5800]
injection-structures [{u'abbreviation': u'ACAd', u'color': u'40A666...
product-id 5
strain C57BL/6J
structure-abbrev ACAd
structure-color 40A666
structure-id 39
structure-name Anterior cingulate area, dorsal part
transgenic-line
Name: 146593590, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_146593590/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_146593590/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.028970
full_vol = 0.177222
Row 22
Processing experiment 180296424
gender M
id 180296424
injection-coordinates [9570, 1750, 8510]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 180296424, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180296424/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_180296424/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.281138
full_vol = 0.798705
Row 23
Processing experiment 117298988
gender M
id 117298988
injection-coordinates [6140, 3530, 9340]
injection-structures [{u'abbreviation': u'SSs', u'color': u'188064'...
product-id 5
strain C57BL/6J
structure-abbrev SSs
structure-color 188064
structure-id 378
structure-name Supplemental somatosensory area
transgenic-line
Name: 117298988, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_117298988/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_117298988/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.043328
full_vol = 0.389740
Row 24
Processing experiment 170721670
gender M
id 170721670
injection-coordinates [2410, 3150, 6820]
injection-structures [{u'abbreviation': u'AOB', u'color': u'9DF0D2'...
product-id 5
strain C57BL/6J
structure-abbrev ORBl
structure-color 248A5E
structure-id 723
structure-name Orbital area, lateral part
transgenic-line
Name: 170721670, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_170721670/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_170721670/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.000001
full_vol = 0.204924
Row 25
Processing experiment 157710335
gender M
id 157710335
injection-coordinates [2440, 2750, 7050]
injection-structures [{u'abbreviation': u'FRP', u'color': u'268F45'...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 157710335, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_157710335/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_157710335/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.046751
full_vol = 0.126339
Row 26
Processing experiment 126907302
gender M
id 126907302
injection-coordinates [7210, 1280, 8030]
injection-structures [{u'abbreviation': u'SSp-bfd', u'color': u'188...
product-id 5
strain C57BL/6J
structure-abbrev SSp-bfd
structure-color 188064
structure-id 329
structure-name Primary somatosensory area, barrel field
transgenic-line
Name: 126907302, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126907302/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126907302/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.272996
full_vol = 0.571541
Row 27
Processing experiment 126861679
gender M
id 126861679
injection-coordinates [7450, 910, 7080]
injection-structures [{u'abbreviation': u'VISam', u'color': u'08858...
product-id 5
strain C57BL/6J
structure-abbrev VISam
structure-color 08858C
structure-id 394
structure-name Anteromedial visual area
transgenic-line
Name: 126861679, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126861679/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126861679/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.081876
full_vol = 0.168900
Row 28
Processing experiment 127089669
gender M
id 127089669
injection-coordinates [9270, 2930, 9310]
injection-structures [{u'abbreviation': u'SUB', u'color': u'4FC244'...
product-id 5
strain C57BL/6J
structure-abbrev VISpor
structure-color 08858C
structure-id 312782628
structure-name Postrhinal area
transgenic-line
Name: 127089669, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_127089669/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_127089669/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.089955
full_vol = 0.342804
Row 29
Processing experiment 141602484
gender M
id 141602484
injection-coordinates [4030, 1830, 7090]
injection-structures [{u'abbreviation': u'MOp', u'color': u'1F9D5A'...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 141602484, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_141602484/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_141602484/projection_density_top_view_10.nrrd
Row 30
Processing experiment 174361746
gender M
id 174361746
injection-coordinates [6330, 4620, 9560]
injection-structures [{u'abbreviation': u'AIp', u'color': u'219866'...
product-id 5
strain C57BL/6J
structure-abbrev VISC
structure-color 11AD83
structure-id 677
structure-name Visceral area
transgenic-line
Name: 174361746, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_174361746/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_174361746/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.004987
full_vol = 0.441243
Row 31
Processing experiment 309004492
gender M
id 309004492
injection-coordinates [9200, 1720, 8330]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 309004492, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_309004492/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_309004492/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.400143
full_vol = 1.064930
Row 32
Processing experiment 126909424
gender M
id 126909424
injection-coordinates [4950, 2050, 7500]
injection-structures [{u'abbreviation': u'SSp-ul', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev MOp
structure-color 1F9D5A
structure-id 985
structure-name Primary motor area
transgenic-line
Name: 126909424, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126909424/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126909424/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.173941
full_vol = 0.305395
Row 33
Processing experiment 100142655
gender M
id 100142655
injection-coordinates [6750, 1490, 7940]
injection-structures [{u'abbreviation': u'SSp-bfd', u'color': u'188...
product-id 5
strain C57BL/6J
structure-abbrev SSp-bfd
structure-color 188064
structure-id 329
structure-name Primary somatosensory area, barrel field
transgenic-line
Name: 100142655, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100142655/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100142655/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.097064
full_vol = 0.175529
Row 34
Processing experiment 112514202
gender M
id 112514202
injection-coordinates [4250, 2450, 5860]
injection-structures [{u'abbreviation': u'ACAd', u'color': u'40A666...
product-id 5
strain C57BL/6J
structure-abbrev ACAv
structure-color 40A666
structure-id 48
structure-name Anterior cingulate area, ventral part
transgenic-line
Name: 112514202, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112514202/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112514202/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.025792
full_vol = 0.222342
Row 35
Processing experiment 115958825
gender M
id 115958825
injection-coordinates [8100, 2190, 9290]
injection-structures [{u'abbreviation': u'VISal', u'color': u'08858...
product-id 5
strain C57BL/6J
structure-abbrev AUDpo
structure-color 019399
structure-id 1027
structure-name Posterior auditory area
transgenic-line
Name: 115958825, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_115958825/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_115958825/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.076351
full_vol = 0.205175
Row 36
Processing experiment 157654817
gender M
id 157654817
injection-coordinates [4510, 3380, 8580]
injection-structures [{u'abbreviation': u'SSp-m', u'color': u'18806...
product-id 5
strain C57BL/6J
structure-abbrev SSp-m
structure-color 188064
structure-id 345
structure-name Primary somatosensory area, mouth
transgenic-line
Name: 157654817, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_157654817/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_157654817/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.027077
full_vol = 0.138265
Row 37
Processing experiment 100141599
gender M
id 100141599
injection-coordinates [8150, 740, 7090]
injection-structures [{u'abbreviation': u'VISam', u'color': u'08858...
product-id 5
strain C57BL/6J
structure-abbrev VISam
structure-color 08858C
structure-id 394
structure-name Anteromedial visual area
transgenic-line
Name: 100141599, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100141599/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_100141599/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.061756
full_vol = 0.125485
Row 38
Processing experiment 127866392
gender M
id 127866392
injection-coordinates [7070, 2150, 8900]
injection-structures [{u'abbreviation': u'SSp-bfd', u'color': u'188...
product-id 5
strain C57BL/6J
structure-abbrev SSp-bfd
structure-color 188064
structure-id 329
structure-name Primary somatosensory area, barrel field
transgenic-line
Name: 127866392, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_127866392/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_127866392/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.082033
full_vol = 0.175440
Row 39
Processing experiment 126860974
gender M
id 126860974
injection-coordinates [2510, 3620, 5710]
injection-structures [{u'abbreviation': u'ORBm', u'color': u'248A5E...
product-id 5
strain C57BL/6J
structure-abbrev ORBm
structure-color 248A5E
structure-id 731
structure-name Orbital area, medial part
transgenic-line
Name: 126860974, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126860974/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126860974/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.004714
full_vol = 0.282686
Row 40
Processing experiment 126852363
gender M
id 126852363
injection-coordinates [6540, 990, 6720]
injection-structures [{u'abbreviation': u'SSp-ll', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev SSp-tr
structure-color 188064
structure-id 361
structure-name Primary somatosensory area, trunk
transgenic-line
Name: 126852363, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126852363/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126852363/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.249758
full_vol = 0.367458
Row 41
Processing experiment 112670853
gender M
id 112670853
injection-coordinates [3230, 2980, 7490]
injection-structures [{u'abbreviation': u'MOp', u'color': u'1F9D5A'...
product-id 5
strain C57BL/6J
structure-abbrev MOs
structure-color 1F9D5A
structure-id 993
structure-name Secondary motor area
transgenic-line
Name: 112670853, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112670853/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112670853/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.276188
full_vol = 0.403681
Row 42
Processing experiment 158314278
gender M
id 158314278
injection-coordinates [7610, 2500, 9320]
injection-structures [{u'abbreviation': u'SSs', u'color': u'188064'...
product-id 5
strain C57BL/6J
structure-abbrev AUDd
structure-color 019399
structure-id 1011
structure-name Dorsal auditory area
transgenic-line
Name: 158314278, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_158314278/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_158314278/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.102000
full_vol = 0.273547
Row 43
Processing experiment 112791318
gender M
id 112791318
injection-coordinates [6370, 1630, 7470]
injection-structures [{u'abbreviation': u'SSp-ll', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev SSp-ll
structure-color 188064
structure-id 337
structure-name Primary somatosensory area, lower limb
transgenic-line
Name: 112791318, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112791318/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112791318/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.267322
full_vol = 0.425096
Row 44
Processing experiment 113887162
gender M
id 113887162
injection-coordinates [8300, 1170, 7870]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 113887162, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_113887162/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_113887162/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.190526
full_vol = 0.407139
Row 45
Processing experiment 307558646
gender M
id 307558646
injection-coordinates [8780, 1390, 7890]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 307558646, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307558646/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307558646/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.478155
full_vol = 1.036020
Row 46
Processing experiment 309372716
gender M
id 309372716
injection-coordinates [8630, 1370, 7810]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 309372716, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_309372716/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_309372716/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.413647
full_vol = 0.893193
Row 47
Processing experiment 114290938
gender M
id 114290938
injection-coordinates [4780, 2770, 8240]
injection-structures [{u'abbreviation': u'SSp-m', u'color': u'18806...
product-id 5
strain C57BL/6J
structure-abbrev SSp-m
structure-color 188064
structure-id 345
structure-name Primary somatosensory area, mouth
transgenic-line
Name: 114290938, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_114290938/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_114290938/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.195886
full_vol = 0.368803
Row 48
Processing experiment 112936582
gender M
id 112936582
injection-coordinates [4660, 2990, 8370]
injection-structures [{u'abbreviation': u'SSp-m', u'color': u'18806...
product-id 5
strain C57BL/6J
structure-abbrev SSp-m
structure-color 188064
structure-id 345
structure-name Primary somatosensory area, mouth
transgenic-line
Name: 112936582, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112936582/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112936582/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.081023
full_vol = 0.178016
Row 49
Processing experiment 114292355
gender M
id 114292355
injection-coordinates [6060, 1270, 6650]
injection-structures [{u'abbreviation': u'SSp-ll', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev SSp-ll
structure-color 188064
structure-id 337
structure-name Primary somatosensory area, lower limb
transgenic-line
Name: 114292355, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_114292355/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_114292355/projection_density_top_view_10.nrrd
Row 50
Processing experiment 112935169
gender M
id 112935169
injection-coordinates [5890, 1300, 6910]
injection-structures [{u'abbreviation': u'SSp-ll', u'color': u'1880...
product-id 5
strain C57BL/6J
structure-abbrev SSp-ll
structure-color 188064
structure-id 337
structure-name Primary somatosensory area, lower limb
transgenic-line
Name: 112935169, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112935169/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112935169/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.146374
full_vol = 0.221911
Row 51
Processing experiment 307137980
gender M
id 307137980
injection-coordinates [8900, 1550, 8130]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 307137980, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307137980/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307137980/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.226466
full_vol = 0.475240
Row 52
Processing experiment 309113907
gender M
id 309113907
injection-coordinates [8690, 1290, 7780]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 309113907, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_309113907/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_309113907/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.363399
full_vol = 0.769987
Row 53
Processing experiment 120437703
gender M
id 120437703
injection-coordinates [8090, 2140, 9230]
injection-structures [{u'abbreviation': u'VISal', u'color': u'08858...
product-id 5
strain C57BL/6J
structure-abbrev VISal
structure-color 08858C
structure-id 402
structure-name Anterolateral visual area
transgenic-line
Name: 120437703, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_120437703/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_120437703/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.042619
full_vol = 0.112727
Row 54
Processing experiment 126908007
gender M
id 126908007
injection-coordinates [5770, 2560, 8500]
injection-structures [{u'abbreviation': u'SSp-n', u'color': u'18806...
product-id 5
strain C57BL/6J
structure-abbrev SSp-n
structure-color 188064
structure-id 353
structure-name Primary somatosensory area, nose
transgenic-line
Name: 126908007, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126908007/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_126908007/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.194973
full_vol = 0.358564
Row 55
Processing experiment 307743253
gender M
id 307743253
injection-coordinates [9010, 1630, 8310]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISp
structure-color 08858C
structure-id 385
structure-name Primary visual area
transgenic-line
Name: 307743253, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307743253/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307743253/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.239092
full_vol = 0.559220
Row 56
Processing experiment 307295727
gender M
id 307295727
injection-coordinates [9380, 1840, 8530]
injection-structures [{u'abbreviation': u'VISp', u'color': u'08858C...
product-id 5
strain C57BL/6J
structure-abbrev VISl
structure-color 08858C
structure-id 409
structure-name Lateral visual area
transgenic-line
Name: 307295727, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307295727/injection_density_top_view_10.nrrd
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_307295727/projection_density_top_view_10.nrrd
warning, dropping experiment
flat_vol = 0.186292
full_vol = 0.518331
Row 57
Processing experiment 112458114
gender M
id 112458114
injection-coordinates [4180, 2040, 5850]
injection-structures [{u'abbreviation': u'ACAd', u'color': u'40A666...
product-id 5
strain C57BL/6J
structure-abbrev ACAd
structure-color 40A666
structure-id 39
structure-name Anterior cingulate area, dorsal part
transgenic-line
Name: 112458114, dtype: object
reading /home/kamdh/work/allen/data/sdk_new_100/experiment_112458114/injection_density_top_view_10.nrrd
In [ ]:
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure(figsize = (20,20))
ax = fig.add_subplot(121)
h = ax.imshow(in_d_s)
fig.colorbar(h)
#fig2 = plt.figure(figsize = (10,10))
ax2 = fig.add_subplot(122)
h2 = ax2.imshow(pr_d_s)
ax2.plot([np.floor(285/2.), np.floor(285/2.)], [0, 330], 'k-', linewidth=0.2 )
#fig2.colorbar(h2)
In [ ]:
vol1 = np.nansum(nrrd.read(in_fn)[0] * norm_lut)
print vol1
vol2 = np.sum(mcc.get_injection_density(eid)[0])
print vol2
print np.abs(vol1 - vol2)/vol2
In [ ]:
tmp = mcc.get_structure_unionizes()
In [ ]:
tmp = downsample(pr_d_s, stride)[hemi_R_mask]
plt.hist( tmp[tmp!=0])
In [ ]:
output_dir = os.path.join(os.getenv('HOME'), 'work/allen/data/2d_test')
from scipy.io import mmwrite
mmwrite(os.path.join(output_dir, "Lx.mtx"), Lx)
mmwrite(os.path.join(output_dir, "Ly.mtx"), Ly)
In [ ]:
expt_union = mcc.get_experiment_structure_unionizes(eid,
hemisphere_ids = [3],
is_injection = True,
structure_ids = [ontology['grey']['id'].values[0]])
In [ ]:
expt_union
In [ ]:
expt_union['projection_volume']
In [ ]:
flat_vol = vol1 * (10/1000.)**3
full_vol = float(expt_union['projection_volume'])
In [ ]:
np.abs(flat_vol - full_vol)/full_vol*100
In [15]:
volume_fraction = 30
Omega_thresh = 0.5
In [ ]:
print len(expt_drop_list)
print len(experiments)
In [19]:
print "drop list: " + str(expt_drop_list)
drop list: [0, 1, 2, 3, 4, 6, 8, 9, 10, 11, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125]
In [22]:
np.array(data_mask).T
Out[22]:
array([[ 46, 109],
[ 46, 110],
[ 46, 111],
...,
[259, 225],
[259, 226],
[259, 227]])
In [24]:
hemi_R_mask
Out[24]:
(array([ 46, 46, 46, ..., 259, 259, 259]),
array([150, 151, 152, ..., 225, 226, 227]))
In [25]:
view_lut
Out[25]:
array([[-1, -1, -1, ..., -1, -1, -1],
[-1, -1, -1, ..., -1, -1, -1],
[-1, -1, -1, ..., -1, -1, -1],
...,
[-1, -1, -1, ..., -1, -1, -1],
[-1, -1, -1, ..., -1, -1, -1],
[-1, -1, -1, ..., -1, -1, -1]], dtype=int32)
In [ ]:
Content source: kharris/allen-voxel-network
Similar notebooks: