Skip to content

Commit 1fefe2e

Browse files
committed
Fix single file output
- now creates directories for temp and slices appropriately - now passes correct file path to pipeline - no longer creates unnessecary folder during single file output
1 parent 722824a commit 1fefe2e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

python/ouroboros/pipeline/slice_parallel_pipeline.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import numpy as np
2424
import concurrent.futures
2525
from tifffile import imwrite, memmap
26-
import os
2726
import multiprocessing
2827
import time
2928

@@ -68,21 +67,19 @@ def _process(self, input_data: tuple[any]) -> None | str:
6867
if len(slice_rects) == 0:
6968
return "No slice rects were provided."
7069

71-
# Create a folder with the same name as the output file
72-
folder_name = join_path(
73-
config.output_file_folder,
74-
format_slice_output_multiple(config.output_file_name),
75-
)
70+
# Makes output file folder
71+
Path(config.output_file_folder).mkdir(parents=True, exist_ok=True)
7672

73+
# Create a folder with the same name as the output file
7774
if config.make_single_file:
78-
os.makedirs(folder_name, exist_ok=True)
75+
output_file_path = join_path(config.output_file_folder, format_slice_output_file(config.output_file_name))
76+
else:
77+
output_folder = Path(config.output_file_folder, format_slice_output_multiple(config.output_file_name))
78+
output_folder.mkdir(parents=True, exist_ok=True)
7979

80-
output_file_path = join_path(
81-
config.output_file_folder, format_slice_output_file(config.output_file_name)
82-
)
8380
temp_file_path = Path(
84-
config.output_file_folder, format_slice_output_file(config.output_file_name)
85-
).with_suffix(".temptif")
81+
config.output_file_folder, f"{config.output_file_name}_temp"
82+
).with_suffix(".tif")
8683

8784
# Start setting up metadata
8885
# Volume cache resolution is in voxel size, but .tiff XY resolution is in voxels per unit, so we invert.
@@ -203,7 +200,7 @@ def processor_completed(future):
203200
else:
204201
pool.starmap(write_normalized,
205202
[(temp_file,
206-
partial(imwrite, join_path(folder_name, format_tiff_name(i, num_digits)), **tiff_metadata), # noqa: E501
203+
partial(imwrite, output_folder.joinpath(format_tiff_name(i, num_digits)), **tiff_metadata), # noqa: E501
207204
convert_func,
208205
i) for i in range(len(temp_file))])
209206
del temp_file
@@ -213,7 +210,10 @@ def processor_completed(future):
213210
return f"Error downloading data: {e}"
214211

215212
# Update the pipeline input with the output file path
216-
pipeline_input.output_file_path = output_file_path
213+
if config.make_single_file:
214+
pipeline_input.output_file_path = output_file_path
215+
else:
216+
pipeline_input.output_file_path = str(output_folder)
217217

218218
return None
219219

0 commit comments

Comments
 (0)