Welcome to auto-coloc-gui’s documentation!
API for auto-coloc-gui modules and readme
# Flourescence Colocalisation Group Project
Introduction
Colocalisation is the study of whether two proteins have correlated or co-occuring spatial distributions in a biological sample. This desktop based application uses a K-means model to specify regions of colocalisation between different flourescent channels in a .tiff image for reproducable diagrams identifying co-occurance
# Authors
Amit Halkhoree - amit.halkhoree@dtc.ox.ac.uk Cameron Anderson - cameron.anderson@dtc.ox.ac.uk Dan Hudson - alexander.hudson@dtc.ox.ac.uk Ishaan Kapoor - ishaan.kapoor@dtc.ox.ac.uk Joseph Pollacco - joseph.pollacco@dtc.ox.ac.uk Samuel Johnson - samuel.johnson@dtc.ox.ac.uk
Indices and tables
- class classes.pipeline_object(inpath, outpath, threshold=False)
Pipeline object class. Any input .tiff image becomes an instance of this class. The class operates using its methods to move an image through the pipeline.
- Parameters
inpath (string or os.path) – File path of image in directory
outpath –
threshold (bool, optional) – threshold, defaults to False
- normalise(j)
Minmax rescale a 2D image at index j, where j is the channel index.
- Parameters
j (integer) – index of channel
- Raises
ValueError – Cannot process images that have less or more than 2 dimensions
- Returns
boolean value indicating if the image was rescaled
- Return type
bool
- normalise_all()
Rescale RGB image using minmax rescaling
- Parameters
im_3d (numpy array) – input RGB image
- Returns
- Return type
bool
- reshape()
Reshapes an image such that the dimensions are square, using the dimension of the smallest side.
- Returns
resized image
- Return type
class object, image array
- visualise()
Visualise the stack of RGB images
- Visualiser.annotate(ax, title, coords=False)
Adds a circle and/title to a given position in an ICA plot.
- Parameters
ax (matplotlib.pyplot axis object) – Axis to add the circle
title (string) – Title to add to the axes
coords (list of tuples (y, x)) – Coordinates to plot the circle(s)
- Visualiser.compare_dists(ch1_clusters, ch2_clusters, max_dist)
Compares the distances between centroids of channel 1 and 2 clusters. :param ch1_clusters: List of the coordinates of all cluster centres for channel 1 :type ch1_clusters: list of tuples (x, y) :param ch2_clusters: List of the coordinates of all cluster centres for channel 2 :type ch2_clusters: list of tuples (x, y) :param max_dist: defines distance threshold for definition of clusters as colocalised :type max_dist: int
- Return euc_dists
Euclidean distances between the cluster centres
- Visualiser.correlate(denoised, channels, num_clusts)
Returns the centres of clusters based on Intensity Correlation Analysis (ICA).
- Parameters
preprocessed (numpy array) – Preprocessed image data
channels – List of indices referring to the populated channels in
the data :type channels: list of integers of length 2 :param num_clusts: Number of clusters to output :type num_clusts: integer :return out: Intensity Correlation Analysis (ICA) array for every pixel in the image. :type out: numpy array :return clusts: List of (x, y) coordinates of cluster centres. :type clusts: List of tuples.
- Visualiser.fit_clusters(im, num_clusters)
Fits a series of k-means clusters using Scikit-Learn. :param im: image data :type im: numpy array of dims (heightxwidthxn-channels) :param num_clusters: Number of clusters to fit to the data :type num_clusters: int :return clusts: Coordinates of the centres of clusters :type clusts: list of tuples? # NB check this
- Visualiser.get_colocs(im, channels, num_clusts, max_dist)
Compare two chanels of an image and return the set of KMeans cluster centroids. Centroids fall within a minimum distance of one another. :param im: Image data to compare :type im: Numpy array of shape (height x width x channels) :param channels: index of the channels of interest, defaults to [0,1] :type channels: list :param num_clusts: Number of clusters to fit to the image :type num_clusts: int :param max_dist: Maximum allowed distance between cluster centres :type max_dist: float :return euc_dists: Average positions of cluster centres for cluster positions closest to each other. :type euc_dists: list of tuples
- Visualiser.plot(original, denoised, clusters, output_dir, filename)
Plots a pair of images, draws ICA cluster markings , and saves the figure.
- Parameters
original (Numpy array of shape (height x width x channels)) – Input image data
denoised (Numpy array of shape (height x width x channels)) – Denoised image data
clusters (List) – List of cluster coordinates
output_dir (string) – Path to output the result to
filename (string) – Name to output file as
- Visualiser.plot_kmeans(original, denoised, clusters, output_dir, filename)
Plots a pair of images, draws ICA cluster markings , and saves the figure.
- Parameters
original (Numpy array of shape (height x width x channels)) – Input image data
denoised (Numpy array of shape (height x width x channels)) – Denoised image data
clusters (List) – List of cluster coordinates
output_dir (string) – Path to output the result to
filename (string) – Name to output file as
- Visualiser.run_visualiser(input_dict)
Generates ICA and/or K-means plots in response to user-defined inputs
- Parameters
input_dict (dictionary) – User input values
- Visualiser.scaled_dist(max_dist)
Scale the maximum distance between clusters from uM to number of pixels :param max_dist: scale of the input image :type max_dist: int
- Returns
maximum distance between clusters for colocalisation
- Return type
int
- class gui.App
- class gui.MyTableWidget(parent)
- activate_visualiser()
This function is called when the model has completed the image analysis. It activates the View tab and adds the visualisation widgets. It also produces a message box that confirms to the user that the program has completed.
- check_errors()
This function ensures that the user inputs are all complete. It checks that an input .tif file has been selected. It also checks that necessary parameters have been selected for the model to run.
- create_channels()
This function creates the attribute channel_list from the user inputted number of channels from the dropdown menu.
- create_dict()
This file creates a dictionary of the user inputs which can be fed to the model and visualiser functions.
- property current_index
Determines what the current index is
- define_cluster_number()
This cluster labels the GUI with the user’s cluster number input to confirm data entry.
- define_file_path()
This function uses the file path that the user selects as input to define in_path and out_path variables as well as labelling the GUI with the selected file name to confirm file selection.
- handle_next()
Adds one to the index counter (moves forward in directory)
- handle_previous()
Subtracts one from the index (moves backward in directory)
- load_files()
Loads the files in from filesPath and sets the index counter to 0
- reset_clicked()
This resest the app
- run_program()
This function is the overall controller of the script. It checks for input errors by calling the check_errors function. If this passes, the function creates the input dictionary, calls the model and the visualiser to display the results.
- start_animation()
This function loads the loading.gif file as a movie attached to a label widget. The function adds the widget and then starts the .gif file to create movement.
- stop_animation()
This function stops the loading.gif movie and deletes the loading gif label so that the loading sign disappears.