spacr.gui_elements¶
Module Contents¶
- spacr.gui_elements.restart_gui_app(root)[source]¶
Restarts the GUI application by destroying the current instance and launching a fresh one.
- spacr.gui_elements.set_dark_style(style, parent_frame=None, containers=None, widgets=None, font_family='OpenSans', font_size=12, bg_color='black', fg_color='white', active_color='blue', inactive_color='dark_gray')[source]¶
- class spacr.gui_elements.spacrFont(font_name, font_style, font_size=12)[source]¶
- class spacr.gui_elements.spacrContainer(parent, orient=tk.VERTICAL, bg=None, *args, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrEntry(parent, textvariable=None, outline=False, width=None, *args, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrCheck(parent, text='', variable=None, *args, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrCombo(parent, textvariable=None, values=None, width=None, *args, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrDropdownMenu(parent, variable, options, command=None, font=None, size=50, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrCheckbutton(parent, text='', variable=None, command=None, *args, **kwargs)[source]¶
Bases:
tkinter.ttk.Checkbutton
Ttk Checkbutton widget which is either in on- or off-state.
- class spacr.gui_elements.spacrProgressBar(parent, label=True, *args, **kwargs)[source]¶
Bases:
tkinter.ttk.Progressbar
Ttk Progressbar widget shows the status of a long-running operation. They can operate in two modes: determinate mode shows the amount completed relative to the total amount of work to be done, and indeterminate mode provides an animated display to let the user know that something is happening.
- class spacr.gui_elements.spacrSlider(master=None, length=None, thickness=2, knob_radius=10, position='center', from_=0, to=100, value=None, show_index=False, command=None, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrFrame(container, width=None, *args, bg='black', radius=20, scrollbar=True, textbox=False, **kwargs)[source]¶
Bases:
tkinter.ttk.Frame
Ttk Frame widget is a container, used to group other widgets together.
- class spacr.gui_elements.spacrLabel(parent, text='', font=None, style=None, align='right', height=None, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrButton(parent, text='', command=None, font=None, icon_name=None, size=50, show_text=True, outline=False, animation=True, *args, **kwargs)[source]¶
Bases:
tkinter.Frame
Frame widget which may contain other widgets and can have a 3D border.
- class spacr.gui_elements.spacrSwitch(parent, text='', variable=None, command=None, *args, **kwargs)[source]¶
Bases:
tkinter.ttk.Frame
Ttk Frame widget is a container, used to group other widgets together.
- class spacr.gui_elements.AnnotateApp(root, db_path, src, image_type=None, channels=None, image_size=200, annotation_column='annotate', normalize=False, percentiles=(1, 99), measurement=None, threshold=None, normalize_channels=None)[source]¶
-
- static normalize_image(img, normalize=False, percentiles=(1, 99), normalize_channels=None)[source]¶
Normalize an image based on specific channels (R, G, B).
- Parameters:
img (PIL.Image or np.array) – Input image.
normalize (bool) – Whether to normalize the image or not.
percentiles (tuple) – Percentiles to use for intensity rescaling.
normalize_channels (list) – List of channels to normalize. E.g., [‘r’, ‘g’, ‘b’], [‘r’], [‘g’], etc.
- Returns:
Normalized image.
- Return type:
PIL.Image
- train_and_classify()[source]¶
Merge data from the relevant DB tables (including png_list).
Collect manual annotations from png_list.<annotation_column> => ‘manual_annotation’. - 1 => class=1, 2 => class=0 (for training).
If only one class is present, randomly sample unannotated images as the other class.
Train an XGBoost model.
Classify all rows -> fill XGboost_score (prob of class=1) & XGboost_annotation (1 or 2 if high confidence).
Write those columns back to sqlite, so every row in png_list has a score (and possibly an annotation).
Refresh the UI (prefilter_paths_annotations + load_images).
- spacr.gui_elements.modify_figure_properties(fig, scale_x=None, scale_y=None, line_width=None, font_size=None, x_lim=None, y_lim=None, grid=False, legend=None, title=None, x_label_rotation=None, remove_axes=False, bg_color=None, text_color=None, line_color=None)[source]¶
Modifies the properties of the figure, including scaling, line widths, font sizes, axis limits, x-axis label rotation, background color, text color, line color, and other common options.
Parameters: - fig: The Matplotlib figure object to modify. - scale_x: Scaling factor for the width of subplots (optional). - scale_y: Scaling factor for the height of subplots (optional). - line_width: Desired line width for all lines (optional). - font_size: Desired font size for all text (optional). - x_lim: Tuple specifying the x-axis limits (min, max) (optional). - y_lim: Tuple specifying the y-axis limits (min, max) (optional). - grid: Boolean to add grid lines to the plot (optional). - legend: Boolean to show/hide the legend (optional). - title: String to set as the title of the plot (optional). - x_label_rotation: Angle to rotate the x-axis labels (optional). - remove_axes: Boolean to remove or show the axes labels (optional). - bg_color: Color for the figure and subplot background (optional). - text_color: Color for all text in the figure (optional). - line_color: Color for all lines in the figure (optional).
- spacr.gui_elements.generate_dna_matrix(output_path='dna_matrix.gif', canvas_width=1500, canvas_height=1000, duration=30, fps=20, base_size=20, transition_frames=30, font_type='arial.ttf', enhance=[1.1, 1.5, 1.2, 1.5], lowercase_prob=0.3)[source]¶
Generate a DNA matrix animation and save it as GIF, MP4, or AVI using OpenCV for videos.