예제 #1
0
def gui():
    # setting up tkinter window
    root = tkinter.Tk()
    root.title("Generate Fluorescence Aggregates")
    # root.geometry("300x125")
    # root.configure(background='white')
    root.resizable(False, False)

    # configuring grid for resizable buttons
    tkinter.Grid.columnconfigure(root, 0, weight=1)
    for y in range(3):
        tkinter.Grid.rowconfigure(root, y, weight=1)

    # creating a button for each main function
    bin_to_binary_btn = tkinter.ttk.Button(
        root, 
        text="Binary To PNG", 
        command=lambda: bin_conversion.convert_dirs(fd.askdirectory(title="Please select a ps2 collection"))
    )
    bin_to_binary_btn.grid(column=0, row=0, sticky="nsew", padx=2, pady=2, ipadx=10, ipady=7, columnspan=2)

    imagej_macro_btn = tkinter.ttk.Button(
        root, 
        text="ImageJ Macro", 
        command=run_imagej_macro
    )
    imagej_macro_btn.grid(column=0, row=1, sticky="nsew", padx=2, pady=2, ipadx=10, ipady=7)

    image_segmentation_btn = tkinter.ttk.Button(
        root, 
        text="Python Macro", 
        command=lambda: image_segmentation.process_collection(fd.askdirectory(title="Please select a ps2 collection"))
    )
    image_segmentation_btn.grid(column=1, row=1, sticky="nsew", padx=2, pady=2, ipadx=10, ipady=7)

    # getting offsets
    with open(os.path.join(this_dir, "static", "ps2", "sensor_fixed_metadata.json"), 'r') as f:
        ps2_dict = json.load(f)
        ps2_x = float(ps2_dict[0]['location_in_camera_box_m']['x'])
        ps2_y = float(ps2_dict[0]['location_in_camera_box_m']['y'])

    # calling single process
    # using a file dialog, ask the user for a collection path
    # use the Plot boundaries.xlsx and multithresh json next to this file
    # use offsets from sensor_fixed_metadata.json
    generate_aggregate_btn = tkinter.ttk.Button(
        root, 
        text="Generate Aggregate and Fluorescence", 
        command=lambda: fluorescence_aggregation.single_process(
            filepath=fd.askdirectory(title="Please select a ps2 collection"),
            plot_boundaries=os.path.join(this_dir, 'static', 'Plot boundaries.xlsx'),
            multithresh_json=os.path.join(this_dir, 'static', 'multithresh.json'),
            offset_x=ps2_x,
            offset_y=ps2_y
        ),
    )
    generate_aggregate_btn.grid(column=0, row=2, sticky="nsew", padx=2, pady=2, ipadx=10, ipady=7, columnspan=2)

    # starting gui
    root.mainloop()
예제 #2
0
파일: FLIP.py 프로젝트: uacic/FLIP
def headless(directory, output, processes=-1):
    """
    run the full pipeline on a directory without a gui

    parameters:
        directory: input directory with ps2 data
        output: output directory
        processes: max number of multiprocesses. default: max available
    
    1. convert bins to pngs
    2. do image segmentation (this is where the imagej macro 
        would go, but it has been rewritten)
    3. get ps2 offsets
    4. generate aggregate files
    5. generate fluorescence file 
    """

    print("Converting bins to pngs")
    bin_conversion.convert_dirs(
        directory,
        processes=processes)  # converting all images in a dir from bin to png

    print("segmenting images")
    # imagej_macro(args.macro, args.directory) # old fiji macro
    image_segmentation.process_collection(directory)  # new python macro

    # getting offsets
    with open(
            os.path.join(this_dir, "static", "ps2",
                         "sensor_fixed_metadata.json"), 'r') as f:
        ps2_dict = json.load(f)
        ps2_x = float(ps2_dict[0]['location_in_camera_box_m']['x'])
        ps2_y = float(ps2_dict[0]['location_in_camera_box_m']['y'])

    print("generating aggregates")
    fluorescence_aggregation.generate_aggregate(
        directory, output,
        os.path.join(this_dir, "static", 'S10_Plot_boundaries.csv'),
        os.path.join(this_dir, "static", 'multithresh.json'), ps2_x,
        ps2_y)  # generating aggregates
    fluorescence_aggregation.generate_fluorescence(
        directory, output, True)  # generate fluorescence files

    print("Finished processing", directory)
