import torch


def get_cl(arr, index, ema_t_l):
    """
    calculates constriction length (CL):
        T?CL[n] = median{T?x for all T?x} - T?x[n]
    """
    return torch.median(torch.cat(ema_t_l)[:,index]) - arr[:,index]