spateo.external.CAST.CAST_Stack =============================== .. py:module:: spateo.external.CAST.CAST_Stack Classes ------- .. autoapisummary:: spateo.external.CAST.CAST_Stack.reg_params Functions --------- .. autoapisummary:: spateo.external.CAST.CAST_Stack.get_range spateo.external.CAST.CAST_Stack.prelocate spateo.external.CAST.CAST_Stack.Affine_GD spateo.external.CAST.CAST_Stack.BSpline_GD spateo.external.CAST.CAST_Stack.J_cal spateo.external.CAST.CAST_Stack.alpha_init spateo.external.CAST.CAST_Stack.dJ_dt_cal spateo.external.CAST.CAST_Stack.dJ_dtheta_cal spateo.external.CAST.CAST_Stack.theta_renew spateo.external.CAST.CAST_Stack.affine_trans_t spateo.external.CAST.CAST_Stack.torch_Bspline spateo.external.CAST.CAST_Stack.BSpline_GD_preparation spateo.external.CAST.CAST_Stack.BSpline_GD_uv_ij_calculate spateo.external.CAST.CAST_Stack.B_matrix spateo.external.CAST.CAST_Stack.get_dxy_ffd spateo.external.CAST.CAST_Stack.BSpline_renew_coords spateo.external.CAST.CAST_Stack.reg_total_t spateo.external.CAST.CAST_Stack.FFD_Bspline_apply_t spateo.external.CAST.CAST_Stack.rescale_coords spateo.external.CAST.CAST_Stack.mesh_plot spateo.external.CAST.CAST_Stack.plot_mid spateo.external.CAST.CAST_Stack.corr_heat spateo.external.CAST.CAST_Stack.prelocate_loss_plot spateo.external.CAST.CAST_Stack.register_result spateo.external.CAST.CAST_Stack.affine_reg_params spateo.external.CAST.CAST_Stack.CAST_STACK_rough spateo.external.CAST.CAST_Stack.coords_minus_mean spateo.external.CAST.CAST_Stack.coords_minus_min spateo.external.CAST.CAST_Stack.max_minus_value spateo.external.CAST.CAST_Stack.coords_minus_min_t spateo.external.CAST.CAST_Stack.max_minus_value_t spateo.external.CAST.CAST_Stack.corr_dist spateo.external.CAST.CAST_Stack.region_detect Module Contents --------------- .. py:class:: reg_params .. py:attribute:: dataname :type: str .. py:attribute:: theta_r1 :type: float :value: 0 .. py:attribute:: theta_r2 :type: float :value: 0 .. py:attribute:: d_list :type: list[float] :value: [] .. py:attribute:: translation_params :type: list[float] :value: None .. py:attribute:: mirror_t :type: list[float] :value: None .. py:attribute:: alpha_basis :type: list[float] :value: [] .. py:attribute:: iterations :type: int :value: 500 .. py:attribute:: dist_penalty1 :type: float :value: 0 .. py:attribute:: attention_params :type: list[float] :value: [] .. py:attribute:: mesh_trans_list :type: list[float] :value: [] .. py:attribute:: attention_region :type: list[float] :value: [] .. py:attribute:: attention_params_bs :type: list[float] :value: [] .. py:attribute:: mesh_weight :type: list[float] :value: [] .. py:attribute:: iterations_bs :type: list[float] :value: [] .. py:attribute:: alpha_basis_bs :type: list[float] :value: [] .. py:attribute:: meshsize :type: list[float] :value: [] .. py:attribute:: img_size_bs :type: list[float] :value: [] .. py:attribute:: dist_penalty2 :type: list[float] :value: [] .. py:attribute:: PaddingRate_bs :type: float :value: 0 .. py:attribute:: bleeding :type: float :value: 500 .. py:attribute:: diff_step :type: float :value: 5 .. py:attribute:: min_qr2 :type: float :value: 0 .. py:attribute:: mean_q :type: float :value: 0 .. py:attribute:: mean_r :type: float :value: 0 .. py:attribute:: gpu :type: int :value: 0 .. py:attribute:: device :type: str .. py:attribute:: ifrigid :type: bool :value: False .. py:method:: __post_init__() .. py:function:: get_range(sp_coords) .. py:function:: prelocate(coords_q, coords_r, cov_anchor_it, bleeding, output_path, d_list=[1, 2, 3], prefix='test', ifplot=True, index_list=None, translation_params=None, mirror_t=None) .. py:function:: Affine_GD(coords_query_it_raw, coords_ref_it, cov_anchor_it, output_path, bleeding=500, dist_penalty=0, diff_step=50, alpha_basis=np.reshape(np.array([0, 0, 1 / 5, 2, 2]), [5, 1]), iterations=50, prefix='test', attention_params=[None, 3, 1, 0], scale_t=1, coords_log=False, index_list=None, mid_visual=False, early_stop_thres=1, ifrigid=False) .. py:function:: BSpline_GD(coords_q, coords_r, cov_anchor_it, iterations, output_path, bleeding, dist_penalty=0, alpha_basis=1000, diff_step=50, mesh_size=5, prefix='test', mesh_weight=None, attention_params=[None, 3, 1, 0], scale_t=1, coords_log=False, index_list=None, mid_visual=False, max_xy=None, renew_mesh_trans=True, restriction_t=0.5) .. py:function:: J_cal(coords_q, coords_r, cov_mat, bleeding=10, dist_penalty=0, attention_params=[None, 3, 1, 0]) .. py:function:: alpha_init(alpha_basis, it, dev) .. py:function:: dJ_dt_cal(coords_q, coords_r, diff_step, dev, cov_anchor_it, bleeding, dist_penalty, attention_params) .. py:function:: dJ_dtheta_cal(xi, yi, dJ_dxy_mat, theta, dev, ifrigid=False) #dxy_da: #{x * cos(rad_phi), x * sin(rad_phi)} #dxy_dd: #{-y * sin(rad_phi), y * cos(rad_phi)} #dxy_dphi: #{-d * y * cos(rad_phi) - a * x * sin(rad_phi), a * x * cos(rad_phi) - d * y * sin(rad_phi)} #dxy_dt1: #{1, 0} #dxy_dt2: #{0, 1} # when we set d = a (rigid): #dxy_da #{x * cos(rad_phi) - y * sin(rad_phi), y * cos(rad_phi) + x * sin(rad_phi)} #dxy_dd - set as the same value as dxy_da #{x * cos(rad_phi) - y * sin(rad_phi), y * cos(rad_phi) + x * sin(rad_phi)} #dxy_dphi #{-a * y * cos(rad_phi) - a * x * sin(rad_phi), a * x * cos(rad_phi) - a * y * sin(rad_phi)} .. py:function:: theta_renew(theta, dJ_dtheta, alpha, ifrigid=False) .. py:function:: affine_trans_t(theta, coords_t) .. py:function:: torch_Bspline(uv, kl) .. py:function:: BSpline_GD_preparation(max_xy, mesh_size, dev, mesh_weight) .. py:function:: BSpline_GD_uv_ij_calculate(coords_query_it, delta, dev) .. py:function:: B_matrix(uv_t, kls_t) .. py:function:: get_dxy_ffd(ij, result_B_t, mesh, dJ_dxy_mat, mesh_weight, alpha_basis) .. py:function:: BSpline_renew_coords(uv_t, kls_t, ij_t, mesh_trans) .. py:function:: reg_total_t(coords_q, coords_r, params_dist) .. py:function:: FFD_Bspline_apply_t(coords_q, params_dist, round_t=0) .. py:function:: rescale_coords(coords_raw, graph_list, rescale=False) .. py:function:: mesh_plot(mesh_t, coords_q_t, mesh_trans_t=None) .. py:function:: plot_mid(coords_q, coords_r, output_path='', filename=None, title_t=['ref', 'query'], s_t=8, scale_bar_t=None) .. py:function:: corr_heat(coords_q, coords_r, corr, output_path, title_t=['Corr in ref', 'Anchor in query'], filename=None, scale_bar_t=None) .. py:function:: prelocate_loss_plot(J_t, output_path, prefix='test') .. py:function:: register_result(coords_q, coords_r, cov_anchor_t, bleeding, embed_stack, output_path, k=8, prefix='test', scale_t=1, index_list=None) .. py:function:: affine_reg_params(it_theta, similarity_score, iterations, output_path, prefix='test') .. py:function:: CAST_STACK_rough(coords_raw_list, ifsquare=True, if_max_xy=True, percentile=None) coords_raw_list: list of numpy arrays, each array is the coordinates of a layer ifsquare: if True, the coordinates will be scaled to a square if_max_xy: if True, the coordinates will be scaled to the max value of the `max_range_x` and `max_range_y`, respectively (if ifsquare is False), or the max value of [max_range_x,max_range_y] (if ifsquare is True) percentile: if not None, the min and max will be calculated based on the percentile of the coordinates for each slice. .. py:function:: coords_minus_mean(coord_t) .. py:function:: coords_minus_min(coord_t) .. py:function:: max_minus_value(corr) .. py:function:: coords_minus_min_t(coord_t) .. py:function:: max_minus_value_t(corr) .. py:function:: corr_dist(query_np, ref_np, nan_as='min') .. py:function:: region_detect(embed_dict_t, coords0, k=20)