Skip to content
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

[ENH] Merge TsGroup? #251

Closed
qian-chu opened this issue Mar 25, 2024 · 2 comments
Closed

[ENH] Merge TsGroup? #251

qian-chu opened this issue Mar 25, 2024 · 2 comments

Comments

@qian-chu
Copy link
Contributor

In quite a few scenarios one may want to merge some TsGroup (e.g. adding new neurons, merging PETH from different runs, etc.) but currently TsGroup is non-mutable:

def __setitem__(self, key, value):
if self._initialized:
raise RuntimeError("TsGroup object is not mutable.")

Maybe we can add a method that takes two TsGroups and returns a new TsGroup when the following conditions are met:

  1. Non-overlapping indices
  2. Same meta-info columns
  3. Same time support (if none specified, infer from start and end of the merged Ts/Tsd

Happy to initiate a pull request if people see a need for this.

@qian-chu qian-chu changed the title Merge TsGroup? [ENH] Merge TsGroup? Mar 26, 2024
@gviejo
Copy link
Contributor

gviejo commented Apr 2, 2024

Hi Qian Chu, I think it's doable with the condition you just listed. Maybe a class method that does something like this

tsgroup = nap.TsGroup.join_group_set([tsgroup1, tsgroup2, tsgroup3])

Maybe this class method can be called by a simple method of TsGroup like this as well.

tsgroup = tsgroup1.join(tsgroup2)

In general I like to provide multiple ways of doing the same thing in pynapple. I noticed people have different intuition about how the package should behave.

Happy to review a PR.

@gviejo
Copy link
Contributor

gviejo commented May 22, 2024

Solved in #275

@gviejo gviejo closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants