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

Fix: test for windowed projection in analysis.Video class #28

Open
janreising opened this issue May 25, 2023 · 0 comments
Open

Fix: test for windowed projection in analysis.Video class #28

janreising opened this issue May 25, 2023 · 0 comments
Labels
bug Something isn't working complicated

Comments

@janreising
Copy link
Owner

section of get_image_project()

...

from numpy.lib.stride_tricks import sliding_window_view

Z, X, Y = img.shape
proj = np.zeros((X, Y))

z_step = int(window/2)
for x in tqdm(range(X)) if show_progress else range(X):
    for y in range(Y):

        slide_ = sliding_window_view(img[:, x, y], axis=0, window_shape = window) # sliding trick
        slide_ = slide_[::z_step, :] # skip most steps
        agg = agg_func(slide_, axis=1) # aggregate
        proj[x, y] = window_agg(agg) # window aggregate


Current implementation of test:

proj_org = np.zeros(original_data.shape)
                    for x in range(original_data.shape[1]):
                        for y in range(original_data.shape[2]):
                            proj_org[:, x, y] = pd.Series(original_data[:, x, y]).rolling(window=window).apply(proj_func).values

This fails because the sliding trick windows differently than intuitively expected. Eg. initial values of sliding trick produces np.nan

@janreising janreising added the bug Something isn't working label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working complicated
Projects
None yet
Development

No branches or pull requests

1 participant