def read_spiketrain(self, cluster_id, model,
lazy=False,
cascade=True,
get_waveforms=True,
):
"""
Reads sorted spiketrains
Parameters:
get_waveforms: bool, default = False
Wether or not to get the waveforms
cluster_id: int,
Which cluster to load, according to cluster id from klusta
model: klusta.kwik.KwikModel
A KwikModel object obtained by klusta.kwik.KwikModel(fname)
"""
try:
if ((not(cluster_id in model.cluster_ids))):
raise ValueError
except ValueError:
print("Exception: cluster_id (%d) not found !! " % cluster_id)
return
clusters = model.spike_clusters
idx = np.argwhere(clusters == cluster_id)
if get_waveforms:
w = model.all_waveforms[idx]
# klusta: num_spikes, samples_per_spike, num_chans = w.shape
w = w.swapaxes(1, 2)
else:
w = None
sptr = SpikeTrain(times=model.spike_times[idx],
t_stop=model.duration, waveforms=w, units='s',
sampling_rate=model.sample_rate*pq.Hz,
file_origin=self.filename,
**{'cluster_id': cluster_id})
return sptr
评论列表
文章目录