Skip to content

Commit b05ff5b

Browse files
authored
Merge pull request #58 from janelia-cellmap/blockwise
fix blockwise process
2 parents 3bd42e3 + 17112e6 commit b05ff5b

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

cellmap_flow/blockwise/blockwise_processor.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(self, yaml_config: str, create=True):
9797
self.inferencer = Inferencer(self.model_config)
9898

9999
self.idi_raw = ImageDataInterface(
100-
self.input_path, target_resolution=self.input_voxel_size
100+
self.input_path, voxel_size=self.input_voxel_size
101101
)
102102
self.output_arrays = []
103103

@@ -112,16 +112,19 @@ def __init__(self, yaml_config: str, create=True):
112112
print(f"output_path: {self.output_path}")
113113
for channel in self.output_channels:
114114
if create:
115-
array = prepare_ds(
116-
DirectoryStore(self.output_path / channel / "s0"),
117-
output_shape,
118-
dtype=self.dtype,
119-
chunk_shape=self.block_shape,
120-
voxel_size=self.output_voxel_size,
121-
axis_names=["z", "y", "x"],
122-
units=["nm", "nm", "nm"],
123-
offset=(0, 0, 0),
124-
)
115+
try:
116+
array = prepare_ds(
117+
DirectoryStore(self.output_path / channel / "s0"),
118+
output_shape,
119+
dtype=self.dtype,
120+
chunk_shape=self.block_shape,
121+
voxel_size=self.output_voxel_size,
122+
axis_names=["z", "y", "x"],
123+
units=["nm", "nm", "nm"],
124+
offset=(0, 0, 0),
125+
)
126+
except Exception as e:
127+
raise Exception(f"Failed to prepare {self.output_path/channel/'s0'} \n try deleting it manually and run again ! {e}")
125128
else:
126129
try:
127130
array = open_ds(
@@ -130,11 +133,11 @@ def __init__(self, yaml_config: str, create=True):
130133
)
131134
except Exception as e:
132135
raise Exception(f"Failed to open {self.output_path/channel}\n{e}")
133-
self.outpout_arrays.append(array)
136+
self.output_arrays.append(array)
134137

135138
def process_fn(self, block):
136139

137-
write_roi = block.write_roi.intersect(self.outpout_arrays[0].roi)
140+
write_roi = block.write_roi.intersect(self.output_arrays[0].roi)
138141

139142
if write_roi.empty:
140143
print(f"empty write roi: {write_roi}")
@@ -144,10 +147,10 @@ def process_fn(self, block):
144147

145148
chunk_data = chunk_data.astype(self.dtype)
146149

147-
# if self.outpout_arrays[0][block.write_roi].any():
150+
# if self.output_arrays[0][block.write_roi].any():
148151
# return
149152

150-
for i, array in enumerate(self.outpout_arrays):
153+
for i, array in enumerate(self.output_arrays):
151154

152155
if chunk_data.shape == 3:
153156
if len(self.output_channels) > 1:

cellmap_flow/globals.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ def __repr__(self):
4848
def __str__(self):
4949
return f"Flow({self.__dict__})"
5050

51-
def get_output_dtype(self):
51+
def get_output_dtype(self,model_output_dtype=None):
5252
dtype = np.float32
5353

54+
if model_output_dtype is not None:
55+
dtype = model_output_dtype
56+
5457
if len(self.input_norms) > 0:
5558
for norm in self.input_norms[::-1]:
5659
if norm.dtype:

0 commit comments

Comments
 (0)