palmettobug.Utils.sharedClasses =============================== .. py:module:: palmettobug.Utils.sharedClasses .. autoapi-nested-parse:: This module contains classes that can be used by multiple other modules in the program. Such as: logging classes, directory setup class, and table entry / display classes. It does also contains the table widget/launch class for the public PalmettoBUG non-GUI API, as a separate class from the table widget/launch classes used in the GUI itself. Classes ------- .. autoapisummary:: palmettobug.Utils.sharedClasses.TableLaunch_nonGUI Functions --------- .. autoapisummary:: palmettobug.Utils.sharedClasses.run_napari Module Contents --------------- .. py:function:: run_napari(image: numpy.ndarray[Union[int, float]], masks: Union[None, numpy.ndarray[int]] = None, channel_axis: Union[None, int] = None) -> None This function launches napari with the provided image & mask. The mask is shown as a layer over the image. Args: image (numpy array): the numpy array to display in napari (3D -- X, Y, and channels / Z) masks (numpy array (of integers) or None): if None, only the image is displayed. If not None, then this is added as a label layer in Napari Should have the same X,Y dimensions as the image, but only one channel layer channel_axis (None, or integer): passed to the napari.imshow() function, determines which dimension of image numpy array will be treated as the channels By default, Napari treats the channel axis as a spatial dimension (it expects 3D imaging), which is fine as I think this allows easier scrolling through the channels. However, if you prefer Napari to open separate layers for each channel, then specify the channel axis with this parameter and Napari should do that instead of treating the channels like an extra spatial dimension. .. py:class:: TableLaunch_nonGUI(dataframe: Union[str, pathlib.Path, pandas.DataFrame], export_path: Union[str, pathlib.Path], table_type: str = 'other', labels_editable: bool = True, width: int = 1, height: int = 1) Bases: :py:obj:`customtkinter.CTk` This class launches a customtkinter GUI window, in order to display the contents of a table. It can make setting up the panel/metadata/Analysis_panel files easier / faster, instead of manually setting values in python or requiring the user to go to a second program (like excel) to enter values. Args: dataframe (Path, string, or pandas dataframe): either the dataframe, or the path to a .csv file, which will be displayed in the window export_path (Path or string): the path to where you want to write the dataframe when the "Accept and Return" Button is pressed & the window closes. Remeber to include the .csv file extension! table_type (str): The type of the table being passed in. Helps determine the format of the display, one of ['panel','metadata','Analysis_panel','Regionprops_panel','other']. 'other' is the default, and will display all entries in the dataframe as either uneditable labels or as entry fields that allow any kind of text editing depending on whether labels_editable is False or True. The specific table types, like 'metadata', etc. expect a particular format for the dataframe. For example, selecting a table_type of 'panel' means 4 data columns will be generated >> the first two are label/entry columns, the next column of drop-down option widgets with 0 / 1 as the choices and the last column of data will be a drop down with options of "Nuclei (1)" and "Cytoplasmic / Membrane (2)". This is to replicate the expectation of the panel file, but theoretically you could use 'other' for all table types and simply use the entry fields to have full control of the final table. Note that if you use 'other' instead of 'panel' in the example above, you should enter numbers for nuclei (1) and cytoplasmic (2) segmentation channels, NOT the strings "Nuclei (1)" or "Cytoplasmic / Membrane (2)", as the table_type == "panel" also auto-converts between the human-friendly strings and the computer friendly integers (1 or 2). labels_editable (bool): whether fields are displayed as CTklabels (uneditable, if False) or CTkEntry (editable, if True) when those fields are otherwise specified by the table_type. width / height (both ints): determine the shape & size of the window/table when launched. This operates by an estimation of the needed table height/width to accommodate the widgets multiplied by height/width. (Default = 1 for both means the initial estimate is also the final shape) Input / Output: Input: if dataframe is a file path, not a pandas dataframe, wil attempt to read a csv at that filepath Output: when the accept button is pressed, will attempt to write the dataframe set up in the GUI to export_path as a csv file. .. py:attribute:: tablewidget .. py:attribute:: column :value: 1 .. py:attribute:: table_list .. py:attribute:: accept_button .. py:method:: accept_and_return() -> None