From 5572d979992d1bb50429459b051ce89cd1ca70ac Mon Sep 17 00:00:00 2001 From: Miro Astore Date: Mon, 19 Aug 2024 15:36:37 -0400 Subject: [PATCH 1/2] added serial code for centering every volume --- .../_preprocessing/align_utils.py | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/cryo_challenge/_preprocessing/align_utils.py b/src/cryo_challenge/_preprocessing/align_utils.py index cbbb6a1..4a976b5 100644 --- a/src/cryo_challenge/_preprocessing/align_utils.py +++ b/src/cryo_challenge/_preprocessing/align_utils.py @@ -134,21 +134,23 @@ def align_submission( -------- volumes (torch.Tensor): aligned submission volumes """ - obj_vol = volumes[0].numpy().astype(np.float32) - - obj_vol = Volume(obj_vol / obj_vol.sum()) - ref_vol = Volume(ref_volume / ref_volume.sum()) - - _, R_est = align_BO( - ref_vol, - obj_vol, - loss_type=params["BOT_loss"], - downsampled_size=params["BOT_box_size"], - max_iters=params["BOT_iter"], - refine=params["BOT_refine"], - ) - R_est = Rotation(R_est.astype(np.float32)) - - volumes = torch.from_numpy(Volume(volumes.numpy()).rotate(R_est)._data) + for i in range(len(volumes)): + print('aligning ' + str(i) + 'th volume' ) + obj_vol = volumes[i].numpy().astype(np.float32) + + obj_vol = Volume(obj_vol / obj_vol.sum()) + ref_vol = Volume(ref_volume / ref_volume.sum()) + + _, R_est = align_BO( + ref_vol, + obj_vol, + loss_type=params["BOT_loss"], + downsampled_size=params["BOT_box_size"], + max_iters=params["BOT_iter"], + refine=params["BOT_refine"], + ) + R_est = Rotation(R_est.astype(np.float32)) + + volumes[i] = torch.from_numpy(Volume(volumes[i].numpy()).rotate(R_est)._data) return volumes From 94b07dd79ec066b39d49cdbd7045061c1e40363d Mon Sep 17 00:00:00 2001 From: Miro Astore Date: Tue, 20 Aug 2024 10:31:29 -0400 Subject: [PATCH 2/2] element wise volume alignment --- src/cryo_challenge/_preprocessing/align_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cryo_challenge/_preprocessing/align_utils.py b/src/cryo_challenge/_preprocessing/align_utils.py index 4a976b5..d2a7784 100644 --- a/src/cryo_challenge/_preprocessing/align_utils.py +++ b/src/cryo_challenge/_preprocessing/align_utils.py @@ -135,11 +135,10 @@ def align_submission( volumes (torch.Tensor): aligned submission volumes """ for i in range(len(volumes)): - print('aligning ' + str(i) + 'th volume' ) - obj_vol = volumes[i].numpy().astype(np.float32) + obj_vol = volumes[i].numpy().astype(np.float32).copy() obj_vol = Volume(obj_vol / obj_vol.sum()) - ref_vol = Volume(ref_volume / ref_volume.sum()) + ref_vol = Volume(ref_volume.copy() / ref_volume.sum()) _, R_est = align_BO( ref_vol,