Skip to content

Fix/197 198 - #199

Merged
mdenker merged 10 commits into
NeuralEnsemble:masterfrom
INM-6:fix/197_198
Apr 11, 2019
Merged

mdenker merged 10 commits into
NeuralEnsemble:masterfrom
INM-6:fix/197_198

Conversation

@pietroquaglio

Copy link
Copy Markdown
Contributor

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.

@pep8speaks

pep8speaks commented Feb 6, 2019 •

Copy link
Copy Markdown

Hello @pietroquaglio! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 51:80: E501 line too long (113 > 79 characters)
Line 53:80: E501 line too long (90 > 79 characters)
Line 56:80: E501 line too long (83 > 79 characters)

Line 379:80: E501 line too long (80 > 79 characters)

Line 122:13: E128 continuation line under-indented for visual indent
Line 123:13: E128 continuation line under-indented for visual indent
Line 350:13: E128 continuation line under-indented for visual indent
Line 351:13: E128 continuation line under-indented for visual indent

Line 450:1: W293 blank line contains whitespace
Line 469:1: W293 blank line contains whitespace
Line 672:20: E231 missing whitespace after ','
Line 675:20: E231 missing whitespace after ','
Line 678:20: E231 missing whitespace after ','
Line 1032:1: W293 blank line contains whitespace

Line 525:80: E501 line too long (80 > 79 characters)

Comment last updated at 2019-04-08 18:56:25 UTC

Comment thread elephant/spike_train_surrogates.py Outdated
surr = data.reshape((1, len(data))) + 2 * dither * np.random.random_sample(
(n, len(data))) - dither

print(surr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a print left.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, a sort() for ISIs was already included in the meantime.

mdenker and others added 4 commits March 31, 2019 22:48
* 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
@mdenker mdenker added this to the v0.6.2 milestone Apr 8, 2019
@mdenker

mdenker commented Apr 8, 2019

Copy link
Copy Markdown
Member

Hi @pietroquaglio
the breaking unit tests in the master branch should now be fixed, so we can integrate this PR into Elephant.

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

  • pulling the current NeuralEnsemble Elephant master branch to your local master
  • changing to you local copy of this feature branch, and making a git rebase master
  • and then pushing the feature branch to update this PR?

Thanks!

@mdenker mdenker added the bug Indicates an unexpected problem or unintended behavior label Apr 8, 2019
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage increased (+0.2%) to 87.222% when pulling fba69d5 on INM-6:fix/197_198 into c6ffc3b on NeuralEnsemble:master.

1 similar comment
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage increased (+0.2%) to 87.222% when pulling fba69d5 on INM-6:fix/197_198 into c6ffc3b on NeuralEnsemble:master.

@pietroquaglio

Copy link
Copy Markdown
Contributor Author

Going through the process I created a small conflict but now it should be fine!

@mdenker

mdenker commented Apr 11, 2019

Copy link
Copy Markdown
Member

@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.

@mdenker
mdenker merged commit 941518a into NeuralEnsemble:master Apr 11, 2019
@mdenker
mdenker deleted the fix/197_198 branch April 11, 2019 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants