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

improves blackrock spikes in nev #1152

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ferchaure
Copy link
Contributor

Hi,
I tried to open a .nev file (2.3 version) and I found t2o bugs and fix them:

-The timestamps gives one element less that the amount of spikes. I follow that issue to the _seg_t_stops definition and how is used to create a slice. Before the highest element in the nev file was defined as the t_stops and used to slice... keeping the last element outside the range. I just add a sample before converting to time and the appending to _seg_t_stops

-It wasn't possible to load the waveforms. The reshape in _get_spike_raw_waveforms throw an error related to sizes mismatch. In a few words, it had to many bytes for the waveforms (in my case 96 when each waveform should have 92). I could increase the bytes for the reserved fields of the Spikes fields in the __nev_data_types ... but given that each channels has its own waveform_dtypes maybe it has to be resize for each case. For that reason I create that additional dt1 type, to remove the extra bytes knowing how many bytes should be there for the waveform.

Cheers,
Fernando

@pep8speaks
Copy link

pep8speaks commented Aug 13, 2022

Hello @ferchaure! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-08-30 15:33:56 UTC

waveforms = unit_spikes['waveform'].flatten().view(wf_dtype)
dt1 = [
('extra', 'S{}'.format(unit_spikes['waveform'].dtype.itemsize - wf_byte_size)),
('ch_waveform', 'S{}'.format(wf_byte_size))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you get this specification of extra bytes ? is it in the official documents ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, the code looked like it follows the documentation, but I saw that the available bytes for the waveforms are bigger that the ones expected given the dtype. Maybe the reserved bytes ( the ones before the waveform data) must be dynamic and not always uint8 (but I couldn't find documentation to support that theory). For that reason I did that dt1 type, just to extract the expected bytes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how we can be sure that extra bytes are before ?
And what if extra size == 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question, I don't know, I just tested it in a file and there is the relationship with the reserved bytes that are before. (I can share the file if you want)
I checked the case when extra size == 0 and it's fine, it just creates an empty binary field without errors

@ferchaure
Copy link
Contributor Author

The last commit edits the segment stop just to extract spikes times (adding a sample to let it work fine with the stop of a slice), it fixes the same without editing the _seg_t_stops attribute

@JuliaSprenger JuliaSprenger added this to the 0.12.0 milestone Oct 25, 2022
@JuliaSprenger JuliaSprenger modified the milestones: 0.12.0, 0.12.1 Apr 2, 2023
@JuliaSprenger JuliaSprenger modified the milestones: 0.12.1, 0.13.0 Jul 19, 2023
Copy link
Member

@mdenker mdenker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged with the current master branch, I was able to successfully load two of our v2.3 data files, containing 2 and 3 segments, respectively. Regarding the waveforms, one had 38, one 48 samples, both was correctly loaded with an extra field of size 0 in dt1. Regarding the missing spikes, I can confirm that with the patch, in one of the two data files 3 additional spikes were loaded which are sitting exactly on t_stop, i.e., the end of the segment. These spikes were missed with the previous version of the IO, and I agree that the user would expect these spikes to be included instead.

Looking at the code, it looks good to me. Thanks for the patch, very useful!

@apdavison apdavison modified the milestones: 0.13.0, 0.13.1 Feb 2, 2024
@mdenker
Copy link
Member

mdenker commented Feb 23, 2024

Decision was made during a Neo discussion to add a flag to the loader that can be used to select the alternate waveform loading.

@alejoe91 alejoe91 modified the milestones: 0.13.1, 0.14.0 Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants