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

Index "xyz" is out of bounds for axis "xyx" #2779

Open
taningh86 opened this issue Apr 29, 2024 · 10 comments
Open

Index "xyz" is out of bounds for axis "xyx" #2779

taningh86 opened this issue Apr 29, 2024 · 10 comments
Labels
question General question regarding SI

Comments

@taningh86
Copy link

Hi,
I am getting the index error saying that "index 2054149 is out of bounds for axis 0 with size 2054146" when I try to run sw.plot_amplitudes(sa,backend='ipywidgets'). I am aware what this error means, but knowing that this is not due to any incorrect indexing logic in the source code, I am assuming that this is a rare scenario and may be issues with sorting or something else. Not sure how to resolve this. This is the first time I have gotten this error in spikeinterface and I haven't made any changes to the order of how I process my data. Is it something with the data itself? Not sure, because my data is still 30ish minutes long recordig and that has been the same all my recordings.
Also, is it something similar to 'more spikes than the length of the recording' occassionally spike sorting causes? By that I mean an error originating from sorting. The workaround for that kind of error I used is:

import spikeinterface.curation as scur
sorting_wout_excess_spikes = scur.remove_excess_spikes(sorting_KS25, recording_saved)

Is there a similar workaround or a similar solution for this error?
Thanks

@zm711
Copy link
Collaborator

zm711 commented Apr 29, 2024

Could you copy the complete stack trace? We need to see where the error comes from.

@zm711 zm711 added the question General question regarding SI label Apr 29, 2024
@taningh86
Copy link
Author

sure. here it is
---------------------------------------------------------------------------```

IndexError Traceback (most recent call last)
Cell In[16], line 1
----> 1 sw.plot_amplitudes(sa,backend="ipywidgets")

File ~\spikeinterface\src\spikeinterface\widgets\amplitudes.py:59, in AmplitudesWidget.init(self, sorting_analyzer, unit_ids, unit_colors, segment_index, max_spikes_per_unit, hide_unit_selector, plot_histograms, bins, plot_legend, backend, **backend_kwargs)
56 sorting = sorting_analyzer.sorting
57 self.check_extensions(sorting_analyzer, "spike_amplitudes")
---> 59 amplitudes = sorting_analyzer.get_extension("spike_amplitudes").get_data(outputs="by_unit")
61 if unit_ids is None:
62 unit_ids = sorting.unit_ids

File ~\spikeinterface\src\spikeinterface\core\sortinganalyzer.py:1476, in AnalyzerExtension.get_data(self, *args, **kwargs)
1474 def get_data(self, *args, **kwargs):
1475 assert len(self.data) > 0, f"You must run the extension {self.extension_name} before retrieving data"
-> 1476 return self._get_data(*args, **kwargs)

File ~\spikeinterface\src\spikeinterface\postprocessing\spike_amplitudes.py:143, in ComputeSpikeAmplitudes._get_data(self, outputs)
141 for unit_id in unit_ids:
142 inds = spike_indices[segment_index][unit_id]
--> 143 amplitudes_by_units[segment_index][unit_id] = all_amplitudes[inds]
144 return amplitudes_by_units
145 else:

IndexError: index 2054149 is out of bounds for axis 0 with size 2054146

@zm711
Copy link
Collaborator

zm711 commented Apr 29, 2024

Which sorter are you using? This has happened before but I can't quite remember if it was the excessive spike issues. Did you load in the sorting_wout_excess_spikes into the sorting_analyzer?

@taningh86
Copy link
Author

i used ks2.5. I have not done sorting_wout_escessive_spikes yet, but I will do it and let you know.

@zm711
Copy link
Collaborator

zm711 commented Apr 29, 2024

Kilosort (all flavors) is the one we typically see having excessive spikes (usually after the recording ends). so if using KS, the remove excess spikes can be beneficial.

@taningh86
Copy link
Author

It worked with remove_excess_spikes. Thanks @zm711 We can close this issue.

@JoeZiminski
Copy link
Contributor

Does it make sense to put this as a suggestion in the assert message?

@taningh86
Copy link
Author

Does it make sense to put this as a suggestion in the assert message?

I would vote Yes!

@zm711
Copy link
Collaborator

zm711 commented Apr 30, 2024

I think the issue is we don't know that you have excessive spikes until the SortingAnalyzer because that is the point at which the Recording and Sorting come together. So maybe we could do a check during creation of that? Because then you need to remake the Analyzer with the curated sorting so we move the issue earlier in the chain?

@JoeZiminski
Copy link
Contributor

Thanks @zm711 to me that makes sense, I am not caught up yet with the SortingAnalyzer but happy to give my thoughts when I've done a bit more reading 😅

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

No branches or pull requests

3 participants