GUI

This module contains the GUI components for the AxoDen application.

Start the tkinter GUI by running the following command:

python -m axoden.gui.gui_projections_quantification

For the streamlit app, run the following command:

python -m axoden.gui.streamlit_app

Streamlit pdf utility functions

This section is only relevant if you want to change or extend the streamlit app functionality.

axoden.gui.streamlit_app.pdf_utils.fig2pdfpage(fig: Figure) PageObject

Converts a matplotlib figure to a PyPDF PageObject.

Parameters:

fig (Figure) – matplotlib figure

Returns:

PyPDF PageObject containing the input matplotlib figure

Return type:

PageObject

axoden.gui.streamlit_app.pdf_utils.fig2stream(fig: Figure) BytesIO

Converts a matplotlib figure to a BytesIO stream.

The output stream can be directly used as a download in Streamlit.

Parameters:

fig (Figure) – matplotlib figure

Returns:

BytesIO stream of the input matplotlib figure

Return type:

BytesIO

axoden.gui.streamlit_app.pdf_utils.join_pdfs(pdf_streams: List[BytesIO]) BytesIO

Joins all first pages of multiple pdfs into a single pdf.

This function only cares about the first page. These types of pdfs are used when figures are converted to pdfs containing only one page. The output BytesIO stream can be directly used as a download in Streamlit.

Parameters:

pdfs (List[BytesIO]) – list of pdfs as streams

Returns:

BytesIO stream of the joined pdf

Return type:

BytesIO

axoden.gui.streamlit_app.pdf_utils.pages2pdf(pages: List[PageObject]) PdfWriter

Converts a list of PyPDF Pages to a single pdf.

Parameters:

pages (List[PageObject]) – list of pages

Returns:

PyPDF PdfWriter object containing all input pages

Return type:

PdfWriter

axoden.gui.streamlit_app.pdf_utils.pdf2stream(pdf: PdfWriter) BytesIO

Converts a PyPDF PdfReader to a BytesIO stream.

The output stream can be directly used as a download in Streamlit.

Parameters:

pdf (PdfWriter) – PyPDF PdfWriter object

Returns:

BytesIO stream of the input PyPDF PdfReader object

Return type:

BytesIO

Streamlit app utility functions

This section is only relevant if you want to change or extend the streamlit app functionality.

axoden.gui.streamlit_app.app_utils.cached_plot_signal_intensity_along_axis(project_name: str, table_data_axis: DataFrame, pixel_size: float) Tuple[Figure, BytesIO]

Generate a plot of signal intensity along an axis.

Parameters:
  • project_name (str) – The name of the project.

  • table_data_axis (pd.DataFrame) – The table data containing the signal intensity values along the axis.

  • pixel_size (float) – The size of each pixel.

Returns:

A tuple containing the generated figure and file stream.

Return type:

Tuple[Figure, BytesIO]

axoden.gui.streamlit_app.app_utils.cached_plot_summary_data(table_data: DataFrame, project_name: str) Tuple[Figure, BytesIO]

Generate a cached plot of summary data.

Parameters:
  • table_data (pd.DataFrame) – The input DataFrame containing the data for the plot.

  • project_name (str) – The name of the project.

Returns:

A tuple containing the generated plot (Figure object)

and the BytesIO stream.

Return type:

Tuple[Figure, BytesIO]

axoden.gui.streamlit_app.app_utils.get_brain_regions(raw_files: List[UploadedFile]) Iterable[str]

Get the brain regions from the uploaded files.

Parameters:

raw_files (List[UploadedFile]) – The raw uploaded files to process.

Returns:

A list of brain regions extracted from the raw files.

Return type:

List[str]

axoden.gui.streamlit_app.app_utils.get_figure_by_brain_region(figures: List[BytesIO], brain_areas: List[str]) Dict[str, List[BytesIO]]

Group the given figures by brain region.

Parameters:
  • figures (List[BytesIO]) – A list of figure streams to be grouped.

  • brain_areas (List[str]) – A list of brain areas corresponding to each figure.

Returns:

A dictionary where the keys are brain regions

and the values are lists of figure streams belonging to each brain region.

Return type:

Dict[str, List[BytesIO]]

axoden.gui.streamlit_app.app_utils.hash_uploaded_file(file: UploadedFile) str

Hash util for an uploaded file.

axoden.gui.streamlit_app.app_utils.process_image_single_cached(raw_image: UploadedFile, pixel_size: float, is_masked: bool) Tuple[BytesIO, Dict, Dict]

Process a single image.

Parameters:
  • raw_image (UploadedFile) – The input image object.

  • pixel_size (float) – The pixel size in um.

  • is_masked (bool) – Flag indicating whether the image is masked.

Returns:

A tuple containing the processed image as a stream

and the data and axis data

Return type:

Tuple[BytesIO, Dict, Dict]

axoden.gui.streamlit_app.app_utils.process_images(raw_files: List[UploadedFile], pixel_size: float, is_masked: bool) Tuple[List[BytesIO], DataFrame, DataFrame]

Process a list of raw image files.

Parameters:
  • raw_files (List[UploadedFile]) – A list of raw image files.

  • pixel_size (float) – The pixel size.

  • is_masked (bool) – A flag indicating whether the images are masked.

Returns:

A tuple containing the

processed figure streams, table data, and table data axis.

Return type:

Tuple[List[BytesIO], pd.DataFrame, pd.DataFrame]