|
6 | 6 | from natsort import natsorted |
7 | 7 |
|
8 | 8 | from .mag import Mag |
9 | | -from .downsampling import downsample_cube, parse_interpolation_mode |
| 9 | +from .downsampling import parse_interpolation_mode, downsample_unpadded_data |
10 | 10 | from .utils import ( |
11 | 11 | get_chunks, |
12 | 12 | find_files, |
@@ -193,29 +193,6 @@ def cubing_job(args): |
193 | 193 | raise exc |
194 | 194 |
|
195 | 195 |
|
196 | | -def downsample_unpadded_data(buffer, target_mag, interpolation_mode): |
197 | | - logging.info( |
198 | | - f"Downsampling buffer of size {buffer.shape} to mag {target_mag.to_layer_name()}" |
199 | | - ) |
200 | | - target_mag_np = np.array(target_mag.to_array()) |
201 | | - current_dimension_size = np.array(buffer.shape[1:]) |
202 | | - padding_size_for_downsampling = ( |
203 | | - target_mag_np - (current_dimension_size % target_mag_np) % target_mag_np |
204 | | - ) |
205 | | - padding_size_for_downsampling = list(zip([0, 0, 0], padding_size_for_downsampling)) |
206 | | - buffer = np.pad( |
207 | | - buffer, pad_width=[(0, 0)] + padding_size_for_downsampling, mode="constant" |
208 | | - ) |
209 | | - dimension_decrease = np.array([1] + target_mag.to_array()) |
210 | | - downsampled_buffer_shape = np.array(buffer.shape) // dimension_decrease |
211 | | - downsampled_buffer = np.empty(dtype=buffer.dtype, shape=downsampled_buffer_shape) |
212 | | - for channel in range(buffer.shape[0]): |
213 | | - downsampled_buffer[channel] = downsample_cube( |
214 | | - buffer[channel], target_mag.to_array(), interpolation_mode |
215 | | - ) |
216 | | - return downsampled_buffer |
217 | | - |
218 | | - |
219 | 196 | def cubing(source_path, target_path, layer_name, dtype, batch_size, args=None) -> dict: |
220 | 197 |
|
221 | 198 | target_mag = Mag(args.target_mag) |
|
0 commit comments