def ssnr_sequential___individual_data_collect(self, r, op): if (self is None): get_mrc_func = IV.get_mrc else: get_mrc_func = self.cache.get_mrc v = get_mrc_func(r['subtomogram']) if ('angle' in r): v = GR.rotate_pad_mean(v, angle=N.array(r['angle'], dtype=N.float), loc_r=N.array(r['loc'], dtype=N.float)) if ((op is not None) and ('segmentation_tg' in op) and ('template' in r) and ('segmentation' in r['template'])): phi = IV.read_mrc_vol(r['template']['segmentation']) phi_m = (phi > 0.5) del phi (ang_inv, loc_inv) = AAL.reverse_transform_ang_loc(r['angle'], r['loc']) phi_mr = GR.rotate(phi_m, angle=ang_inv, loc_r=loc_inv, default_val=0) del phi_m del ang_inv, loc_inv import aitom.tomominer.pursuit.multi.util as PMU v_s = PMU.template_guided_segmentation(v=v, m=phi_mr, op=op['segmentation_tg']) del phi_mr if (v_s is not None): v_f = N.isfinite(v_s) if (v_f.sum() > 0): v_s[N.logical_not(v_f)] = v_s[v_f].mean() v = v_s del v_s v = NF.fftshift(NF.fftn(v)) m = get_mrc_func(r['mask']) if ('angle' in r): m = GR.rotate_mask(m, angle=N.array(r['angle'], dtype=N.float)) v[(m < op['mask_cutoff'])] = 0.0 return {'v': v, 'm': m, }
def transform(phi, A_fourier, n, inv=False): A_real = inv_fourier_transform(A_fourier) ang = [phi['q_rot'], phi['q_tilt'], phi['q_psi']] loc = [phi['q_x'], phi['q_y'], phi['q_z']] if inv: ang, loc = ang_loc.reverse_transform_ang_loc(ang, loc) A_real_rot = rotate.rotate_pad_mean(A_real, angle=ang, loc_r=loc) result = fourier_transform(A_real_rot) return result
def inv_transform_mask(phi, w, n): ang = [phi['q_rot'], phi['q_tilt'], phi['q_psi']] loc = [0.0, 0.0, 0.0] ang, loc = ang_loc.reverse_transform_ang_loc(ang, loc) w_rot = rotate.rotate_pad_zero(w, angle=ang, loc_r=loc) return w_rot