<commit_before>"""
tint.phase_correlation
======================

Functions for performing phase correlation. Used to predict cell movement
between scans.

"""

import numpy as np
from scipy import ndimage


def get_ambient_flow(obj_extent, img1, img2, params):
    """ Takes in object extent and two images and returns ambient flow. Margin
    is the additional region around the object used to compute the flow
    vectors. """
    margin = params['FLOW_MARGIN']
    row_lb = obj_extent['obj_center'][0] - obj_extent['obj_radius'] - margin
    row_ub = obj_extent['obj_center'][0] + obj_extent['obj_radius'] + margin
    col_lb = obj_extent['obj_center'][1] - obj_extent['obj_radius'] - margin
    col_ub = obj_extent['obj_center'][1] + obj_extent['obj_radius'] + margin
    row_lb = np.int(row_lb)
    row_ub = np.int(row_ub)
    col_lb = np.int(col_lb)
    col_ub = np.int(col_ub)

    dims = img1.shape

    row_lb = np.max([row_lb, 0])
    row_ub = np.min([row_ub, dims[0]])
    col_lb = np.max([col_lb, 0])<commit_msg>DEV: FLOW_MARGIN in get_ambient_flow can now be given in meters.<commit_after>"""
tint.phase_correlation
======================

Functions for performing phase correlation. Used to predict cell movement
between scans.

"""

import numpy as np
from scipy import ndimage


def get_ambient_flow(obj_extent, img1, img2, params, grid_size):
    """ Takes in object extent and two images and returns ambient flow. Margin
    is the additional region around the object used to compute the flow
    vectors. """
    margin_r = params['FLOW_MARGIN'] / grid_size[1]
    margin_c = params['FLOW_MARGIN'] / grid_size[2]
    row_lb = obj_extent['obj_center'][0] - obj_extent['obj_radius'] - margin_r
    row_ub = obj_extent['obj_center'][0] + obj_extent['obj_radius'] + margin_r
    col_lb = obj_extent['obj_center'][1] - obj_extent['obj_radius'] - margin_c
    col_ub = obj_extent['obj_center'][1] + obj_extent['obj_radius'] + margin_c
    row_lb = np.int(row_lb)
    row_ub = np.int(row_ub)
    col_lb = np.int(col_lb)
    col_ub = np.int(col_ub)

    dims = img1.shape

    row_lb = np.max([row_lb, 0])
    row_ub = np.min([row_ub, dims[0]])
    col_lb = np.max([col_lb, 0])
{'fraction_non_alphanumeric': 0.1397898583828232, 'fraction_numerical': 0.010050251256281407, 'mean_word_length': 4.128805620608899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7359738', 'n_tokens_mistral': 798, 'n_tokens_neox': 785, 'n_words': 191}