Example #1
0
 def test_spike_times(self):
     expected = [
         2.937305,   3.16453 ,   3.24271 ,   4.1622  ,   4.24182 ,
         10.0898  ,  10.132545,  10.176095,  10.2361  ,  10.660655,
         10.762125,  10.863465,  10.93833 ,  11.140815,  11.19246 ,
         11.24553 ,  11.696305,  11.812655,  11.90469 ,  12.056755,
         12.15794 ,  12.233905,  12.47577 ,  12.741295,  12.82861 ,
         12.923175,  18.05068 ,  18.139875,  18.17693 ,  18.221485,
         18.24337 ,  18.39981 ,  18.470705,  18.759675,  18.82183 ,
         18.877475,  18.91033 ,  18.941195,  19.050515,  19.12557 ,
         19.15963 ,  19.188655,  19.226205,  19.29813 ,  19.420665,
         19.47627 ,  19.763365,  19.824225,  19.897995,  19.93155 ,
         20.04916 ,  20.11832 ,  20.148755,  20.18004 ,  20.22173 ,
         20.2433  ,  20.40018 ,  20.470915,  20.759715,  20.82156 ,
         20.866465,  20.90807 ,  20.939175]
     
     bp = BiophysicalPerisomaticApi('http://api.brain-map.org')
     bp.cache_stimulus = True # change to False to not download the large stimulus NWB file
     neuronal_model_id = 472451419    # get this from the web site as above
     bp.cache_data(neuronal_model_id, working_directory='neuronal_model')
     cwd = os.path.realpath(os.curdir)
     print(cwd)
     os.chdir(os.path.join(cwd, 'neuronal_model'))
     manifest = ju.read('manifest.json')
     manifest['biophys'][0]['model_file'][0] = 'manifest_51.json'
     manifest['runs'][0]['sweeps'] = [51]
     ju.write('manifest_51.json', manifest)
     subprocess.call(['nrnivmodl', './modfiles'])
     run(Config().load('manifest_51.json'))
     #os.chdir(cwd)
     nwb_out = NwbDataSet('work/386049444.nwb')
     spikes = nwb_out.get_spike_times(51)
     
     numpy.testing.assert_array_almost_equal(spikes, expected)
Example #2
0
# open up a list of all of the experiments
all_experiments = mcc.get_experiments(dataframe=True)


from allensdk.api.queries.biophysical_perisomatic_api import \
    BiophysicalPerisomaticApi

from allensdk.api.queries.cell_types_api import CellTypesApi
import allensdk.core.swc as swc
import os
from allensdk.core.nwb_data_set import NwbDataSet
from IPython import __main__


bp = BiophysicalPerisomaticApi('http://api.brain-map.org')

ct = CellTypesApi()
cells = ct.list_cells()


#Below is one way, I can create URL, queries and get the result in a local python dictionary.
import allensdk 
import mpi4py as MPI
import numpy as np
import csv
import pickle
import sys
#import glob

def __main__():
from allensdk.api.queries.biophysical_perisomatic_api import \
    BiophysicalPerisomaticApi

bp = BiophysicalPerisomaticApi('http://api.brain-map.org')
bp.cache_stimulus = True # change to False to not download the large stimulus NWB file
neuronal_model_id = 472451419    # get this from the web site as above
bp.cache_data(neuronal_model_id, working_directory='neuronal_model')
from allensdk.api.queries.biophysical_perisomatic_api import BiophysicalPerisomaticApi

neuronal_model_ids = [472300877, 472363762, 472442377, 473561660, 473863035, 473561729, 472421285, 472301074, \
                      473872986, 472306616, 329321704, 472912107, 472352327, 471085845, 472912177, 472304676, \
                      473860269, 472447460, 472427533, 472304539, 473465774, 472430904, 473862845, 472450023, \
                      473862496, 473863578, 473871773, 329322394, 472299363, 472455509, 472349114, 471081668, \
                      472451419, 471087975, 472424854, 473863510, 473871592, 472299294, 473835796, 473871429, \
                      473465456, 472306460, 472440759, 472434498, 472915634, 472306544, 473862421, 471086533, \
                      473834758]

#neuronal_model_ids = [472451419]

print("---- Downloading %i cell models..." % len(neuronal_model_ids))

for neuronal_model_id in neuronal_model_ids:
    print("---- Downloading cell model: %s..." % neuronal_model_id)
    try:

        bp = BiophysicalPerisomaticApi('http://api.brain-map.org')
        bp.cache_stimulus = False  # change to False to not download the large stimulus NWB file
        bp.cache_data(neuronal_model_id,
                      working_directory='%i' % neuronal_model_id)
    except IndexError:
        print("Problem!")