RASPRoutines module
This class contains functions that collect analysis routines for RASP. jsb92, 2024/02/08
- class RASPRoutines.RASP_Routines(defaultfolder=None, defaultarea=True, defaultd=True, defaultrad=True, defaultflat=True, defaultdfocus=True, defaultintfocus=True, defaultcellparams=True, defaultcameraparams=True)
Bases:
object- analyse_images(folder, imtype='.tif', thres=0.05, large_thres=450.0, gsigma=1.4, rwave=2.0, oligomer_string='C1', cell_string='C0', if_filter=True, im_start=1, cell_analysis=True, one_savefile=False, disp=True)
analyses data from images in a specified folder, saves spots, locations, intensities and backgrounds in a folder created next to the folder analysed with _analysis string attached also writes a folder with _analysisparameters and saves analysis parameters used for particular experiment
- Parameters:
folder (string) – Folder containing images
imtype (string) – Type of images being analysed, default tif
thres (float) – fraction of bright pixels accepted
large_thres (float) – large object intensity threshold
gisgma (float) – gaussian blurring parameter (default 1.4)
rwave (float) – Ricker wavelent sigma (default 2.)
oligomer_string (string) – string for oligomer-containing data (default C1)
string (cell) – string for cell-containing data (default C0)
if_filter (boolean) – Filter images for focus (default True)
im_start (integer) – Images to start from (default 1)
cell_analysis (boolean) – Parameter where script also analyses cell images and computes colocalisation likelihood ratios.
one_savefile (boolean) – Parameter that, if true, doesn’t save a file per image but amalgamates them into one file
disp (boolean) – If true, prints when analysed an image stack.
- analyse_round_images(folder, imtype='.tif', thres=0.05, large_thres=450.0, gsigma=1.4, rwave=2.0, oligomer_string='C1', cell_string='C0', if_filter=True, im_start=1, cell_analysis=False, one_savefile=True)
analyses data in a folder specified, folder has either “Round” in the title or multiple rounds below; structure as in Lee Lab Cambridge Experiment saves spots, locations, intensities and backgrounds in a folder created next to the folder analysed with _analysis string attached also writes a folder with _analysisparameters and saves analysis parameters used for particular experiment
- Parameters:
folder (string) – Folder containing images
imtype (string) – Type of images being analysed, default tif
gisgma (float) – gaussian blurring parameter (default 1.4)
rwave (float) – Ricker wavelent sigma (default 2.)
oligomer_string (string) – string for oligomer-containing data (default C1)
string (cell) – string for cell-containing data (default C0)
if_filter (boolean) – Filter images for focus (default True)
im_start (integer) – Images to start from (default 1)
one_savefile (boolean) – Parameter that, if true, doesn’t save a file per image but amalgamates them into one file
cell_analysis (boolean) – Parameter where script also analyses cell images and computes colocalisation likelihood ratios.
- analyse_round_subfolder(folder, k1, k2, rdl, imtype='.tif', thres=0.05, large_thres=450.0, gsigma=1.4, rwave=2.0, oligomer_string='C1', cell_string='C0', if_filter=True, im_start=1, cell_analysis=False, one_savefile=True, disp=True)
analyses data in a folder specified, folder has either “Round” in the title or multiple rounds below; structure as in Lee Lab Cambridge Experiment saves spots, locations, intensities and backgrounds in a folder created next to the folder analysed with _analysis string attached also writes a folder with _analysisparameters and saves analysis parameters used for particular experiment
- Parameters:
folder (string) – Folder containing images
k1 (matrix) – convolution kernel 1
k2 (matrix) – convolution kernel 2
rdl (vector) – radiality filter
thres (float) – fraction of bright pixels accepted
large_thres (float) – large object intensity threshold
imtype (string) – Type of images being analysed, default tif
gisgma (float) – gaussian blurring parameter (default 1.4)
rwave (float) – Ricker wavelent sigma (default 2.)
oligomer_string (string) – string for oligomer-containing data (default C1)
string (cell) – string for cell-containing data (default C0)
if_filter (boolean) – Filter images for focus (default True)
im_start (integer) – Images to start from (default 1)
one_savefile (boolean) – Parameter that, if true, doesn’t save a file per image but amalgamates them into one file
cell_analysis (boolean) – Parameter where script also analyses cell images and computes colocalisation likelihood ratios.
disp (boolean) – If True, outputs a message saying analysed image.
- calibrate_area(folder, imtype='.tif', gsigma=1.4, rwave=2.0, large_thres=10000.0)
Calibrates area threshold. Given a folder of bead images, analyses them and saves the radiality parameter to the .json file, as well as writing it to the current class radiality and flatness values
- Parameters:
folder (string) – Folder containing bead (bright) control tifs
imtype (string) – Type of images being analysed, default tif
gisgma (float) – gaussian blurring parameter (default 1.4)
rwave (float) – Ricker wavelent sigma (default 2.)
- calibrate_radiality(folder, imtype='.tif', gsigma=1.4, rwave=2.0, accepted_ratio=1)
Calibrates radility parameters. Given a folder of negative controls, analyses them and saves the radiality parameter to the .json file, as well as writing it to the current class radiality and flatness values
- Parameters:
folder (string) – Folder containing negative control tifs
imtype (string) – Type of images being analysed, default tif
gsigma (float) – gaussian blurring parameter (default 1.4)
rwave (float) – Ricker wavelent sigma (default 2.)
accepted_ratio (float) – Percentage accepted of false positives
- count_spots(database, z_planes)
Counts spots per z plane
- Parameters:
database (pandas array) – pandas array of spots
z_planes (np.1darray) – is range of zplanes
- Returns:
n_spots
- file_search(folder, string1, string2)
Search for files containing ‘string1’ in their names within ‘folder’, and then filter the results to include only those containing ‘string2’.
- Parameters:
folder (str) – The directory to search for files.
string1 (str) – The first string to search for in the filenames.
string2 (str) – The second string to filter the filenames containing string1.
- Returns:
file_list (list) – A sorted list of file paths matching the search criteria.
- get_infocus_planes(image, kernel)
Gets z planes that area in focus from an image stack
- Parameters:
image (array) – image as numpy array
kernel (array) – gaussian blur kernel
- Returns:
z_planes (np.1darray) – z_plane range that is in focus
- save_analysis_results(directory, file, to_save, rsid, cell_analysis=False, to_save_cell=0, cell_mask=0)
Saves analysis results to the specified directory.
- Parameters:
directory (str) – The directory where the results will be saved.
file_path (str) – The file path of the original data file.
data_to_save (pandas.DataFrame) – The data to be saved.
rsid (float) – The rsid value associated with the data.
cell_analysis (bool) – Indicates whether cell analysis was performed (default False).
cell_data_to_save (pandas.DataFrame) – The cell data to be saved (default None).
cell_mask (numpy.ndarray) – The cell mask to be saved as a TIFF file (default None).
- save_analysis_results_onesavefile(analysis_directory, file, to_save, rsid, z_planes, i, cell_analysis=False, cell_file=0, to_save_cell=0, cell_mask=0)
Saves analysis results to the specified directory.
- Parameters:
directory (str) – The directory where the results will be saved.
file_path (str) – The file path of the original data file.
data_to_save (pandas.DataFrame) – The data to be saved.
rsid (float) – The rsid value associated with the data.
cell_analysis (bool) – Indicates whether cell analysis was performed (default False).
cell_data_to_save (pandas.DataFrame) – The cell data to be saved (default None).
cell_mask (numpy.ndarray) – The cell mask to be saved as a TIFF file (default None).
- single_image_analysis(protein_file, thres=0.05, large_thres=450.0, gsigma=1.4, rwave=2.0, image_size=200, save_figure=False, cell_analysis=False, cell_file=None)
analyses data from specified image, presents spots, locations, intensities in a figure, with the option of saving this figure
- Parameters:
file (string) – image location
thres (float) – fraction of bright pixels accepted
large_thres (float) – large object intensity threshold
gisgma (float) – gaussian blurring parameter (default 1.4)
rwave (float) – Ricker wavelent sigma (default 2.)
image_size (int) – Amount of image to plot—by default plots 100x100 chunk of an image to give you an idea, can scale up
save_figure (boolean) – save the figure as an svg, default no
cell_analysis (boolean) – Parameter where script also analyses cell images and computes colocalisation likelihood ratios.
cell_file (string) – cell image location