Conversation
|
Hello @lungsi! Thanks for updating the PR.
Comment last updated on April 19, 2018 at 11:49 Hours UTC |
neo/core/basesignal.py
Outdated
| def extract_for_epoch(self, epoch): | ||
| """ | ||
| Checks self (which is the instance, neo.AnalogSignal or neo.SpikeTrain) for | ||
| specified neo.Epoch and returns signals for respetive epochs within neo.Epoch |
There was a problem hiding this comment.
typo: this should be 'respective'
|
Hi Lungsi! If this is going to stay a BaseSignal method, I would suggest to include the code of the |
| else: | ||
| return times_of_an_epoch | ||
|
|
||
| def extract_for_epoch(self, epoch): |
There was a problem hiding this comment.
maybe cut_by_epoch or slice_by_epoch is more telling?
There was a problem hiding this comment.
I have not particular preference, I used the verb extract because it returns the cut/sliced signal.
There was a problem hiding this comment.
Hi Julia,
Thanks for the comments.
The point regarding the function performing a utility is a good one. I started out thinking that way but since there were no current utility.py script/source fille so I took the current approach which is to make signal have the method where one just had to pass the epoch. If there's going to be a script containing the utility methods I thinks its ok to have it there.
With regards to why I have _rescale_epoch_time and extract_for_epoch, not just one is because it avoids code duplication and also one has only 1-reason to change/edit either methods.
There was a problem hiding this comment.
I prefer slice_by_epoch to match time_slice
There was a problem hiding this comment.
I agree with @JuliaSprenger on moving _rescale_epoch_time inside the function where it is used. This does not imply code duplication, since you can define a function inside a function.
Alternatively, it could be moved out of the BaseSignal definition into a utility function, as checking two Neo objects have the same units must surely be a common need.
|
I believe this is an implementation of #387 ? |
| or | ||
| rescaled (to signal.times.units) times_of_an_epoch if units are different. | ||
| """ | ||
| if times_of_an_epoch.units is not a_signal.times.units: |
There was a problem hiding this comment.
shouldn't this be "!=" rather than "is not"?
|
Dear all. I have implemented proxy objects here #461. For doing this I would prefer to write external function as proposed by @JuliaSprenger and map them to method as proposed by @apdavison. So with proxy objects the external function could be hacked easily to work with standard/proxy objects. My proposal is AnalogSignal.extract_for_epoch should call external neo.io.utils_slice.slice_sig_by_epoch (or whatever) External function will also help for global slicing at segment/block level. EDIT: I am totally repeating what @JuliaSprenger and @apdavison said before sorry. |
|
I'm postponing this to the next milestone due to lack of time to work on it. |
|
closing now as this PR is very old, but we will revisit the idea |
Added two methods within the class
BaseSignalthese are: (staticmethod)_rescale_epoch_timeandextract_for_epoch. Therefore when a neo object signal is created (which in turn is an instance of the child class ofBaseSignal) it has the methodextract_for_epoch. Passing the epochs (created neo.Epoch) into this method will return a list of extracted signals (specific to the epochs).