bfio 2.4.0__tar.gz → 2.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bfio-2.4.0/src/bfio.egg-info → bfio-2.4.2}/PKG-INFO +6 -6
- {bfio-2.4.0 → bfio-2.4.2}/README.md +4 -4
- {bfio-2.4.0 → bfio-2.4.2}/pyproject.toml +3 -3
- bfio-2.4.2/src/bfio/VERSION +1 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio/backends.py +61 -25
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio/bfio.py +17 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio/ts_backends.py +20 -1
- {bfio-2.4.0 → bfio-2.4.2/src/bfio.egg-info}/PKG-INFO +6 -6
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio.egg-info/requires.txt +1 -1
- {bfio-2.4.0 → bfio-2.4.2}/tests/test_write.py +92 -6
- bfio-2.4.0/src/bfio/VERSION +0 -1
- {bfio-2.4.0 → bfio-2.4.2}/LICENSE +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/setup.cfg +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio/__init__.py +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio/base_classes.py +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio/utils.py +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio.egg-info/SOURCES.txt +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio.egg-info/dependency_links.txt +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/src/bfio.egg-info/top_level.txt +0 -0
- {bfio-2.4.0 → bfio-2.4.2}/tests/test_read.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bfio
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.2
|
|
4
4
|
Summary: Simple reading and writing classes for tiled tiffs using Bio-Formats.
|
|
5
5
|
Author-email: Nick Schaub <nick.schaub@nih.gov>, Sameeul Bashir Samee <sameeul.samee@axleinfo.com>
|
|
6
6
|
Maintainer-email: Sameeul Bashir Samee <sameeul.samee@axleinfo.com>
|
|
@@ -36,7 +36,7 @@ Requires-Python: >=3.8
|
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
License-File: LICENSE
|
|
38
38
|
Requires-Dist: imagecodecs>=2021.2.26
|
|
39
|
-
Requires-Dist: numpy
|
|
39
|
+
Requires-Dist: numpy
|
|
40
40
|
Requires-Dist: ome-types>=0.4.2
|
|
41
41
|
Requires-Dist: zarr>=2.6.1
|
|
42
42
|
Requires-Dist: scyjava
|
|
@@ -47,7 +47,7 @@ Provides-Extra: dev
|
|
|
47
47
|
Requires-Dist: ome_zarr; extra == "dev"
|
|
48
48
|
Requires-Dist: requests>=2.26.0; extra == "dev"
|
|
49
49
|
|
|
50
|
-
# **B**io**F**ormats **I**nput/**O**utput utility (bfio 2.4.
|
|
50
|
+
# **B**io**F**ormats **I**nput/**O**utput utility (bfio 2.4.2)
|
|
51
51
|
|
|
52
52
|
[](https://bfio.readthedocs.io/en/latest/?badge=latest)
|
|
53
53
|
[](https://pypi.org/project/bfio/)
|
|
@@ -99,15 +99,15 @@ be installed using pip:
|
|
|
99
99
|
|
|
100
100
|
## Docker
|
|
101
101
|
|
|
102
|
-
### polusai/bfio:2.4.
|
|
102
|
+
### polusai/bfio:2.4.2
|
|
103
103
|
|
|
104
104
|
Ubuntu based container with bfio and all dependencies (including Java).
|
|
105
105
|
|
|
106
|
-
### polusai/bfio:2.4.
|
|
106
|
+
### polusai/bfio:2.4.2-imagej
|
|
107
107
|
|
|
108
108
|
Same as above, except comes with ImageJ and PyImageJ.
|
|
109
109
|
|
|
110
|
-
### polusai/bfio:2.4.
|
|
110
|
+
### polusai/bfio:2.4.2-tensorflow
|
|
111
111
|
|
|
112
112
|
Tensorflow container with bfio installed.
|
|
113
113
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# **B**io**F**ormats **I**nput/**O**utput utility (bfio 2.4.
|
|
1
|
+
# **B**io**F**ormats **I**nput/**O**utput utility (bfio 2.4.2)
|
|
2
2
|
|
|
3
3
|
[](https://bfio.readthedocs.io/en/latest/?badge=latest)
|
|
4
4
|
[](https://pypi.org/project/bfio/)
|
|
@@ -50,15 +50,15 @@ be installed using pip:
|
|
|
50
50
|
|
|
51
51
|
## Docker
|
|
52
52
|
|
|
53
|
-
### polusai/bfio:2.4.
|
|
53
|
+
### polusai/bfio:2.4.2
|
|
54
54
|
|
|
55
55
|
Ubuntu based container with bfio and all dependencies (including Java).
|
|
56
56
|
|
|
57
|
-
### polusai/bfio:2.4.
|
|
57
|
+
### polusai/bfio:2.4.2-imagej
|
|
58
58
|
|
|
59
59
|
Same as above, except comes with ImageJ and PyImageJ.
|
|
60
60
|
|
|
61
|
-
### polusai/bfio:2.4.
|
|
61
|
+
### polusai/bfio:2.4.2-tensorflow
|
|
62
62
|
|
|
63
63
|
Tensorflow container with bfio installed.
|
|
64
64
|
|
|
@@ -5,7 +5,7 @@ requires = [
|
|
|
5
5
|
"setuptools",
|
|
6
6
|
"wheel",
|
|
7
7
|
"imagecodecs>=2021.2.26",
|
|
8
|
-
"numpy
|
|
8
|
+
"numpy",
|
|
9
9
|
"ome-types>=0.4.2",
|
|
10
10
|
"zarr>=2.6.1",
|
|
11
11
|
"scyjava",
|
|
@@ -21,7 +21,7 @@ name = "bfio"
|
|
|
21
21
|
dynamic = ["version"]
|
|
22
22
|
dependencies = [
|
|
23
23
|
"imagecodecs>=2021.2.26",
|
|
24
|
-
"numpy
|
|
24
|
+
"numpy",
|
|
25
25
|
"ome-types>=0.4.2",
|
|
26
26
|
"zarr>=2.6.1",
|
|
27
27
|
"scyjava",
|
|
@@ -86,7 +86,7 @@ namespaces = false
|
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
[tool.bumpversion]
|
|
89
|
-
current_version = "2.4.
|
|
89
|
+
current_version = "2.4.2"
|
|
90
90
|
commit = true
|
|
91
91
|
tag = true
|
|
92
92
|
commit_args = "--no-verify"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.4.2
|
|
@@ -617,7 +617,15 @@ class PythonWriter(bfio.base_classes.AbstractWriter):
|
|
|
617
617
|
f"Image:{Path(self.frontend._file_path).name}"
|
|
618
618
|
)
|
|
619
619
|
|
|
620
|
-
if
|
|
620
|
+
if (
|
|
621
|
+
self.frontend.X
|
|
622
|
+
* self.frontend.Y
|
|
623
|
+
* self.frontend.Z
|
|
624
|
+
* self.frontend.C
|
|
625
|
+
* self.frontend.T
|
|
626
|
+
* self.frontend.bpp
|
|
627
|
+
> 2**31
|
|
628
|
+
):
|
|
621
629
|
big_tiff = True
|
|
622
630
|
else:
|
|
623
631
|
big_tiff = False
|
|
@@ -1405,8 +1413,9 @@ try:
|
|
|
1405
1413
|
In the future, it may be reasonable to not enforce read-only
|
|
1406
1414
|
|
|
1407
1415
|
"""
|
|
1408
|
-
if self.frontend.
|
|
1409
|
-
|
|
1416
|
+
if self.frontend.append is False:
|
|
1417
|
+
if self.frontend._file_path.exists():
|
|
1418
|
+
shutil.rmtree(self.frontend._file_path)
|
|
1410
1419
|
|
|
1411
1420
|
shape = (
|
|
1412
1421
|
self.frontend.T,
|
|
@@ -1417,8 +1426,12 @@ try:
|
|
|
1417
1426
|
)
|
|
1418
1427
|
|
|
1419
1428
|
compressor = Blosc(cname="zstd", clevel=1, shuffle=Blosc.SHUFFLE)
|
|
1420
|
-
|
|
1421
|
-
|
|
1429
|
+
mode = "w"
|
|
1430
|
+
if self.frontend.append is True:
|
|
1431
|
+
mode = "a"
|
|
1432
|
+
self._root = zarr.open_group(
|
|
1433
|
+
store=str(self.frontend._file_path.resolve()), mode=mode
|
|
1434
|
+
)
|
|
1422
1435
|
|
|
1423
1436
|
# Create the metadata
|
|
1424
1437
|
metadata_path = (
|
|
@@ -1426,30 +1439,53 @@ try:
|
|
|
1426
1439
|
.joinpath("OME")
|
|
1427
1440
|
.joinpath("METADATA.ome.xml")
|
|
1428
1441
|
)
|
|
1429
|
-
metadata_path.parent.mkdir(parents=True, exist_ok=True)
|
|
1430
|
-
with open(metadata_path, "w") as fw:
|
|
1431
|
-
fw.write(str(self.frontend._metadata.to_xml()))
|
|
1432
|
-
|
|
1433
|
-
self._root.attrs["multiscales"] = [
|
|
1434
|
-
{
|
|
1435
|
-
"version": "0.1",
|
|
1436
|
-
"name": self.frontend._file_path.name,
|
|
1437
|
-
"datasets": [{"path": "0"}],
|
|
1438
|
-
"metadata": {"method": "mean"},
|
|
1439
|
-
}
|
|
1440
|
-
]
|
|
1441
1442
|
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1443
|
+
if self.frontend.append is False or (
|
|
1444
|
+
self.frontend.append is True and metadata_path.exists() is False
|
|
1445
|
+
):
|
|
1446
|
+
metadata_path.parent.mkdir(parents=True, exist_ok=True)
|
|
1447
|
+
with open(metadata_path, "w") as fw:
|
|
1448
|
+
fw.write(str(self.frontend._metadata.to_xml()))
|
|
1449
|
+
|
|
1450
|
+
self._root.attrs["multiscales"] = [
|
|
1451
|
+
{
|
|
1452
|
+
"version": "0.1",
|
|
1453
|
+
"name": self.frontend._file_path.name,
|
|
1454
|
+
"datasets": [{"path": "0"}],
|
|
1455
|
+
"metadata": {"method": "mean"},
|
|
1456
|
+
}
|
|
1457
|
+
]
|
|
1458
|
+
if (
|
|
1459
|
+
self.frontend.append is True
|
|
1460
|
+
and len(sorted(self._root.array_keys())) > 0
|
|
1461
|
+
):
|
|
1462
|
+
writer = self._root["0"]
|
|
1463
|
+
else:
|
|
1464
|
+
writer = self._root.zeros(
|
|
1465
|
+
"0",
|
|
1466
|
+
shape=shape,
|
|
1467
|
+
chunks=(
|
|
1468
|
+
1,
|
|
1469
|
+
1,
|
|
1470
|
+
1,
|
|
1471
|
+
self.frontend._TILE_SIZE,
|
|
1472
|
+
self.frontend._TILE_SIZE,
|
|
1473
|
+
),
|
|
1474
|
+
dtype=self.frontend.dtype,
|
|
1475
|
+
compressor=compressor,
|
|
1476
|
+
dimension_separator="/",
|
|
1477
|
+
)
|
|
1449
1478
|
|
|
1450
1479
|
# This is recommended to do for cloud storage to increase read/write
|
|
1451
1480
|
# speed, but it also increases write speed locally when threading.
|
|
1452
|
-
|
|
1481
|
+
consolidated_metadata_file = Path(self.frontend._file_path).joinpath(
|
|
1482
|
+
".zmetadata"
|
|
1483
|
+
)
|
|
1484
|
+
if self.frontend.append is False or (
|
|
1485
|
+
self.frontend.append is True
|
|
1486
|
+
and consolidated_metadata_file.exists() is False
|
|
1487
|
+
):
|
|
1488
|
+
zarr.consolidate_metadata(str(self.frontend._file_path.resolve()))
|
|
1453
1489
|
|
|
1454
1490
|
self._writer = writer
|
|
1455
1491
|
|
|
@@ -52,6 +52,7 @@ class BioReader(BioBase):
|
|
|
52
52
|
"_read_only",
|
|
53
53
|
"_backend",
|
|
54
54
|
"level",
|
|
55
|
+
"append",
|
|
55
56
|
]
|
|
56
57
|
|
|
57
58
|
def __init__(
|
|
@@ -1042,6 +1043,17 @@ class BioWriter(BioBase):
|
|
|
1042
1043
|
self._metadata.images[0].pixels.dimension_order = (
|
|
1043
1044
|
ome_types.model.Pixels_DimensionOrder.XYZCT
|
|
1044
1045
|
)
|
|
1046
|
+
# overwrite values in metadata if explicitly specified in the constructor
|
|
1047
|
+
if kwargs:
|
|
1048
|
+
for k, v in kwargs.items():
|
|
1049
|
+
setattr(self, k, v)
|
|
1050
|
+
if k in ("YXZCT"):
|
|
1051
|
+
setattr(
|
|
1052
|
+
self._metadata.images[0].pixels,
|
|
1053
|
+
"size_{}".format(k.lower()),
|
|
1054
|
+
v,
|
|
1055
|
+
)
|
|
1056
|
+
|
|
1045
1057
|
else:
|
|
1046
1058
|
self._metadata = self._minimal_xml()
|
|
1047
1059
|
|
|
@@ -1059,6 +1071,11 @@ class BioWriter(BioBase):
|
|
|
1059
1071
|
setattr(self, k, v)
|
|
1060
1072
|
|
|
1061
1073
|
self.set_backend(backend)
|
|
1074
|
+
self.append = False
|
|
1075
|
+
if kwargs and "append" in kwargs:
|
|
1076
|
+
if kwargs["append"] is True:
|
|
1077
|
+
self.append = True
|
|
1078
|
+
|
|
1062
1079
|
# Ensure backend is supported
|
|
1063
1080
|
if self._backend_name == "python":
|
|
1064
1081
|
self._backend = backends.PythonWriter(self)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# import core packages
|
|
3
|
+
import json
|
|
3
4
|
import logging
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
from typing import Dict
|
|
@@ -317,13 +318,15 @@ class TensorstoreWriter(bfio.base_classes.TSAbstractWriter):
|
|
|
317
318
|
)
|
|
318
319
|
|
|
319
320
|
self._writer = TSWriter(
|
|
320
|
-
str(self.frontend._file_path.resolve()),
|
|
321
|
+
str(self.frontend._file_path.joinpath("0").resolve()),
|
|
321
322
|
shape,
|
|
322
323
|
(1, 1, 1, self.frontend._TILE_SIZE, self.frontend._TILE_SIZE),
|
|
323
324
|
self.frontend.dtype,
|
|
324
325
|
"TCZYX",
|
|
325
326
|
)
|
|
326
327
|
|
|
328
|
+
self.write_metadata()
|
|
329
|
+
|
|
327
330
|
def write_metadata(self):
|
|
328
331
|
|
|
329
332
|
# Create the metadata
|
|
@@ -336,6 +339,22 @@ class TensorstoreWriter(bfio.base_classes.TSAbstractWriter):
|
|
|
336
339
|
with open(metadata_path, "w") as fw:
|
|
337
340
|
fw.write(str(self.frontend._metadata.to_xml()))
|
|
338
341
|
|
|
342
|
+
with open(self.frontend._file_path.joinpath(".zgroup"), "w") as f:
|
|
343
|
+
f.write('{\n\t"zarr_format": 2\n}')
|
|
344
|
+
|
|
345
|
+
zarr_attrs = {
|
|
346
|
+
"multiscales": [
|
|
347
|
+
{
|
|
348
|
+
"version": "0.1",
|
|
349
|
+
"name": self.frontend._file_path.name,
|
|
350
|
+
"datasets": [{"path": "0"}],
|
|
351
|
+
"metadata": {"method": "mean"},
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
}
|
|
355
|
+
with open(self.frontend._file_path.joinpath(".zattrs"), "w") as f:
|
|
356
|
+
json.dump(zarr_attrs, f, indent=4)
|
|
357
|
+
|
|
339
358
|
# This is recommended to do for cloud storage to increase read/write
|
|
340
359
|
# speed, but it also increases write speed locally when threading.
|
|
341
360
|
zarr.consolidate_metadata(str(self.frontend._file_path.resolve()))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bfio
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.2
|
|
4
4
|
Summary: Simple reading and writing classes for tiled tiffs using Bio-Formats.
|
|
5
5
|
Author-email: Nick Schaub <nick.schaub@nih.gov>, Sameeul Bashir Samee <sameeul.samee@axleinfo.com>
|
|
6
6
|
Maintainer-email: Sameeul Bashir Samee <sameeul.samee@axleinfo.com>
|
|
@@ -36,7 +36,7 @@ Requires-Python: >=3.8
|
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
License-File: LICENSE
|
|
38
38
|
Requires-Dist: imagecodecs>=2021.2.26
|
|
39
|
-
Requires-Dist: numpy
|
|
39
|
+
Requires-Dist: numpy
|
|
40
40
|
Requires-Dist: ome-types>=0.4.2
|
|
41
41
|
Requires-Dist: zarr>=2.6.1
|
|
42
42
|
Requires-Dist: scyjava
|
|
@@ -47,7 +47,7 @@ Provides-Extra: dev
|
|
|
47
47
|
Requires-Dist: ome_zarr; extra == "dev"
|
|
48
48
|
Requires-Dist: requests>=2.26.0; extra == "dev"
|
|
49
49
|
|
|
50
|
-
# **B**io**F**ormats **I**nput/**O**utput utility (bfio 2.4.
|
|
50
|
+
# **B**io**F**ormats **I**nput/**O**utput utility (bfio 2.4.2)
|
|
51
51
|
|
|
52
52
|
[](https://bfio.readthedocs.io/en/latest/?badge=latest)
|
|
53
53
|
[](https://pypi.org/project/bfio/)
|
|
@@ -99,15 +99,15 @@ be installed using pip:
|
|
|
99
99
|
|
|
100
100
|
## Docker
|
|
101
101
|
|
|
102
|
-
### polusai/bfio:2.4.
|
|
102
|
+
### polusai/bfio:2.4.2
|
|
103
103
|
|
|
104
104
|
Ubuntu based container with bfio and all dependencies (including Java).
|
|
105
105
|
|
|
106
|
-
### polusai/bfio:2.4.
|
|
106
|
+
### polusai/bfio:2.4.2-imagej
|
|
107
107
|
|
|
108
108
|
Same as above, except comes with ImageJ and PyImageJ.
|
|
109
109
|
|
|
110
|
-
### polusai/bfio:2.4.
|
|
110
|
+
### polusai/bfio:2.4.2-tensorflow
|
|
111
111
|
|
|
112
112
|
Tensorflow container with bfio installed.
|
|
113
113
|
|
|
@@ -9,6 +9,7 @@ from ome_zarr.utils import download as zarr_download
|
|
|
9
9
|
TEST_IMAGES = {
|
|
10
10
|
"Plate1-Blue-A-12-Scene-3-P3-F2-03.czi": "https://downloads.openmicroscopy.org/images/Zeiss-CZI/idr0011/Plate1-Blue-A_TS-Stinger/Plate1-Blue-A-12-Scene-3-P3-F2-03.czi",
|
|
11
11
|
"5025551.zarr": "https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0054A/5025551.zarr",
|
|
12
|
+
"0.tif": "https://osf.io/j6aer/download",
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
TEST_DIR = pathlib.Path(__file__).with_name("data")
|
|
@@ -43,12 +44,14 @@ def setUpModule():
|
|
|
43
44
|
shutil.rmtree(TEST_DIR.joinpath(file))
|
|
44
45
|
zarr_download(url, str(TEST_DIR))
|
|
45
46
|
|
|
47
|
+
|
|
46
48
|
def tearDownModule():
|
|
47
49
|
"""Remove test images"""
|
|
48
50
|
|
|
49
51
|
logger.info("teardown - Removing test images...")
|
|
50
52
|
shutil.rmtree(TEST_DIR)
|
|
51
53
|
|
|
54
|
+
|
|
52
55
|
class TestOmeTiffWrite(unittest.TestCase):
|
|
53
56
|
@classmethod
|
|
54
57
|
def setUpClass(self):
|
|
@@ -102,6 +105,68 @@ class TestOmeTiffWrite(unittest.TestCase):
|
|
|
102
105
|
assert np.array_equal(image[:], br[:])
|
|
103
106
|
|
|
104
107
|
|
|
108
|
+
class TestPythonZarrWriter(unittest.TestCase):
|
|
109
|
+
|
|
110
|
+
def test_write_zarr_append_no_file(self):
|
|
111
|
+
|
|
112
|
+
with bfio.BioReader(str(TEST_DIR.joinpath("5025551.zarr"))) as br:
|
|
113
|
+
|
|
114
|
+
actual_shape = br.shape
|
|
115
|
+
actual_dtype = br.dtype
|
|
116
|
+
actual_image = br[:]
|
|
117
|
+
actual_mdata = br.metadata
|
|
118
|
+
print(br.shape)
|
|
119
|
+
with tempfile.TemporaryDirectory() as dir:
|
|
120
|
+
|
|
121
|
+
test_file_path = os.path.join(dir, "out/test.ome.zarr")
|
|
122
|
+
|
|
123
|
+
with bfio.BioWriter(
|
|
124
|
+
test_file_path, metadata=actual_mdata, backend="zarr", append=True
|
|
125
|
+
) as bw:
|
|
126
|
+
|
|
127
|
+
expanded = np.expand_dims(actual_image, axis=-1)
|
|
128
|
+
bw[:, :, :, :, :] = expanded[:, :, :, :, :]
|
|
129
|
+
|
|
130
|
+
with bfio.BioReader(test_file_path) as br:
|
|
131
|
+
|
|
132
|
+
assert br.shape == actual_shape
|
|
133
|
+
assert br.dtype == actual_dtype
|
|
134
|
+
|
|
135
|
+
assert br[:].sum() == actual_image.sum()
|
|
136
|
+
|
|
137
|
+
def test_write_zarr_append_file_exist(self):
|
|
138
|
+
|
|
139
|
+
with bfio.BioReader(str(TEST_DIR.joinpath("5025551.zarr"))) as br:
|
|
140
|
+
|
|
141
|
+
actual_shape = br.shape
|
|
142
|
+
actual_dtype = br.dtype
|
|
143
|
+
actual_image = br[:]
|
|
144
|
+
actual_mdata = br.metadata
|
|
145
|
+
with tempfile.TemporaryDirectory() as dir:
|
|
146
|
+
|
|
147
|
+
test_file_path = os.path.join(dir, "out/test.ome.zarr")
|
|
148
|
+
|
|
149
|
+
with bfio.BioWriter(
|
|
150
|
+
test_file_path, metadata=actual_mdata, backend="zarr"
|
|
151
|
+
) as bw:
|
|
152
|
+
|
|
153
|
+
expanded = np.expand_dims(actual_image, axis=-1)
|
|
154
|
+
bw[:, :, :, 0:13, :] = expanded[:, :, :, 0:13, :]
|
|
155
|
+
|
|
156
|
+
with bfio.BioWriter(
|
|
157
|
+
test_file_path, metadata=actual_mdata, backend="zarr", append=True
|
|
158
|
+
) as bw:
|
|
159
|
+
|
|
160
|
+
expanded = np.expand_dims(actual_image, axis=-1)
|
|
161
|
+
bw[:, :, :, 13:, :] = expanded[:, :, :, 13:, :]
|
|
162
|
+
with bfio.BioReader(test_file_path) as br:
|
|
163
|
+
|
|
164
|
+
assert br.shape == actual_shape
|
|
165
|
+
assert br.dtype == actual_dtype
|
|
166
|
+
|
|
167
|
+
assert br[:].sum() == actual_image.sum()
|
|
168
|
+
|
|
169
|
+
|
|
105
170
|
class TestOmeZarrWriter(unittest.TestCase):
|
|
106
171
|
|
|
107
172
|
def test_write_zarr_tensorstore(self):
|
|
@@ -110,25 +175,46 @@ class TestOmeZarrWriter(unittest.TestCase):
|
|
|
110
175
|
|
|
111
176
|
actual_shape = br.shape
|
|
112
177
|
actual_dtype = br.dtype
|
|
113
|
-
|
|
114
178
|
actual_image = br[:]
|
|
115
|
-
|
|
116
179
|
actual_mdata = br.metadata
|
|
117
|
-
|
|
118
180
|
with tempfile.TemporaryDirectory() as dir:
|
|
119
181
|
|
|
120
182
|
# Use the temporary directory
|
|
121
|
-
test_file_path = os.path.join(dir,
|
|
183
|
+
test_file_path = os.path.join(dir, "out/test.ome.zarr")
|
|
122
184
|
|
|
123
|
-
with bfio.BioWriter(
|
|
185
|
+
with bfio.BioWriter(
|
|
186
|
+
test_file_path, metadata=actual_mdata, backend="tensorstore"
|
|
187
|
+
) as bw:
|
|
124
188
|
|
|
125
189
|
expanded = np.expand_dims(actual_image, axis=-1)
|
|
126
190
|
bw[:] = expanded
|
|
127
191
|
|
|
128
192
|
with bfio.BioReader(test_file_path) as br:
|
|
129
193
|
|
|
130
|
-
|
|
131
194
|
assert br.shape == actual_shape
|
|
132
195
|
assert br.dtype == actual_dtype
|
|
133
196
|
|
|
134
197
|
assert br[:].sum() == actual_image.sum()
|
|
198
|
+
|
|
199
|
+
def test_overwrite_metadata(self):
|
|
200
|
+
|
|
201
|
+
with bfio.BioReader(str(TEST_DIR.joinpath("0.tif"))) as br:
|
|
202
|
+
with tempfile.TemporaryDirectory() as dir:
|
|
203
|
+
|
|
204
|
+
# Use the temporary directory
|
|
205
|
+
test_file_path = os.path.join(dir, "out/0.ome.zarr")
|
|
206
|
+
|
|
207
|
+
with bfio.BioWriter(
|
|
208
|
+
test_file_path,
|
|
209
|
+
metadata=br.metadata,
|
|
210
|
+
backend="tensorstore",
|
|
211
|
+
Z=br.Z * 2,
|
|
212
|
+
) as bw:
|
|
213
|
+
|
|
214
|
+
bw[:, :, 0, :, :] = br[:]
|
|
215
|
+
bw[:, :, 1, :, :] = br[:]
|
|
216
|
+
|
|
217
|
+
bw_z_dim = bw.Z
|
|
218
|
+
|
|
219
|
+
with bfio.BioReader(test_file_path) as br2:
|
|
220
|
+
assert br2.Z == bw_z_dim
|
bfio-2.4.0/src/bfio/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.4.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|