コード例 #1
0
def runThunderSTORM(filename):
    # ---------------------------------------------
    # Runs the ThunderSTORM plugin on the filename
    # provided with the settings from the top of
    # this file.
    # ---------------------------------------------
    global exportList
    if virtualStack:
        IJ.openVirtual(filename)
    else:
        IJ.open(filename)
    IJ.run(stormAnalysisCmd, stormAnalysisParams)
    dataStoreFilename = os.path.dirname(filename) + os.sep + os.path.splitext(
        os.path.basename(filename))[0] + ".csv"
    exportList.append(dataStoreFilename)
    exportParams = stormExportParams.replace("%filename", dataStoreFilename)
    print exportParams
    IJ.run(stormExportCmd, exportParams)
    WindowManager.closeAllWindows()
    return exportList
コード例 #2
0
def show_thresholded(event):
    """ Show virtual stack of image thresholded to mu +/- 1x sigma of each Gaussian component

    Parameters
    ----------
    event : Event
        Waits for show_thresholded_JB JButton to be pressed

    Returns
    -------
    None
    """

    # Get image filename
    results_dir = get_results_dir()
    with open(os.path.join(results_dir, "Users_Params.csv")) as csv_file:
        reader = csv.DictReader(csv_file)
        for row in reader:
            img_fname = row['img_fname']
            n_gaussians = int(row['n_gaussians'])
    print("Displaying image {} with {} Gaussians fitted".format(
        img_fname, n_gaussians))

    # Read mu and sigma from results directory
    with open(os.path.join(results_dir, "fitted_results.csv")) as csv_file:
        reader = csv.reader(csv_file)
        results = []  # list containing lines in fitted_results.csv
        for row in reader:
            results.append(row)
    mu_all = []
    sigma_all = []
    for i in range(3, len(results)):
        mu_all.append(float(results[i][0]))
        sigma_all.append(float(results[i][1]))

    # Calculate values for thresholding (mu +/- 1x sigma)
    lower_threshold = map(lambda mu, sigma: mu - sigma, mu_all, sigma_all)
    upper_threshold = map(lambda mu, sigma: mu + sigma, mu_all, sigma_all)

    # Display each slice thresholded with the Gaussian number in title
    for gaussian in range(n_gaussians):
        imp = IJ.openVirtual(img_fname)
        imp.setTitle("Gaussian {}".format(gaussian))
        imp.show()
        IJ.setThreshold(imp, lower_threshold[gaussian],
                        upper_threshold[gaussian])
        print("Gaussian {} threshold values [{} - {}]".format(
            gaussian, lower_threshold[gaussian], upper_threshold[gaussian]))