Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize droping spikextractors, remove its use in toy_example.py #204

Open
h-mayorquin opened this issue Aug 31, 2022 · 1 comment
Open
Labels

Comments

@h-mayorquin
Copy link
Collaborator

On #196 @CodyCBakerPhD did most of the hard work of removing the spikextractors as a dependency and pushed it as an optional work flow.

What is left is to eliminate this completely. In the toy example spike-extractor is used to generate a set of frames in which the spikes occur to transform them to roi (that is, not the spikes times but the actual frames, given a sampling frequency, in which the spikes occurred). We should be able to reproduce this functionality here and eliminate the dependency for good.

So, where is this in the code, the actual functions from spikeextractors are here:

rec, sort = se.example_datasets.toy_example(
duration=duration,
K=num_rois,
num_channels=1,
sampling_frequency=sampling_frequency,
)

A recording and a spikextractor. They only use is here:

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():
if s + len(resp) < frames:
raw[u_i, s : s + len(resp)] += resp
else:
raw[u_i, s:] = resp[: frames - s]
deconvolved[u_i, s] = 1

Note that the the recording extractor (rec in the code) is only used to get the sampling frequency and the number of frames which is not really necessary. I will re-structure this in a small PR to make this obvious. The only difficult thing to remove is the production of the spike trains in line 144:

for u_i, unit in enumerate(sort.get_unit_ids()):

So, a function that produces frames in which spikes occur in some reasonable fashion should suffice for this small toy example.

@h-mayorquin
Copy link
Collaborator Author

In #205 I added indications of what needs to be done for when someone has time to take this on:

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(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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant