Repository navigation
Fix/197 198 - #199
Fix/197 198#199
Conversation
|
Hello @pietroquaglio! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-04-08 18:56:25 UTC |
| surr = data.reshape((1, len(data))) + 2 * dither * np.random.random_sample( | ||
| (n, len(data))) - dither | ||
|
|
||
| print(surr) |
There was a problem hiding this comment.
There is a print left.
There was a problem hiding this comment.
Thanks for spotting it I will remove it
| (spiketrain.t_stop / spiketrain.units).base) * spiketrain.units | ||
| surr = np.minimum(np.maximum(surr.simplified.magnitude, | ||
| spiketrain.t_start.simplified.magnitude), | ||
| spiketrain.t_stop.simplified.magnitude) * pq.s |
There was a problem hiding this comment.
This solution looks clean and relatively compact, but it forces all numerical operations to be held in seconds. What about applying the unit of original spike train from the beginning:
surr = np.minimum(np.maximum(surr.magnitude,
(spiketrain.t_start.rescale(spiketrain.units).magnitude)),
(spiketrain.t_stop.rescale(spiketrain.units).magnitude)) * spiketrain.units
Something has to be rescaled, if spiketrain and its t_start and t_stop have different units, but hard-coding any arbitrary units always seems a bit worrisome.
There was a problem hiding this comment.
The output spiketrains are in the end all re-scaled to the input for the units, honestly for the computations I prefer to have explicitely fixed units everywhere, which are not arbitrary but they match the simplified function
There was a problem hiding this comment.
It's an interesting question to come up frequently. From my understanding, the advantage to Paulina's approach is that one can continue to work in the time base of the original data, avoiding numerical problems by unnecessary time conversions. Pietro's version on the other hand moves the problem to a standard unit representation, avoiding things such as potential conversions of the data to some odd CompoundUnit. Are there any compelling arguments beyond this for choosing one over the other?
This is something that could be discussed in a broader audience and lead to a guideline on implementing methods in Elephant -- I guess this conversion issue is something that keeps coming up.
| for s in surr.base] | ||
| tstart, tstop = spiketrain.t_start.simplified.magnitude, \ | ||
| spiketrain.t_stop.simplified.magnitude | ||
| surr = [np.sort(s[np.all([s >= tstart, s < tstop], axis=0)]) * pq.s |
There was a problem hiding this comment.
I would not add np.sort() here, since the method is only supposed to shift the original spike train, no matter how nicely constructed it was in the first place. So it should never change the order of spikes - this could affect some analyses, couldn't it?
There was a problem hiding this comment.
Sorting is necessary because the it is not automatically checked by the neo.Spiketrains class, but other functions (e.g. isi()) assumes the spike are in increasing order.
There was a problem hiding this comment.
Actually, I am putting this an a potential issue for ISI calculation, as long as it's not clear of spike train objects are sorted or not.
There was a problem hiding this comment.
Actually, a sort() for ISIs was already included in the meantime.
* Change signal's `duplicate_with_new_array` to `duplicate_with_new_data` For compatibility with Neo 0.7.0 * Fixed error by replacing deprecated pandas function * Quick fix due to event labels being treated as array annotations * Quick fix due to event labels being treated as array annotations * Fixed handling of neo 0.7 array_annotations * Fixed requirements for neo * Removed left-over print statement * Added a hot fix to circumtvent Neo problem in generating fake epochs * Added fixed Neo Version 0.7.x * Fixed failing test in spike_train_correlation by alternate numpy construct.
…ing with readthedocs.org (NeuralEnsemble#205) * Removed setuptools from requirements * Removed all fixed packages from doc environment * Further simplified new environment.yml for RTD
* Changes for compatibility release 0.6.1 * Added release notes
* Fix typo in docstring * Replace some deprecated aliases * Add rauc and derivative to signal_processing * Apply suggestions from code review Co-Authored-By: jpgill86 <[email protected]> * Similar changes based on code review * Ensure rauc output signal has same time units as input
|
Hi @pietroquaglio To do this, it would be great if the unit tests would pass on this PR. Would you be able to base the PR off the current Elephant master branch, by
Thanks! |
1 similar comment
|
Going through the process I created a small conflict but now it should be fine! |
|
@PaulinaDabrowska and I discussed the outstanding issues again, and concluded to stick with the hard-coded seconds in the analysis until an agreement is reached on a more global level (e.g., by defining a global "standard time unit"). Also, the sorting is best left in for now. Therefore, we see no issues left in this PR. |
This pull request should fix both issue #197 and #198. Additionally in the test now it is covered the case of t_stop with different unit than the spikes.