11from typing import Optional , Sequence , Union
22import numpy as np
33import tifffile
4+ import tqdm
45import matplotlib .pyplot as plt
56from mpl_toolkits .axes_grid1 .inset_locator import zoomed_inset_axes , mark_inset
7+ from pyxalign .data_structures .task import load_task
68from pyxalign .plotting .plotters import add_scalebar
79from pyxalign .transformations .functions import image_crop
810
@@ -286,3 +288,28 @@ def _clamped_crop_bounds(h: int, w: int, crop: int, cy: int, cx: int):
286288 if y2 - y1 < 1 :
287289 y2 = min (h , y1 + 1 )
288290 return x1 , x2 , y1 , y2
291+
292+
293+ def collect_volumes_from_task_files (
294+ file_paths : list [str ],
295+ rotate_volumes : bool = False ,
296+ volume_width_multiplier : Optional [float ] = None ,
297+ rotation_angles : Optional [list [float ]] = None ,
298+ ):
299+ volumes = []
300+ for i , path in tqdm .tqdm (enumerate (file_paths )):
301+ task = load_task (path , exclude = "complex_projections" )
302+ if volume_width_multiplier is not None :
303+ task .phase_projections .options .volume_width .use_custom_width = True
304+ task .phase_projections .options .volume_width .multiplier = volume_width_multiplier
305+ task .phase_projections .masks = None
306+ task .phase_projections .apply_staged_shift ()
307+ task .phase_projections .get_3D_reconstruction ()
308+ if i == 0 and rotate_volumes and (rotation_angles is None ):
309+ task .phase_projections .volume .get_optimal_rotation_of_reconstruction ()
310+ rotation_angles = task .phase_projections .volume .optimal_rotation_angles
311+ if rotate_volumes :
312+ task .phase_projections .volume .optimal_rotation_angles = rotation_angles
313+ task .phase_projections .volume .rotate_reconstruction ()
314+ volumes += [task .phase_projections .volume .data ]
315+ return volumes
0 commit comments