pynapple-org / pynapple

PYthon Neural Analysis Package :pineapple:
https://pynapple.org/
MIT License
279 stars 63 forks source link

Union of multiple interval sets #217

Open BalzaniEdoardo opened 9 months ago

BalzaniEdoardo commented 9 months ago

First of all, I am really enjoying learning pynapple so thanks for the package!

I would like to have a way to perform the union of an arbitrary number of interval sets. It would be great to have a classmethod for that.

Thanks

NileshArnaiya commented 8 months ago

Hi, is this what you are looking for @BalzaniEdoardo

i_sets = [ep1, ep2, ep3, ep4]

ep6 = nap.core.ts_group.union_intervals(i_sets)
BalzaniEdoardo commented 8 months ago

Hi Nilesh, thanks for your answer. Not exactly, I probably did not formulate my thoughts well enough, my bad. What I had in mind is more something like an IntervalSetGroup. Basically, a dictionary with which you could represent your experiment structure. For example

iset_group = IntervalSetGroup({"stimlus A": ep1, "stimulus B": ep2, "light phase": ep3, "dark phase":ep4})

And with that the possibility to do stuff like,

tsd.restrict( iset_group.intersect("simulus A", "stimulus B", "dark_phase"))

To get the data of the specific condition.

Which is basically a way to represent your experiment and facilitate playing around with the conditions

BalzaniEdoardo commented 8 months ago

you could do any such set operations, in a sense. So, instead of dealing with multiple IntervalSets having the possibility of having a single variable. One could have, similarly to TsGroup, a summary of the various conditions in the repr for example.