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

Implementing build_tensor and warp_tensor in warping.py #388

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

gviejo
Copy link
Contributor

@gviejo gviejo commented Jan 14, 2025

Here is the proposed behavior :

Simple trial-based tensor :

import pynapple as nap
import numpy as np
group = nap.TsGroup({0:nap.Ts(t=np.arange(0, 100))})
ep = nap.IntervalSet(start=np.arange(20, 100, 20), end=np.arange(20, 100, 20) + np.arange(2, 10, 2))
tensor = nap.build_tensor(group, ep, binsize=1)
print(tensor)
    array([[[ 1.,  1., nan, nan, nan, nan, nan, nan],
            [ 1.,  1.,  1.,  1., nan, nan, nan, nan],
            [ 1.,  1.,  1.,  1.,  1.,  1., nan, nan],
            [ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.]]])

Time-warped trial based tensor :

import pynapple as nap
import numpy as np
group = nap.TsGroup({0:nap.Ts(t=np.arange(0, 100))})
ep = nap.IntervalSet(start=np.arange(20, 100, 20), end=np.arange(20, 100, 20) + np.arange(2, 10, 2))
tensor = nap.warp_tensor(group, ep, num_bin=10)
print(tensor)
    array([[[1., 0., 0., 0., 0., 1., 0., 0., 0., 0.],
            [1., 0., 1., 0., 0., 1., 0., 1., 0., 0.],
            [1., 1., 0., 1., 0., 1., 1., 0., 1., 0.],
            [1., 1., 1., 1., 0., 1., 1., 1., 1., 0.]]])

Both functions works for any time series.

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
pynapple/core/base_class.py 97.60% <100.00%> (ø)
pynapple/core/ts_group.py 92.57% <100.00%> (-0.29%) ⬇️
pynapple/process/__init__.py 100.00% <100.00%> (ø)
pynapple/process/perievent.py 100.00% <100.00%> (+5.20%) ⬆️
pynapple/process/warping.py 100.00% <100.00%> (ø)

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

Successfully merging this pull request may close these issues.

1 participant