Exemplo n.º 1
0
def run_script():
    '''Function to be run when this file is used as a script'''
    selected_mode, img1_in, img2_in = get_setup()
    if not selected_mode:
        return
    corrected_stack = drift.get_corrected_stack((img1_in, img2_in), mode=selected_mode)
    img1, img2 = tools.stack_to_list_of_imp(corrected_stack)
    img_ratio = ImageCalculator().run('Divide create', img2, img1)
    img_ratio.setTitle('Jump-ratio [%s divided by %s]' % (img2.getShortTitle(),
                                                          img1.getShortTitle())
                      )
    img_ratio.changes = True
    img_ratio.copyScale(img1_in)
    img_ratio.show()
    IJ.run(img_ratio, 'Enhance Contrast', 'saturated=0.35')
    # We want to optimise the lower displaylimit:
    minimum = img_ratio.getProcessor().getMin()
    maximum = img_ratio.getProcessor().getMax()
    stat = img_ratio.getStatistics(Stats.MEAN + Stats.STD_DEV)
    mean = stat.mean
    stdv = stat.stdDev
    if minimum < mean - stdv:
        if mean - stdv >= 0:
            img_ratio.getProcessor().setMinAndMax(mean - stdv, maximum)
        else:
            img_ratio.getProcessor().setMinAndMax(0, maximum)
        img_ratio.updateAndDraw()
Exemplo n.º 2
0
def run_script():
    """Function to be run when this file is used as a script"""
    images = tools.get_images()
    if not images:
        return
    elif len(images) >= 2:
        corrected_stack = drift.get_corrected_stack(images, "SIFT")
        corrected_stack.copyScale(images[0])
        corrected_stack.show()
Exemplo n.º 3
0
def run_script():
    '''Function to be run when this file is used as a script'''
    images = tools.get_images()
    if not images:
        return
    elif len(images) >= 2:
        corrected_stack = drift.get_corrected_stack_linear(images, 'CC')
        corrected_stack.copyScale(images[0])
        corrected_stack.show()
Exemplo n.º 4
0
def drift_vector_from_drift_matrix(drift_matrix):
    ''' Returns a list of tuples that represents the optimized drift vector.
    :param drift_matrix: A NxN matrix that contains the measured drift between N images.
    '''
    barycenters = [tools.mean_of_list_of_tuples(row) for row in drift_matrix]
    # print 'List of centers: ', centers
    mod_matrix = [[tuple(map(operator.sub, cell, barycenters[i]))
                   for cell in row]
                  for i, row in enumerate(drift_matrix)]
    # print 'Modified drift matrix:'
    # pprint.pprint(mod_matrix)
    rot_matrix = [list(x) for x in zip(*mod_matrix)]
    # print 'Rotated matrix:'
    # pprint.pprint(rot_matrix)
    drift_vector = [tup
                    for tup in [tools.mean_of_list_of_tuples(row)
                                for row in rot_matrix
                               ]
                   ]
    return drift_vector
Exemplo n.º 5
0
def get_corrected_stack_using_vector(images, drift_vector, suffix=''):
    ''' Returns a drift corrected stack using the given drift vector.
    :param images: A list of length N containing ImagePlus objects.
    :param drift_matrix: A list of length N that contains the measured drift.
    '''
    shift_vector = shift_vector_from_drift_vector(drift_vector)
    stack = tools.stack_from_list_of_imp(shift_images(images, shift_vector))
    title = 'Drift corrected stack'
    if suffix:
        title += ' (%s)' % (suffix)
    corrected_stack = ImagePlus(title, stack)
    return corrected_stack
def run_script():
    '''Function to be run when this file is used as a script'''
    selected_mode, pre1_in, pre2_in, post_in = get_setup()
    if not selected_mode:
        return
    corrected_stack = drift.get_corrected_stack((pre1_in, pre2_in, post_in), mode=selected_mode)
    pre1_imp, pre2_imp, post_imp = tools.stack_to_list_of_imp(corrected_stack)

    mapping = ElementalMapping.ThreeWindow(pre1_imp, pre2_imp, post_imp)
    map_imp, snr_imp, r_imp, lna_imp = mapping.get_result()

    for imp in (map_imp, snr_imp, r_imp, lna_imp):
        imp.copyScale(post_in)
        show_imp(imp)