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

Fix/cad validation matlab #533

Conversation

Moritz-Alexander-Kern
Copy link
Member

@Moritz-Alexander-Kern Moritz-Alexander-Kern commented Dec 2, 2022

This is a follow up PR to #576 , adding a validation test.

Bug

This was discovered in issue #443 .

Summary: CAD (cell assembly detection) output is not the same as the original MATLAB version provided by the article's author.

The MATLAB implementation by Eleonora Russo can be found here:
https://github.com/DurstewitzLab/Cell-Assembly-Detection .
This implementation was used in:
Eleonora Russo and Daniel Durstewitz. Cell assemblies at multiple time scales with arbitrary lag constellations. Elife, 6:e19428, 2017.

MATLAB

The MATLAB implementation defines alph as the input parameter of the function:
Line 1 in FindAssemblies_recursive.m

function [assembly_output]=FindAssemblies_recursive(binM,maxlag,alph,gg,Dc,No_th,O_th,bytelimit,reference_lag)

In later steps, the original input alph is kept and derived values are stored as a separate variable alpha .
Line 30 in FindAssemblies_recursive.m

alpha=alph*2/(nu*(nu-1)*(2*maxlag+1));      %% bonferroni correction 

Line 106 in FindAssemblies_recursive.m

alpha=alph/(length(w2_to_test)*n_as*(2*maxlag+1));  %% bonferroni correction only for the test that I actually perform

Elephant

The Elephant implementation defines alpha as the input parameter of the function:

def cell_assembly_detection(binned_spiketrain, max_lag, reference_lag=2,
alpha=0.05, min_occurrences=1, size_chunks=100,
max_spikes=np.inf, significance_pruning=True,
subgroup_pruning=True,
same_configuration_pruning=False,
bool_times_format=None, verbose=False):

In subsequent steps, the original input alpha is changed:

alpha = alpha * 2 / float(number_test_performed)

alpha = alpha / float(len(w2_to_test) * n_as * (2 * max_lag + 1))

As the value of alpha changes, the results differ from the MATLAB implementation, where the original input is stored as alph and is not changed inside the function.

Fix

Introduced a new variable alph, to store the input value of alpha.

todo

  • implement validation test: compare results obtained with the MATLAB implementation against results from Elephant implementation.

@Moritz-Alexander-Kern Moritz-Alexander-Kern added the bugfix Fix for an indentified bug. label Dec 2, 2022
@Moritz-Alexander-Kern Moritz-Alexander-Kern marked this pull request as draft December 2, 2022 09:46
@coveralls
Copy link
Collaborator

coveralls commented Dec 2, 2022

Coverage Status

coverage: 86.977% (+0.04%) from 86.937% when pulling 7994542 on INM-6:fix/CAD_validation_MATLAB into 5a56c31 on NeuralEnsemble:master.

@Moritz-Alexander-Kern Moritz-Alexander-Kern added this to the v0.13.0 milestone May 8, 2023
@Moritz-Alexander-Kern
Copy link
Member Author

This was covered with #576 , can be reopened at any time.

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

Successfully merging this pull request may close these issues.

[Bug] CAD output is not the same as original MATLAB Version
2 participants