-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathupload_image_data.py
45 lines (32 loc) · 1.38 KB
/
upload_image_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import numpy as np
from skimage import data
import webknossos as wk
from webknossos.dataset import COLOR_CATEGORY
from webknossos.dataset.properties import (
DatasetViewConfiguration,
LayerViewConfiguration,
)
def main() -> None:
# load your data - we use an example 3D dataset here
img = data.cells3d() # (z, c, y, x)
# make sure that the dimension of your data has the right order
# we expect the following dimensions: Channels, X, Y, Z.
img = np.transpose(img, [1, 3, 2, 0])
# choose name and voxel size (voxel_size is defined in nm)
ds = wk.Dataset("cell_dataset", voxel_size=(260, 260, 290))
ds.default_view_configuration = DatasetViewConfiguration(zoom=0.35)
# The example microscopy data has two channels
# Channel 0 contains cell membranes, channel 1 contains nuclei.
layer_membranes = ds.write_layer("cell_membranes", COLOR_CATEGORY, data=img[0, :])
layer_membranes.default_view_configuration = LayerViewConfiguration(
color=(17, 212, 17), intensity_range=(0, 16000)
)
layer_nuclei = ds.write_layer("nuclei", COLOR_CATEGORY, data=img[1, :])
layer_nuclei.default_view_configuration = LayerViewConfiguration(
color=(212, 17, 17), intensity_range=(3000, 30000)
)
remote_dataset = ds.upload()
url = remote_dataset.url
print(f"Successfully uploaded {url}")
if __name__ == "__main__":
main()