-
Notifications
You must be signed in to change notification settings - Fork 93
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/multifiltertest #142
Conversation
It seems the failing unit test -- which is related to reproducing published results -- is mainly failing as it depends on realization of the spike trains which are generated (with fixed CPs at 150, 180, and 500s). Although the random seed is fixed, the spike trains seems to differ on travis vs. when running it locally. In other words, the test data operates in a borderline regime, where the method will not always correctly detect all CPs in the data. Thus, it may be a good idea to save the generated spike data explicitly and load it in the unit test. In addition, one could remodel the current unit test such, that the differences between the rates are more pronounced such that the method is very sure to detect them. |
In terms of file names -- would it be better to name the module Independent of the module name decided upon, please name the corresponding unit test file |
The unit test script (test_change_point_detection.py) imports elephant.multiple_filter_test and this raises an error. Please correct this line to the new module name. |
The limit processes are not properly generated, namely, from pag. 10 of the article: |
…brownian motion outside the for loop across windows
…en changed from 8, 13, 18, 16.5 Hz to 4, 13, 36, 16.5 Hz and the seed is not fixed anymore
elephant/change_point_detection.py
Outdated
|
||
>>> import quantities as pq | ||
>>> import neo | ||
>>> from elephant.multiple_filter_test import multiple_filter_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the module name (elephant.multiple_filter_test) needs to be corrected
variances of the limit process correspodning to `h`. This will be | ||
used to normalize the `filter_process` in order to give to the every | ||
maximum the same impact on the global statistic. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation for test_quantile is missing, and the order of the arguments is not consistent with that of the definition of the function.
elephant/change_point_detection.py
Outdated
Returns: | ||
-------- | ||
cps : list of list | ||
one list for each `h`, containing the points detected with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is 'h'?
elephant/change_point_detection.py
Outdated
#print("detected point {0}".format(cp), "with filter {0}".format(h)) | ||
# before to repet the procedure the h-neighbourg of 'cp' detected | ||
# is cut, because rate changes within it are explained by this cp | ||
differences[np.where( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too complicated. Can be rewritten as:
mask_fore = time_index > cp_index - int((h / dt_temp).simplified)
mask_back = time_index < cp_index + int((h / dt_temp).simplified)
differences[mask_fore & mask_back] = 0
elephant/change_point_detection.py
Outdated
# check if the neighbourhood of detected cp does not contain cps | ||
# detected with other windows | ||
neighbourhood_free = True | ||
if i == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if-case is not necessary.
When i == 0
, the for-loop in the else
case actually doesn't iterate anything.
elephant/change_point_detection.py
Outdated
except ValueError: | ||
raise ValueError("dt must be a time quantity") | ||
t_fin_m = t_fin_sec.magnitude | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t_in_sec
and t_fin_sec
are not actually used.
You should rather define them as t_in_sec = t_in.rescale(u).magnitude
and t_fin_sec = t_fin.rescale(u).magnitude
, and use them instead of t_in_m
and t_fin_m
.
This kind of confusing usage of rescale is seen in other functions as well.
Please correct them as well so that the treatment of units is consistent within the code.
elephant/change_point_detection.py
Outdated
matrix_normalized.append((matrix[i] - mean) / np.sqrt(var)) | ||
null_mean.append(mean) | ||
null_var.append(var) | ||
matrix_normalized = np.asanyarray(matrix_normalized) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of code is unnecessarily complicated and redundant.
The same result can be obtained by
null_mean = maxima_matrix.mean(axis=0)
null_var = maxima_matrix.var(axis=0)
matrix_normalized = (maxima_matrix - null_mean) / np.sqrt(null_var)
@EmanueleLucrezia In the docstrings I inserted s at the headers, e.g |
Comments by Messer:
|
@mdenker, see below our input to Messer's comments.
This is addressed by commit 882d9ba
With my latest commit
This is done with commit fd4b2da |
This pull request adds the multiple filter test for the detection of rate change points in single unit spike trains. The algorithm is following the paper:
and the code is adapted from the R implementation: