-
Notifications
You must be signed in to change notification settings - Fork 92
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
Allow passing spike rates directly to gpfa #507
Allow passing spike rates directly to gpfa #507
Conversation
Hello @jonahpearl! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
Hi @jonahpearl , I've created a pull request here: jonahpearl#1 . This PR makes the code comply to pep8. I will have to look more deeply into this and also come up with some unit tests. If you have any suggestions for tests or a minimal example, don't hesitate to share with us. Looking forward to continue on this. What do you think @essink ? |
Hey @jonahpearl , Here's a quick reply to your comments, I need some more time to do a complete the review and come up with a more detailed response.
Good point, I agree this is a good unit-test, thanks for your input! The self.has_spikes_bool = np.hstack(seqs['y']).any(axis=1) https://github.com/jonahpearl/elephant/blob/67492e9852607f08211546f726df9dd5fbe64dfe/elephant/gpfa/gpfa.py#L374
I will come back to this and give a more detailed answer once I have looked into it, but at first glance: do agree that there is no Poisson here. (thanks again essink ) |
Ah, I see now. I was worried that
|
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.
Thank you for your patience, here is a more in-depth review:
additional points:
-
consider adding the change to
fit_transform()
: here an argument would have to be added and passed to fit and transform accordingly. (fit_transform
is just a wrapper for fit and transform). -
consider analogous to
_check_training_data()
a check for seqs e.g. there should be traces inside and it should be a recarray with the right fields.
I will soon push suggestions for unit-tests to the PR already opened here: jonahpearl#1
(edit: first unit-tests for basic functionality added)
self._check_training_data(spiketrains) | ||
seqs_train = self._format_training_data(spiketrains) | ||
elif seqs_train is not None: | ||
seqs_train = self._format_training_data_seqs(seqs_train) # TODO: write this! |
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.
seqs_train = self._format_training_data_seqs(seqs_train) # TODO: write this! | |
seqs_train = self._format_training_data_seqs(seqs_train) |
remove TODO, since _format_training_data_seqs
is implemented, or is this referring to something different?
seq['y'] = seq['y'][self.has_spikes_bool, :] | ||
return seqs | ||
|
||
def transform(self, spiketrains, seqs=None, returned_data=['latent_variable_orth']): |
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.
Since seqs
is now a parameter of transform
, consider adding a description to the docstring of transform
.
"neurons as the training spiketrain data") | ||
seqs = gpfa_util.get_seqs(spiketrains, self.bin_size) | ||
elif seqs is not None: | ||
# check some stuff |
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.
# check some stuff | |
if len(seqs['y'][0]) != len(self.has_spikes_bool): | |
raise ValueError( | |
"'seq_trains' must contain the same number of neurons as " | |
"the training spiketrain data") |
Thanks for your suggestion, I took the liberty to add it here, I hope I got the spirit of your idea correctly? #507 (comment)
seqs = gpfa_util.get_seqs(spiketrains, self.bin_size) | ||
elif seqs is not None: | ||
# check some stuff | ||
pass |
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.
pass |
no longer needed, see above
Thanks for the contribution, development will be continued in #539, feel free to reopen at any time if necessary. |
Hi there -- I made a little edit to the gpfa class that allows spike rates to be passed in directly, bypassing the first step of the processing. This would allow gpfa to be used on df/f traces, or pre-interpolated spike rates, or really any continuous set of values.
I don't know if the downstream analysis assumes things specific to spike rates, eg only positive values, but if so, might be good to add checks to that effect in
Also, it seemed like the check in transform()
if len(spiketrains[0]) != len(self.has_spikes_bool)
was redundant / conflicting with the line a few lines laterseq['y'] = seq['y'][self.has_spikes_bool, :]
, so I didn't add any checks there, but it feels like it ought to check something aboutseq
.Anyways, hope this helps someone :)