def main(argv):
    """

    :param argv:
    """
    directory = util.get_directory_from_command_line(argv, os.path.basename(__file__))

    for filename in util.gen_img_paths(directory):
        path = os.path.join(directory, filename)

        # Open with Bioformats
        im = pims.Bioformats(path + '.tif')

        # Set scale
        micron_per_pixel = im.calibration

        # Calculate size range
        min_size = max(0.3 / micron_per_pixel, 3)
        max_size = min(2.0 / micron_per_pixel, im.frame_shape[0] * 0.5)

        im = im[0][:-64]
        im = np.flipud(im)

        # Locate and refine circles
        finder = pf.ParticleFinder(im)
        f = finder.locate_particles(size_range=(min_size, max_size))

        # Save fit images
        plot.save_fits(f, im, path)

        # Generate data files and save
        report.save_circles_to_csv(f, path, micron_per_pixel)
        report.save_circles_to_csv_grouped(f, path, micron_per_pixel)
Beispiel #2
0
def main(argv):
    """

    :param argv:
    """
    directory = util.get_directory_from_command_line(argv, os.path.basename(__file__))

    # Open all .tif's in the directory
    for filename in util.gen_img_paths(directory):
        path = os.path.join(directory, filename)

        # Open with Bioformats
        im = pims.Bioformats(path + '.tif')

        # Set scale
        micron_per_pixel = im.calibration

        im = im[0][:-64]
        im = np.flipud(im)

        # Report filename
        report_file = os.path.abspath(
            os.path.normpath(directory + os.path.sep + 'report' + os.path.sep + filename + '_frame.csv'))
        if not os.path.isfile(report_file):
            continue

        checker = usercheckfits.UserCheckFits(report_file, micron_per_pixel)
        f = checker.user_check_fits(im)

        # Remove old csv files
        summary_file = os.path.abspath(
            os.path.normpath(directory + os.path.sep + 'report' + os.path.sep + filename + '_summary.csv'))
        if os.path.isfile(summary_file):
            os.remove(summary_file)
        os.remove(report_file)

        # Remove old grouped files
        file_path_grouped = os.path.abspath(
            os.path.normpath(directory + os.path.sep + 'report' + os.path.sep + re.sub("_\d+$", "", filename)))
        report_file_grouped = file_path_grouped + '_grouped_report.csv'
        summary_file_grouped = file_path_grouped + '_grouped_summary.csv'
        if os.path.isfile(report_file_grouped):
            os.remove(report_file_grouped)
        if os.path.isfile(summary_file_grouped):
            os.remove(summary_file_grouped)

        # Remove old fit .tif file
        fits_directory = os.path.abspath(os.path.normpath(directory + os.path.sep + 'fits'))
        fit_file = os.path.abspath(os.path.normpath(fits_directory + os.path.sep + filename)) + '_fit.tif'
        if os.path.isfile(fit_file):
            os.remove(fit_file)

        # Save fit images
        plot.save_fits(f, im, path)

        # Generate data files and save
        report.save_circles_to_csv(f, path, micron_per_pixel)
        report.save_circles_to_csv_grouped(f, path, micron_per_pixel, suffix='_grouped_checked')