NeuralEnsemble / elephant

Elephant is the Electrophysiology Analysis Toolkit
http://www.python-elephant.org
BSD 3-Clause "New" or "Revised" License
200 stars 92 forks source link

[Bug] CAD output is not the same as original MATLAB Version #443

Closed Peyman7 closed 3 months ago

Peyman7 commented 2 years ago

Describe the bug CAD cell assembly detection method output is not the same as the original MATLAB version provided by the article's author. I have checked the source codes, and found the parameter alpha in the " # testing for higher order assemblies" part gives the wrong value as it should take the original alpha=0.05 in the right side. alpha = alpha / float(len(w2_to_test) n_as (2 * max_lag + 1)) As alpha in previous lines recalled and its value is changed because of same alpha values in both side of equation, it should be changed in a way that the value of alpha in the right side always is be the same is the alpha input parameter.

To Reproduce As alpha parameter name in input parameter may be changed to alph (as well as the same MATLAB version) and alpha parameter in the right side of alpha = alph/ float(len(w2_to_test) n_as (2 * max_lag + 1)) changes to alph.

Environment

Environment

Moritz-Alexander-Kern commented 2 years ago

Hey, thanks for your detailed report. If I understand correctly this issue seems to be related to the name used for the variable/parameter producing unwanted behavior. This needs some investigation, we will look into it.

Moritz-Alexander-Kern commented 2 years ago

you've pointed to line: https://github.com/NeuralEnsemble/elephant/blob/6ed3cb3089783035885e2fbec1fff535df7369cd/elephant/cell_assembly_detection.py#L363

another change to alpha seems to occur here: https://github.com/NeuralEnsemble/elephant/blob/6ed3cb3089783035885e2fbec1fff535df7369cd/elephant/cell_assembly_detection.py#L255

I suggest creating a validation test based on the original MATLAB implementation as a regression test. Is this the MATLAB-implementation provided by the author you are using: https://github.com/DurstewitzLab/Cell-Assembly-Detection ?

Peyman7 commented 2 years ago

Yes, that link is the original MATLAB code published by the article's main author.

Peyman7 commented 2 years ago

Hi,

That’s a good idea! Regarding the original MATLAB code link, you have pointed the correct link.

Cheers, Peyman

On May 11, 2022, at 06:46, Moritz Kern @.***> wrote:

 you've pointed to line: https://github.com/NeuralEnsemble/elephant/blob/6ed3cb3089783035885e2fbec1fff535df7369cd/elephant/cell_assembly_detection.py#L363

another change to alpha seems to occur here: https://github.com/NeuralEnsemble/elephant/blob/6ed3cb3089783035885e2fbec1fff535df7369cd/elephant/cell_assembly_detection.py#L255

I suggest creating a validation test based on the original MATLAB implementation as a regression test. Is this the MATLAB-implementation provided by the author you are using: https://github.com/DurstewitzLab/Cell-Assembly-Detection ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

Moritz-Alexander-Kern commented 3 months ago

Fixed with #576