@@ -127,18 +127,25 @@ def _process(self, input_data: any) -> tuple[any, None] | tuple[None, any]:
127127 print (f"\n Front Projection Shape: { FPShape } " )
128128 print (f"\n Back Projection Shape (Z/Y/X):{ write_shape } " )
129129
130- pipeline_input .output_file_path = f"{ config .output_file_name } _{ '_' .join (map (str , full_bounding_box .get_min (np .uint32 )))} "
130+ pipeline_input .output_file_path = (f"{ config .output_file_name } _"
131+ f"{ '_' .join (map (str , full_bounding_box .get_min (np .uint32 )))} " )
131132 folder_path = Path (config .output_file_folder , pipeline_input .output_file_path )
132133 folder_path .mkdir (exist_ok = True , parents = True )
133134
134135 i_path = Path (config .output_file_folder ,
135136 f"{ config .output_file_name } _t_{ '_' .join (map (str , full_bounding_box .get_min (np .uint32 )))} " )
136137
137138 if config .make_single_file :
138- is_big_tiff = calculate_gigabytes_from_dimensions (np .prod (write_shape ), np .uint16 ) > 4 # Check Dtype
139+ is_big_tiff = calculate_gigabytes_from_dimensions (
140+ np .prod (write_shape ),
141+ np .uint8 if config .make_backprojection_binary else np .uint16 ) > 4
139142 else :
140- is_big_tiff = calculate_gigabytes_from_dimensions (np .prod (write_shape [1 :]), np .uint16 ) > 4 # Check Dtype
143+ is_big_tiff = calculate_gigabytes_from_dimensions (
144+ np .prod (write_shape [1 :]),
145+ np .uint8 if config .make_backprojection_binary else np .uint16 ) > 4
141146
147+ # Generate image writing function
148+ # Combining compression with binary images can cause issues.
142149 bp_offset = pipeline_input .backprojection_offset if config .backproject_min_bounding_box else None
143150 tif_write = partial (generate_tiff_write ,
144151 compression = config .backprojection_compression ,
@@ -205,7 +212,9 @@ def note_written(write_future):
205212 write_futures .append (write_executor .submit (
206213 write_conv_vol ,
207214 tif_write (tifffile .imwrite ), i_path .joinpath (f"i_{ index :05} " ),
208- ImgSlice (* write_shape [1 :]), np .uint16 , folder_path .joinpath (f"{ index :05} .tif" )
215+ ImgSlice (* write_shape [1 :]),
216+ bool if config .make_backprojection_binary else np .uint16 ,
217+ folder_path .joinpath (f"{ index :05} .tif" )
209218 ))
210219 write_futures [- 1 ].add_done_callback (note_written )
211220
@@ -265,8 +274,8 @@ def note_written(write_future):
265274 pipeline_input .backprojected_folder_path = folder_path
266275
267276 self .add_timing ("export" , time .perf_counter () - start )
268-
269- if config .make_single_file :
277+
278+ if config .make_single_file :
270279 shutil .rmtree (folder_path )
271280
272281 return None
@@ -285,8 +294,13 @@ def process_chunk(
285294 start_total = time .perf_counter ()
286295
287296 # Load the straightened volume
288- straightened_volume = tifffile .memmap (straightened_volume_path , mode = "r" )
289- durations ["memmap" ] = [time .perf_counter () - start_total ]
297+ try :
298+ straightened_volume = tifffile .memmap (straightened_volume_path , mode = "r" )
299+ durations ["memmap" ] = [time .perf_counter () - start_total ]
300+ except BaseException as be :
301+ print (f"Error loading Volume: { be } : { straightened_volume_path } " )
302+ traceback .print_tb (be .__traceback__ , file = sys .stderr )
303+ raise be
290304
291305 # Get the slices from the straightened volume Dumb but maybe bugfix?
292306 start = time .perf_counter ()
0 commit comments