0

我是 AllenSDK 代码的初学者。我按照他们网站上报告的安装程序安装了所有相关的依赖项。我尝试按照https://alleninstitute.github.io/AllenSDK/glif_models.html中报告的内容构建一个简单的代码示例。我的测试代码如下

#---------------------------
#1° DOWNLOAD OF THE DATA
#---------------------------
from allensdk.api.queries.glif_api import GlifApi
from allensdk.core.cell_types_cache import CellTypesCache
import allensdk.core.json_utilities as json_utilities

neuronal_model_id = 566302806

# download model metadata
glif_api = GlifApi()
nm = glif_api.get_neuronal_models_by_id([neuronal_model_id])[0]

# download the model configuration file
nc = glif_api.get_neuron_configs([neuronal_model_id])[neuronal_model_id]
neuron_config = glif_api.get_neuron_configs([neuronal_model_id])
json_utilities.write('neuron_config.json', neuron_config)

# download information about the cell
ctc = CellTypesCache()
ctc.get_ephys_data(nm['specimen_id'], file_name='stimulus.nwb')
ctc.get_ephys_sweeps(nm['specimen_id'], file_name='ephys_sweeps.json')
#------------------------------------------------------------------------

#------------------------------
#2° RUNNING A GLIF SIMULATION
#------------------------------
import allensdk.core.json_utilities as json_utilities
from allensdk.model.glif.glif_neuron import GlifNeuron

# initialize the neuron
neuron_config = json_utilities.read('neuron_config.json')['566302806']
neuron = GlifNeuron.from_dict(neuron_config)

# make a short square pulse. stimulus units should be in Amps.
stimulus = [ 0.0 ] * 100 + [ 10e-9 ] * 100 + [ 0.0 ] * 100

# important! set the neuron's dt value for your stimulus in seconds
neuron.dt = 5e-6

# simulate the neuron
output = neuron.run(stimulus)

voltage = output['voltage']
threshold = output['threshold']
spike_times = output['interpolated_spike_times']

#-------------------------------
#3° SIMULATE THE MODEL'S TRACES
#-------------------------------
import allensdk.core.json_utilities as json_utilities

from allensdk.model.glif.glif_neuron import GlifNeuron
from allensdk.model.glif.simulate_neuron import simulate_neuron

neuron_config = json_utilities.read('neuron_config.json')['566302806']
ephys_sweeps = json_utilities.read('ephys_sweeps.json')
ephys_file_name = 'stimulus.nwb'

neuron = GlifNeuron.from_dict(neuron_config)

sweep_numbers = [ s['sweep_number'] for s in ephys_sweeps if s['stimulus_units'] == 'Amps' ]
sweep_numbers = sweep_numbers[:2] # for the sake of a speedy example, just run the first one
simulate_neuron(neuron, sweep_numbers, ephys_file_name, ephys_file_name, 0.05)

代码似乎有效,但只有最后一行给了我以下错误

WARNING:root:Failed to load sweep, skipping. ('Dataset' object has no attribute 'value')
Traceback (most recent call last):
  File "/Users/vittoriodefalco/Desktop/GLIF/prova.py", line 64, in <module>
    simulate_neuron(neuron, sweep_numbers, ephys_file_name, ephys_file_name, 0.05)
  File "/usr/local/lib/python3.9/site-packages/allensdk/model/glif/simulate_neuron.py", line 131, in simulate_neuron
    simulate_sweep_from_file(neuron, sweep_number, input_file_name, output_file_name, spike_cut_value)
  File "/usr/local/lib/python3.9/site-packages/allensdk/model/glif/simulate_neuron.py", line 112, in simulate_sweep_from_file
    data = load_sweep(input_file_name, sweep_number)
  File "/usr/local/lib/python3.9/site-packages/allensdk/model/glif/simulate_neuron.py", line 85, in load_sweep
    data = NwbDataSet(file_name).get_sweep(sweep_number)
  File "/usr/local/lib/python3.9/site-packages/allensdk/core/nwb_data_set.py", line 108, in get_sweep
    stimulus = stimulus_dataset.value

我已经安装了 Python (3.9.5) 和 h5py (3.1.0)。你能帮我解决这个错误吗?

4

0 回答 0