Exemplo n.º 1
0
def root_quit():
    """
    This function is called when the use quits the root function. It kills any running toplevels by destroying itself.
    It also set kill to True so the pipeline can't accidentally run.
    :return:
    """
    root.destroy()
    kill(pathClearMap)
Exemplo n.º 2
0
    def manual_quit():
        """
        If the window is closed this function is called which sets the kill parameter to True which stops the pipeline
        béfore it can run.
        :return:
        """
        kill(pathClearMap)

        manualWindow.destroy()
Exemplo n.º 3
0
    def cel_window_quit():
        """
        If the window is closed this function is called which sets the kill parameter to True and stops the pipeline
        béfore it can run.
        :return:
        """
        kill(pathClearMap)

        importCellWindow.destroy()
Exemplo n.º 4
0
def findLandmarks(manualWindow, pathClearMap):
    """
    This function is called when the user has to select where the landmarks.csv file is located.
    :param rootMA: This the window where the select landmarks button is called from.
    :param pathClearMap: The path to where the entire program is saved.
    :return:
    """
    landmarksDir = askopenfilename(parent=manualWindow,
                                   title="Select landmarks file")
    print(landmarksDir)
    pathOutput = pathClearMap + "ClearMap/clearmap_preset_folder/output/landmarks.csv"
    try:
        shutil.copyfile(landmarksDir, pathOutput)
        write_landmarks_to_files(pathClearMap)
    except FileNotFoundError:
        kill(pathClearMap)
    def settings_quit():
        """
        This function is called when the user quits the settings window.
        It enables the use of the button on the previous window and passes a kill parameter to the local settings file.
        This is done so the pipeline isn't able to run on accident without settings freezing the GUI and crashing later
        in the program. It also looks for if a toplevel above this window was opened and closes it so any
        windows which should be inaccessible are not staying open.
        :return:
        """
        settingsWindow.destroy()  # close the popup
        nextButton['state'] = 'normal'
        kill(pathClearMap)

        listToplevel = []
        for widget in root.winfo_children():
            if isinstance(widget, tk.Toplevel):
                listToplevel.append(widget)
        if len(listToplevel) != 1:
            listToplevel[-1].destroy()
def arivis_cel_detection(pathClearMap, column):
    """
    This function is called when the chosen cel detection file is an arivis file.

    :param pathClearMap: The path of the gui
    :param column: a dictionary where the keys are the headers of the read csv file, and where the keys are lists of the
    values in each header column.
    :return:
    """
    try:

        xValues = [
            int(float(x)) for x in column['"X (px), Center of Geometry"']
        ]
        yValues = [
            int(float(x)) for x in column['"Y (px), Center of Geometry"']
        ]
        zValues = [
            int(float(x)) for x in column['"Z (px), Center of Geometry"']
        ]

        cellsList = []
        intensList = []
        for count, item in enumerate(xValues):
            intensList.append([
                "0", "0", column['"Mean, Intensities #1"'][count],
                column['"VoxelCount, Volume"'][count]
            ])
            cellsList.append([xValues[count], yValues[count], zValues[count]])
        np.save(pathClearMap +
                "ClearMap/clearmap_preset_folder/output/cells.npy",
                np.array(cellsList),
                allow_pickle=True,
                fix_imports=True)
        np.save(pathClearMap +
                "ClearMap/clearmap_preset_folder/output/intensities.npy",
                np.array(intensList),
                allow_pickle=True,
                fix_imports=True)

    except Exception as e:
        print(e)
        kill(pathClearMap)
Exemplo n.º 7
0
    def run_quit():
        """
        This function is called when the user quits the run options window.
        It enables the use of the button on the previous window and passes a kill parameter to the local settings file.
        This is done so the pipeline isn't able to run on accident without settings freezing the GUI and crashing later
        in the program. It also looks for if a toplevel above this window was opened and closes it so any
        windows which should be inaccessible are not staying open.
        :return:
        """
        runWindow.destroy()  # close the popup
        runButtonMain['state'] = 'normal'
        importButton['state'] = 'normal'
        presetButton['state'] = 'normal'
        manualButton['state'] = 'normal'
        kill(pathClearMap)

        for widget in root.winfo_children():
            if isinstance(widget, tk.Toplevel):
                widget.destroy()
def cel_detection(importCelWindow, pathClearMap):
    """
    This function is called when the user chooses to import their own cel detection.
    It opens the file and checks if arivis headers are present. If they aren't the program assumes the csv files first 3
    columns are the x y z coordinates without headers.
    Every time when loading a npy fix imports has to be true because the clearmap program uses a python 2.x way to read
    the numpy arrays and this fixes any header issues that would otherwise occur.
    :param importCelWindow: This is the toplevel from where the chooser is called and is used as parent for the file
    chooser
    :param pathClearMap: This is the path of the gui.
    :return:
    """
    cellsDir = askopenfilename(
        parent=importCelWindow,
        title="Select the csv file with the detected cells")

    try:
        f = open(cellsDir, 'r')
        reader = csv.reader(f)
        headers = next(reader, None)
        column = {}
        for h in headers:
            column[h] = []
        for row in reader:
            for h, v in zip(headers, row):
                column[h].append(v)
        f.close()
        if '"X (px), Center of Geometry"' in column and '"Mean, Intensities #1"' in column:
            #if this is true then it is most likely an exported file from arivis. If it isn't but these columns still
            #exist then the outcome should be the same.
            arivis_cel_detection(pathClearMap, column)

        else:
            cel_detection_without_int(pathClearMap, cellsDir)

    except Exception as e:
        print(e)

        kill(pathClearMap)