예제 #3
0
def headless(directory):
    """run the full pipeline on a directory without a gui"""

    bin_conversion.convert_dirs(directory) # converting all images in a dir from bin to png
    # imagej_macro(args.macro, args.directory) # old fiji macro
    image_segmentation.process_collection(directory) # new python macro

    # getting offsets
    with open(os.path.join(this_dir, "static", "ps2", "sensor_fixed_metadata.json"), 'r') as f:
        ps2_dict = json.load(f)
        ps2_x = float(ps2_dict[0]['location_in_camera_box_m']['x'])
        ps2_y = float(ps2_dict[0]['location_in_camera_box_m']['y'])

    fluorescence_aggregation.generate_aggregate(
        directory, 
        os.path.join(this_dir, "static", 'Plot boundaries.xlsx'),
        os.path.join(this_dir, "static", 'multithresh.json'),
        ps2_x, 
        ps2_y
    ) # generating aggregates
    fluorescence_aggregation.generate_fluorescence(directory, True) # generate fluorescence files

    print("Finished processing", directory)
예제 #4
0
def main():
    args = parse_args()

    # segmenting images using new python macro
    print("segmenting images")
    image_segmentation.process_collection(args.directory, args.processes)
예제 #5
0
파일: FLIP.py 프로젝트: uacic/FLIP
def gui():
    import tkinter
    import tkinter.filedialog as fd
    import tkinter.ttk

    def run_imagej_macro():
        """
        runs a command that will call imagej with a specified macro
        """

        # trying to find a local imagej installation, but if one is not found, ask the user where it is
        imagej_path = os.path.join(this_dir, 'Fiji.app/ImageJ-win64.exe')
        if not os.path.exists(imagej_path):
            imagej_path = fd.askopenfilename(
                title="Could not find imagej, please select your imagej.exe")

        # asking the user where their imagej macro is.
        macro_path = fd.askopenfilename(title="Please select an imagej macro")

        # if the user cancels either of the selections, return
        if not macro_path or not imagej_path:
            return

        subprocess.call([imagej_path, "-macro", macro_path])

    # setting up tkinter window
    root = tkinter.Tk()
    root.title("Generate Fluorescence Aggregates")
    # root.geometry("300x125")
    # root.configure(background='white')
    root.resizable(False, False)

    # creating a button for each main function
    bin_to_binary_btn = tkinter.ttk.Button(
        root,
        text="Binary To PNG",
        command=lambda: bin_conversion.convert_dirs(
            fd.askdirectory(title="Please select a ps2 collection")))
    bin_to_binary_btn.grid(column=0,
                           row=0,
                           sticky="nsew",
                           padx=2,
                           pady=2,
                           ipadx=10,
                           ipady=7,
                           columnspan=2)

    imagej_macro_btn = tkinter.ttk.Button(root,
                                          text="ImageJ Macro",
                                          command=run_imagej_macro)
    imagej_macro_btn.grid(column=0,
                          row=1,
                          sticky="nsew",
                          padx=2,
                          pady=2,
                          ipadx=10,
                          ipady=7)

    image_segmentation_btn = tkinter.ttk.Button(
        root,
        text="Python Macro",
        command=lambda: image_segmentation.process_collection(
            fd.askdirectory(title="Please select a ps2 collection")))
    image_segmentation_btn.grid(column=1,
                                row=1,
                                sticky="nsew",
                                padx=2,
                                pady=2,
                                ipadx=10,
                                ipady=7)

    # getting offsets
    with open(
            os.path.join(this_dir, "static", "ps2",
                         "sensor_fixed_metadata.json"), 'r') as f:
        ps2_dict = json.load(f)
        ps2_x = float(ps2_dict[0]['location_in_camera_box_m']['x'])
        ps2_y = float(ps2_dict[0]['location_in_camera_box_m']['y'])

    # calling single process
    # using a file dialog, ask the user for a collection path
    # use the Plot boundaries.csv and multithresh json next to this file
    # use offsets from sensor_fixed_metadata.json
    generate_aggregate_btn = tkinter.ttk.Button(
        root,
        text="Generate Aggregate and Fluorescence",
        command=lambda: fluorescence_aggregation.single_process(
            filepath=fd.askdirectory(title="Please select a ps2 collection"),
            plot_boundaries=os.path.join(this_dir, 'static',
                                         'S10_Plot_boundaries.csv'),
            multithresh_json=os.path.join(this_dir, 'static',
                                          'multithresh.json'),
            offset_x=ps2_x,
            offset_y=ps2_y),
    )
    generate_aggregate_btn.grid(column=0,
                                row=2,
                                sticky="nsew",
                                padx=2,
                                pady=2,
                                ipadx=10,
                                ipady=7,
                                columnspan=2)

    # starting gui
    root.mainloop()