bfio 2.4.1__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.1/src/bfio.egg-info → bfio-2.4.2}/PKG-INFO +5 -5
- {bfio-2.4.1 → bfio-2.4.2}/README.md +4 -4
- {bfio-2.4.1 → bfio-2.4.2}/pyproject.toml +1 -1
- bfio-2.4.2/src/bfio/VERSION +1 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio/backends.py +61 -25
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio/bfio.py +6 -0
- {bfio-2.4.1 → bfio-2.4.2/src/bfio.egg-info}/PKG-INFO +5 -5
- {bfio-2.4.1 → bfio-2.4.2}/tests/test_write.py +62 -0
- bfio-2.4.1/src/bfio/VERSION +0 -1
- {bfio-2.4.1 → bfio-2.4.2}/LICENSE +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/setup.cfg +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio/__init__.py +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio/base_classes.py +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio/ts_backends.py +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio/utils.py +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio.egg-info/SOURCES.txt +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio.egg-info/dependency_links.txt +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio.egg-info/requires.txt +0 -0
- {bfio-2.4.1 → bfio-2.4.2}/src/bfio.egg-info/top_level.txt +0 -0
- {bfio-2.4.1 → 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>
|
|
@@ -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
|
|
|
@@ -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__(
|
|
@@ -1070,6 +1071,11 @@ class BioWriter(BioBase):
|
|
|
1070
1071
|
setattr(self, k, v)
|
|
1071
1072
|
|
|
1072
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
|
+
|
|
1073
1079
|
# Ensure backend is supported
|
|
1074
1080
|
if self._backend_name == "python":
|
|
1075
1081
|
self._backend = backends.PythonWriter(self)
|
|
@@ -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>
|
|
@@ -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
|
|
|
@@ -105,6 +105,68 @@ class TestOmeTiffWrite(unittest.TestCase):
|
|
|
105
105
|
assert np.array_equal(image[:], br[:])
|
|
106
106
|
|
|
107
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
|
+
|
|
108
170
|
class TestOmeZarrWriter(unittest.TestCase):
|
|
109
171
|
|
|
110
172
|
def test_write_zarr_tensorstore(self):
|
bfio-2.4.1/src/bfio/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.4.1
|
|
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
|
|
File without changes
|
|
File without changes
|