def get_setup():
    ''' Returns the drift correction mode and three image.
    The order of return values is drift detection mode, pre-edge 1, pre-edge 2, post-edge.
    '''
    options = drift.get_options()
    modes = drift.get_modes()
    dialog = GenericDialog('3-window-method setup')
    dialog.addMessage('Select the mode  for drift correction\n' +
                      'and the images to process.')
    dialog.addChoice('Mode:', options, options[0])
    image_ids = WindowManager.getIDList()
    if not image_ids or len(image_ids) < 2:
        return [None]*4
    image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
    dialog.addMessage('Post-edge is divided by the pre-edge.')
    dialog.addChoice('Pre-edge 1', image_titles, image_titles[0])
    dialog.addChoice('Pre-edge 2', image_titles, image_titles[1])
    dialog.addChoice('Post-edge', image_titles, image_titles[2])
    dialog.showDialog()
    if dialog.wasCanceled():
        return [None]*4
    mode = modes[dialog.getNextChoiceIndex()]
    img1 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
    img2 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
    img3 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
    return mode, img1, img2, img3
def correct_drift_gui():
    """
    This function combines the image selection and drift correction.
    There is no returned value.
    """
    img1, img2 = select_images()
    if img1 and img2:
        drift.correct_drift(img1, img2, True)
Example #3
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()
Example #4
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()
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()
Example #6
0
def get_setup():
    ''' Returns the drift correction mode and two image.'''
    options = drift.get_options()
    modes = drift.get_modes()
    dialog = GenericDialog('Jump-ratio setup')
    dialog.addMessage('Select the mode  for drift correction\n' +
                      'and the images to process.')
    dialog.addChoice('Mode:', options, options[0])
    image_ids = WindowManager.getIDList()
    if not image_ids or len(image_ids) < 2:
        return [None]*3
    image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
    dialog.addMessage('Post-edge is divided by the pre-edge.')
    dialog.addChoice('Pre-edge', image_titles, image_titles[0])
    dialog.addChoice('Post-edge', image_titles, image_titles[1])
    dialog.showDialog()
    if dialog.wasCanceled():
        return [None]*3
    mode = modes[dialog.getNextChoiceIndex()]
    img1 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
    img2 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
    return mode, img1, img2
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)