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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty timeframes in 4D vectors layers #6856

Open
jo-mueller opened this issue Apr 18, 2024 · 0 comments
Open

Empty timeframes in 4D vectors layers #6856

jo-mueller opened this issue Apr 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jo-mueller
Copy link
Contributor

馃悰 Bug Report

Minor thing what's been bugging me for some time: If a set of 4D vectors (vectors array of shape (N, 2, 4) and timepoints (1, 2, 3,4, 5)) is added to the napari viewer, the time sliders sets itself to double the amount of timepoints in the data, i.e., 10 timepoints.

馃挕 Steps to Reproduce

I used the latest napari version from main.

Script to reproduce:

import numpy as np
import napari

n_points = 100
n_timepoints = 5

vectors_base_points = np.random.rand(n_points, 4)
vectors_base_points[:, 0] = np.arange(n_timepoints).repeat(n_points // n_timepoints)
vector_directions = np.random.rand(n_points, 4)
vector_directions[:, 0] = np.arange(n_timepoints).repeat(n_points // n_timepoints)

# stack vectors into proper format
vectors = np.stack([vectors_base_points, vector_directions], axis=1)

viewer = napari.Viewer(ndisplay=3)
viewer.add_vectors(vectors)

print(viewer.dims)

would result into this, in my case:

> Dims(ndim=4, ndisplay=3, order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3'), rollable=(True, True, True, True), range=(RangeTuple(start=0.0, stop=8.0, step=1.0),, ...

clearly, this (RangeTuple(start=0.0, stop=8.0, step=1.0)) is not correct.

馃挕 Expected Behavior

I would expect the maximum timeframe to be the maximum number in the time column of the 4D data, i.e., max(vectors[:, 0, 0]) - in the example above that would be 4.

馃寧 Environment

napari: 0.1.dev3361+gea9a516
Platform: Windows-10-10.0.19045-SP0
Python: 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:40:50) [MSC v.1937 64 bit (AMD64)]
Qt: 5.15.8
PyQt5: 5.15.9
NumPy: 1.26.4
SciPy: 1.13.0
Dask: 2024.4.1
VisPy: 0.14.2
magicgui: 0.8.2
superqt: 0.6.3
in-n-out: 0.2.0
app-model: 0.2.6
npe2: 0.7.5

OpenGL:

  • GL version: 4.6.0 NVIDIA 551.86
  • MAX_TEXTURE_SIZE: 32768
  • GL_MAX_3D_TEXTURE_SIZE: 16384

Screens:

  • screen 1: resolution 2560x1440, scale 1.0
  • screen 2: resolution 1920x1080, scale 1.0

Optional:

  • numba not installed
  • triangle not installed

Settings path:

  • C:\Users\johan\AppData\Local\napari\napari-dev_2fa15b08d37eac12a0d2634e224a3ab29cd1d339\settings.yaml

馃挕 Additional Context

II tried to pinpoint the location where the dimensions are determined - if pointed to the correct place, I would be happy to send a PR with a fix :)

@jo-mueller jo-mueller added the bug Something isn't working label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant