-
Notifications
You must be signed in to change notification settings - Fork 92
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
[Feature] Add test for automatic kernel selection to test against reference implementation #247
Comments
This is the website to compute a reference implementation: https://www.neuralengine.org/res/kernel.html |
ImplementationsThere are 3 available implementations of this method on https://www.neuralengine.org/res/kernel.html.
TestsCompare the results obtained with elephant against the other implementations. Installation
CodeThe following snippet was used to produce the results: import elephant
import neo
from elephant.datasets import download_datasets
import adaptivekde
# Download data
repo_path = 'tutorials/tutorial_unitary_event_analysis/data/dataset-1.nix'
filepath = download_datasets(repo_path)
# load data
io = neo.io.NixIO(filepath, 'ro')
block = io.read_block()
for segment_no in range(0,5):
# segment_no = 3
train_no = 0
print(f"Segment number: {segment_no}")
print(f"Spiketimes{block.segments[segment_no].spiketrains[train_no].magnitude}")
bandwidth = elephant.statistics.optimal_kernel_bandwidth(block.segments[segment_no].spiketrains[train_no].magnitude)
print("Results:")
print(f"Optimal kernel bandwidth calculated with Elephant {bandwidth['optw']}")
bandwidth2 = adaptivekde.sskernel(block.segments[segment_no].spiketrains[train_no].magnitude)
print(f"Optimal kernel bandwidth calculated with adaptivekde {bandwidth2[2]}") Results(added results from HTML5 based online tool manually)
The results obtained with the python implementation "adaptivekde" are very closely in line with elephants implementation. However, the results obtained with the online tool differ significantly. This might be due to an optimization used by the online tool which is "accelarating computation by excluding >5 std samples. " (see: https://www.neuralengine.org/res/kernel.html) How to proceed ?
I don't have any strong opinions here. Any suggestions? |
Thanks for working on this. For Python and Matlab, I suggest the same procedure as done for similar validations before, i.e., include a script on elephant-data to calculate the results using these tools, save them in elephant-data, and in the elephant unit tests load the results from there and compare. I don't think we should increase our dependency tree by directly installing the adaptivekde. For the web interface version, I suggest to first further investigate the differences. If it turns out that the implementation itself differs too much, there is likely no need for a third validation. Conversely, the doc string should point out the incompatibility. |
For the test, one could also think about creating stochastic data (e.g., using Poisson with varying rate) -- this would make the test independent of the Unitary Events dataset. |
Feature
To prevent bugs such as #245, there should be a unit test of the instantaneous rate estimate against reference data. One option is to compare against data obtained from the online tool.
The text was updated successfully, but these errors were encountered: