@@ -464,8 +464,8 @@ def construct_image_stack(
464464 for img_path , indexes in image_index_groups .items ():
465465 img = load_mrc_image (img_path )
466466
467- pos_y = self ._df .loc [indexes , y_col ].to_numpy ()
468- pos_x = self ._df .loc [indexes , x_col ].to_numpy ()
467+ pos_y = self ._df .loc [indexes , y_col ].to_numpy (). copy ()
468+ pos_x = self ._df .loc [indexes , x_col ].to_numpy (). copy ()
469469
470470 # If the position reference is "center", shift (x, y) by half the original
471471 # template width/height so reference is now the top-left corner
@@ -571,8 +571,8 @@ def construct_cropped_statistic_stack(
571571
572572 # with reference to the exact pixel of the statistic (top-left)
573573 # need to account for relative extracted box size
574- pos_y = self ._df .loc [indexes , y_col ].to_numpy ()
575- pos_x = self ._df .loc [indexes , x_col ].to_numpy ()
574+ pos_y = self ._df .loc [indexes , y_col ].to_numpy (). copy ()
575+ pos_x = self ._df .loc [indexes , x_col ].to_numpy (). copy ()
576576
577577 # NOTE: For both references, we need to shift both x and y
578578 # by half the different of the original template shape and extracted box
@@ -620,7 +620,9 @@ def construct_filter_stack(
620620 and (h, w) is the output shape.
621621 """
622622 # Create an empty tensor to store the filter stack
623- filter_stack = torch .zeros ((self .num_particles , * output_shape ))
623+ filter_stack = torch .zeros (
624+ (self .num_particles , * output_shape ), dtype = torch .complex64
625+ )
624626
625627 # Find the indexes in the DataFrame that correspond to each unique image
626628 image_index_groups = self ._df .groupby ("micrograph_path" ).groups
@@ -691,7 +693,7 @@ def get_relative_defocus(
691693 else :
692694 rel_defocus_col = "refined_relative_defocus"
693695
694- return torch .tensor (self ._df [rel_defocus_col ].to_numpy ())
696+ return torch .tensor (self ._df [rel_defocus_col ].to_numpy (). copy () )
695697
696698 def get_absolute_defocus (
697699 self , prefer_refined_defocus : bool = True
@@ -716,8 +718,10 @@ def get_absolute_defocus(
716718 Angstroms.
717719 """
718720 particle_defocus = self .get_relative_defocus (prefer_refined_defocus )
719- defocus_u = torch .tensor (self ._df ["defocus_u" ].to_numpy ()) + particle_defocus
720- defocus_v = torch .tensor (self ._df ["defocus_v" ].to_numpy ()) + particle_defocus
721+ defocus_u = torch .tensor (self ._df ["defocus_u" ].to_numpy ().copy ())
722+ defocus_v = torch .tensor (self ._df ["defocus_v" ].to_numpy ().copy ())
723+ defocus_u = defocus_u + particle_defocus
724+ defocus_v = defocus_v + particle_defocus
721725
722726 return defocus_u , defocus_v
723727
@@ -760,7 +764,7 @@ def get_pixel_size(
760764 else :
761765 pixel_size_col = "refined_pixel_size"
762766
763- return torch .tensor (self ._df [pixel_size_col ].to_numpy ())
767+ return torch .tensor (self ._df [pixel_size_col ].to_numpy (). copy () )
764768
765769 def get_euler_angles (self , prefer_refined_angles : bool = True ) -> torch .Tensor :
766770 """Return the Euler angles (phi, theta, psi) of all particles as a tensor.
@@ -796,9 +800,9 @@ def get_euler_angles(self, prefer_refined_angles: bool = True) -> torch.Tensor:
796800 psi_col = "refined_psi"
797801
798802 # Get the angles from the DataFrame
799- phi = torch .tensor (self ._df [phi_col ].to_numpy ())
800- theta = torch .tensor (self ._df [theta_col ].to_numpy ())
801- psi = torch .tensor (self ._df [psi_col ].to_numpy ())
803+ phi = torch .tensor (self ._df [phi_col ].to_numpy (). copy () )
804+ theta = torch .tensor (self ._df [theta_col ].to_numpy (). copy () )
805+ psi = torch .tensor (self ._df [psi_col ].to_numpy (). copy () )
802806
803807 return torch .stack ((phi , theta , psi ), dim = - 1 )
804808
0 commit comments