-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0869b62
commit 1d53ecb
Showing
19 changed files
with
360 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
|
||
|
||
def generate_5d_sine_wave( | ||
shape: tuple[int, int, int, int, int], | ||
amplitude: float = 240, | ||
base_frequency: float = 5, | ||
) -> np.ndarray: | ||
"""5D dataset.""" | ||
# Unpack the dimensions | ||
angle_dim, freq_dim, phase_dim, ny, nx = shape | ||
|
||
# Create an empty array to hold the data | ||
output = np.zeros(shape) | ||
|
||
# Define spatial coordinates for the last two dimensions | ||
half_per = base_frequency * np.pi | ||
x = np.linspace(-half_per, half_per, nx) | ||
y = np.linspace(-half_per, half_per, ny) | ||
y, x = np.meshgrid(y, x) | ||
|
||
# Iterate through each parameter in the higher dimensions | ||
for phase_idx in range(phase_dim): | ||
for freq_idx in range(freq_dim): | ||
for angle_idx in range(angle_dim): | ||
# Calculate phase and frequency | ||
phase = np.pi / phase_dim * phase_idx | ||
frequency = 1 + (freq_idx * 0.1) # Increasing frequency with each step | ||
|
||
# Calculate angle | ||
angle = np.pi / angle_dim * angle_idx | ||
# Rotate x and y coordinates | ||
xr = np.cos(angle) * x - np.sin(angle) * y | ||
np.sin(angle) * x + np.cos(angle) * y | ||
|
||
# Compute the sine wave | ||
sine_wave = (amplitude * 0.5) * np.sin(frequency * xr + phase) | ||
sine_wave += amplitude * 0.5 | ||
|
||
# Assign to the output array | ||
output[angle_idx, freq_idx, phase_idx] = sine_wave | ||
|
||
return output | ||
|
||
import ndv | ||
|
||
try: | ||
from skimage import data | ||
|
||
img = data.cells3d() | ||
except Exception: | ||
img = generate_5d_sine_wave((10, 3, 8, 512, 512)) | ||
|
||
|
||
if __name__ == "__main__": | ||
from qtpy import QtWidgets | ||
|
||
from ndv import NDViewer | ||
img = ndv.data.cells3d() | ||
except Exception as e: | ||
print(e) | ||
img = ndv.data.nd_sine_wave((10, 3, 8, 512, 512)) | ||
|
||
qapp = QtWidgets.QApplication([]) | ||
v = NDViewer(img) | ||
v.show() | ||
qapp.exec() | ||
ndv.imshow(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
import tensorstore as ts | ||
from qtpy import QtWidgets | ||
try: | ||
import tensorstore as ts | ||
except ImportError: | ||
raise ImportError("Please install tensorstore to run this example") | ||
|
||
from ndv import NDViewer | ||
|
||
shape = (10, 4, 3, 512, 512) | ||
import ndv | ||
|
||
data = ndv.data.cells3d() | ||
|
||
ts_array = ts.open( | ||
{"driver": "zarr", "kvstore": {"driver": "memory"}}, | ||
{ | ||
"driver": "zarr", | ||
"kvstore": {"driver": "memory"}, | ||
"transform": { | ||
# tensorstore supports labeled dimensions | ||
"input_labels": ["z", "c", "y", "x"], | ||
}, | ||
}, | ||
create=True, | ||
shape=shape, | ||
dtype=ts.uint8, | ||
shape=data.shape, | ||
dtype=data.dtype, | ||
).result() | ||
ts_array[:] = np.random.randint(0, 255, size=shape, dtype=np.uint8) | ||
ts_array = ts_array[ts.d[:].label["t", "c", "z", "y", "x"]] | ||
ts_array[:] = ndv.data.cells3d() | ||
|
||
if __name__ == "__main__": | ||
qapp = QtWidgets.QApplication([]) | ||
v = NDViewer(ts_array) | ||
v.show() | ||
qapp.exec() | ||
ndv.imshow(ts_array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
from __future__ import annotations | ||
|
||
import xarray as xr | ||
from qtpy import QtWidgets | ||
|
||
from ndv import NDViewer | ||
try: | ||
import xarray as xr | ||
except ImportError: | ||
raise ImportError("Please install xarray to run this example") | ||
import ndv | ||
|
||
da = xr.tutorial.open_dataset("air_temperature").air | ||
|
||
if __name__ == "__main__": | ||
qapp = QtWidgets.QApplication([]) | ||
v = NDViewer(da, colormaps=["thermal"], channel_mode="composite") | ||
v.show() | ||
qapp.exec() | ||
ndv.imshow(da, cmap="thermal") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
from __future__ import annotations | ||
|
||
import zarr | ||
import zarr.storage | ||
from qtpy import QtWidgets | ||
import ndv | ||
|
||
try: | ||
import zarr | ||
import zarr.storage | ||
except ImportError: | ||
raise ImportError("Please `pip install zarr aiohttp` to run this example") | ||
|
||
from ndv import NDViewer | ||
|
||
URL = "https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/tczyx.ome.zarr" | ||
zarr_arr = zarr.open(URL, mode="r") | ||
|
||
if __name__ == "__main__": | ||
qapp = QtWidgets.QApplication([]) | ||
v = NDViewer(zarr_arr["s0"]) | ||
v.show() | ||
qapp.exec() | ||
ndv.imshow(zarr_arr["s0"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.