Skip to content

Commit

Permalink
Merge pull request #205 from catalystneuro/small_pr_to_remove_spikeex…
Browse files Browse the repository at this point in the history
…tractors

Make `toy_example.py` dependency on spikeextractors clearer
  • Loading branch information
CodyCBakerPhD authored Aug 31, 2022
2 parents f8c51f0 + e88468a commit 5b74133
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/roiextractors/example_datasets/toy_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def toy_example(
The output segmentation extractor
"""
import spikeextractors as se

# generate ROIs
num_rois = int(num_rois)
Expand All @@ -123,6 +122,8 @@ def toy_example(
)

# generate spike trains
import spikeextractors as se

rec, sort = se.example_datasets.toy_example(
duration=duration,
K=num_rois,
Expand All @@ -131,19 +132,25 @@ def toy_example(
)

# create decaying response
resp_samples = int(decay_time * rec.get_sampling_frequency())
resp_samples = int(decay_time * sampling_frequency)
resp_tau = resp_samples / 5
tresp = np.arange(resp_samples)
resp = np.exp(-tresp / resp_tau)

num_frames = rec.get_num_frames() # TODO This should be changed to sampling_frequency x duration
num_of_units = sort.get_unit_ids() # TODO This to be changed by num_rois

# convolve response with ROIs
raw = np.zeros((len(sort.get_unit_ids()), rec.get_num_frames()))
deconvolved = np.zeros((len(sort.get_unit_ids()), rec.get_num_frames()))
neuropil = noise_std * np.random.randn(len(sort.get_unit_ids()), rec.get_num_frames())
frames = rec.get_num_frames()
for u_i, unit in enumerate(sort.get_unit_ids()):
for s in sort.get_unit_spike_train(unit):
if s < rec.get_num_frames():
raw = np.zeros(num_of_units, num_frames) # TODO Change to new standard formating with time in first axis
deconvolved = np.zeros(num_of_units, num_frames) # TODO Change to new standard formating with time in first axis
neuropil = noise_std * np.random.randn(
num_of_units, num_frames
) # TODO Change to new standard formating with time in first axis
frames = num_frames
for u_i, unit in range(num_of_units):
unit = u_i + 1 # spikeextractor toy example has unit ids starting at 1
for s in sort.get_unit_spike_train(unit): # TODO build a local function that generates frames with spikes
if s < num_frames:
if s + len(resp) < frames:
raw[u_i, s : s + len(resp)] += resp
else:
Expand Down

0 comments on commit 5b74133

Please sign in to comment.