hitips package¶
Submodules¶
hitips.Analysis module¶
- class hitips.Analysis.ImageAnalyzer(params_dict)¶
Bases:
objectA class for analyzing and processing biological images, focusing on segmentation and tracking.
- gui_params(object)¶
- Type:
Configuration parameters from the GUI or other settings.
- __init__(self, gui_params):
Initializes the ImageAnalyzer with configuration parameters.
- neuceli_segmenter(self, input_img, pixpermic=None):
Segments nuclei in an image using various methods.
- deepcell_segmenter(self, input_img, mmp=None):
Segments nuclei using DeepCell’s NuclearSegmentation application.
- cellpose_segmenter(self, input_img, use_GPU, cell_dia=None):
Segments cells using the Cellpose model.
- segmenter_function(self, input_img, cell_size=None, first_threshold=None, second_threshold=None):
Advanced segmentation using blurring, thresholding, and watershed.
- watershed_scikit(self, input_img, cell_size=None, first_threshold=None, second_threshold=None):
Image segmentation using scikit-image’s watershed algorithm.
- max_z_project(self, image_stack):
Maximum intensity projection from an image stack.
- SpotDetector(self, \*\*kwargs):
Detects spots in an image using various methods.
- spots_information(self, bin_img_log, max_project, gaussian_fit=False, min_area=0, max_area=100, min_integrated_intensity=0, psf_size=1.6):
Analyzes and refines detected spots.
- gmask_fit(self, pic, xy_input=None, fit=False, psf_size=1.6):
Gaussian mask fitting for spot characteristics.
- local_background(self, pic, display=False):
Calculates local background using a linear fit to border pixels.
- COORDINATES_TO_CIRCLE(self, coordinates, ImageForSpots, circ_radius=5):
Draws circles at specified coordinates on an image.
- SPOTS_TO_BOUNDARY(self, final_spots):
Converts a binary image of spots to highlighted boundaries.
- __init__(params_dict)¶
Initializes the ImageAnalyzer with configuration parameters.
- Parameters:
gui_params (object) – Configuration parameters for image analysis.
- update_params_dict(params_dict)¶
- neuceli_segmenter(input_img, pixpermic=None)¶
Segments nuclei in an image using various methods based on GUI settings.
- Parameters:
input_img (numpy.ndarray) – Input image for nuclei segmentation.
pixpermic (float, optional) – Microns per pixel for physical size in the image. Default is None.
- Returns:
- A tuple containing:
boundary (numpy.ndarray): Image with marked nuclei boundaries.
mask (numpy.ndarray): Binary mask of segmented nuclei.
- Return type:
tuple
- Usage:
boundary, mask = image_analyzer.neuceli_segmenter(input_image, pixpermic=0.5)
- deepcell_segmenter(input_img, mmp=None)¶
Performs nuclear segmentation on an input image using DeepCell’s NuclearSegmentation application.
- Parameters:
input_img (-) – The input image for segmentation, expected to be a 2D array representing a grayscale image.
mmp (-) – Microns per pixel value for the input image. Adjusts the model’s internal scaling for accurate size representation. Default is None.
- Returns:
Image with boundaries of nuclei marked as white lines on a black background. - mask (numpy.ndarray): Binary mask image with filled areas representing segmented nuclei.
- Return type:
boundary (numpy.ndarray)
The function initializes the NuclearSegmentation model, processes the input image, and uses the model to predict nuclear masks. It then finds and processes boundaries to create clear nuclear boundary and mask images.
- Usage Example:
boundary, mask = deepcell_segmenter(input_image, mmp=0.5)
Note
Ensure the deepcell library is installed and properly set up. The input image should be in grayscale. The mmp parameter is important for physical size representation in medical imaging.
- cellpose_segmenter(input_img, use_GPU, cell_dia=None)¶
Performs cell segmentation on an input image using the Cellpose model.
- Parameters:
input_img (-) – The input image for segmentation.
use_GPU (-) – Flag to indicate whether to use GPU acceleration.
cell_dia (-) – Estimated diameter of the cells in pixels. Default is None.
- Returns:
Image with boundaries of cells marked. - mask (numpy.ndarray): Binary mask image with filled areas representing segmented cells.
- Return type:
boundary (numpy.ndarray)
This function uses the Cellpose model for segmentation. The user can choose between the ‘cyto’ and ‘nuclei’ model types based on the NucDetectMethod_currentText parameter from gui_params. The function applies pre-processing and post-processing steps to enhance the segmentation results, including optional boundary removal and morphological operations for cleaning the mask.
- Usage Example:
boundary, mask = cellpose_segmenter(input_image, True, cell_dia=100)
Note
Requires the Cellpose and OpenCV libraries. The use_GPU parameter should be set according to the available hardware. The function adjusts the processing steps based on the NucRemoveBoundaryCheckBox_isChecked parameter from gui_params.
- segmenter_function(input_img, cell_size=None, first_threshold=None, second_threshold=None)¶
Performs advanced image segmentation using a combination of blurring, thresholding, and the watershed algorithm.
- Parameters:
input_img (-) – The input image for segmentation.
cell_size (-) – Size of the kernel for median blurring. If even, it is incremented by 1. Default is None.
first_threshold (-) – Threshold value for the first round of thresholding in the watershed algorithm. Default is None.
second_threshold (-) – Threshold value for the second round of thresholding in the watershed algorithm. Default is None.
- Returns:
Image showing the boundaries of segmented regions. - mask (numpy.ndarray): Binary mask image with segmented regions filled.
- Return type:
boundary (numpy.ndarray)
The function applies a series of image processing steps including median and Gaussian blurring, binary thresholding, hole filling, distance transformation, and watershed transformation for accurate segmentation. It returns the boundaries of segmented regions and a binary mask of these regions.
- Usage Example:
boundary, mask = segmenter_function(input_image, cell_size=5, first_threshold=50, second_threshold=150)
Note
Requires OpenCV and SciPy libraries. The cell_size, first_threshold, and second_threshold parameters should be chosen based on the specific requirements of the image analysis task.
- watershed_scikit(input_img, cell_size=None, first_threshold=None, second_threshold=None)¶
Performs image segmentation using the watershed algorithm implemented in scikit-image.
- Parameters:
input_img (-) – The input image for segmentation.
cell_size (-) – Not used in the current implementation, but can be included for future use. Default is None.
first_threshold (-) – Threshold value for the first distance transform in watershed segmentation. Default is None.
second_threshold (-) – Threshold value for the second distance transform in watershed segmentation. Default is None.
- Returns:
Image showing the boundaries of segmented regions. - mask (numpy.ndarray): Binary mask image with segmented regions filled.
- Return type:
boundary (numpy.ndarray)
The function applies median filtering, thresholding, hole filling, and distance transformation, followed by the watershed algorithm for segmentation. It identifies and labels the regions of interest in the input image and returns the boundaries and binary mask of these regions.
- Usage Example:
boundary, mask = watershed_scikit(input_image, first_threshold=0.1, second_threshold=0.2)
Note
Requires scikit-image, OpenCV, and SciPy libraries. The first_threshold and second_threshold parameters are critical for the watershed segmentation process and should be chosen based on the specific requirements of the image analysis task.
- max_z_project(image_stack)¶
Performs a maximum intensity projection (max-z projection) on a stack of images.
- Parameters:
image_stack (-) – pandas.DataFrame
image. (A DataFrame where each row represents an) –
file (It must contain the columns 'ImageName' and 'Type'. 'ImageName' should be the path to the image) –
column. (or 'dask_array' to indicate the image is in the 'Type') –
- Returns:
- A 2D array representing the maximum intensity projection
of the input image stack.
- Return type:
max_project (numpy.ndarray)
The function iterates through the image stack, reads each image (either from a file or directly if it’s a dask array), and compiles them into a 3D numpy array. It then computes the maximum intensity projection along the z-axis (axis=2) of this stack, effectively condensing the image stack into a single 2D image highlighting the most intense pixels across the stack.
- Usage Example:
max_projection_image = max_z_project(image_dataframe)
Note
The input image_stack DataFrame must be properly formatted with ‘ImageName’ and ‘Type’ columns. The function requires ‘pandas’ for DataFrame handling and ‘PIL.Image’ for image processing.
- SpotDetector(**kwargs)¶
Performs spot detection in an input image using various methods such as Laplacian of Gaussian, Gaussian filtering, intensity thresholding, and Enhanced LOG.
- Parameters:
kwargs (-) – Keyword arguments containing parameters for the spot detection process.
pairs (The function expects the following key-value) –
'input_image_raw' (-) – Raw input image for spot detection.
'nuclei_image' (-) – Mask of nuclei, used in preprocessing.
'spot_detection_method' (-) – Method for spot detection (‘Laplacian of Gaussian’, ‘Gaussian’, ‘Intensity Threshold’, ‘Enhanced LOG’).
'threshold_method' (-) – Method for thresholding (‘Auto’ or ‘Manual’).
'threshold_value' (-) – Threshold value for ‘Manual’ method.
'kernel_size' (-) – Kernel size for filtering.
'spot_location_coords' (-) – Method to calculate spot locations (‘CenterOfMass’, ‘MaxIntensity’, ‘Centroid’).
'remove_bright_junk' (-) – Flag to remove bright artifacts.
'resize_factor' (-) – Factor to resize the image.
'min_area' (-) – Minimum area for spots.
'max_area' (-) – Maximum area for spots.
'min_integrated_intensity' (-) – Minimum integrated intensity for spots.
'psf_size' (-) – Point spread function size.
'gaussian_fit' (-) – Flag to perform Gaussian fitting.
- Returns:
List of coordinates for detected spots. - spots_df (pandas.DataFrame): DataFrame containing information about detected spots.
- Return type:
spot_locations (list)
This function applies various image processing techniques based on the specified spot detection method. It handles pre-processing, spot detection, thresholding, and calculates spot locations based on the specified method. The function returns the locations of detected spots along with a DataFrame containing detailed information about these spots.
- Usage Example:
- spot_locations, spots_info = SpotDetector(input_image_raw=img, nuclei_image=nuclei_img,
spot_detection_method=”Laplacian of Gaussian”, threshold_method=”Auto”, kernel_size=3)
Note
Requires cv2, numpy, scipy, and pandas libraries. The parameters should be carefully chosen based on the characteristics of the input image and the specific requirements of the spot detection task.
- spots_information(bin_img_log, max_project, gaussian_fit=False, min_area=0, max_area=100, min_integrated_intensity=0, psf_size=1.6)¶
Extracts and analyzes information about spots detected in an image, performing additional processing and calculations to refine the spot detection results.
- Parameters:
bin_img_log (-) – Binary image where spots are identified.
max_project (-) – Maximum projection image used for intensity measurements.
gaussian_fit (-) – Flag to perform Gaussian fitting on spots. Default is False.
min_area (-) – Minimum area threshold for spots to be considered. Default is 0.
max_area (-) – Maximum area threshold for spots. Default is 100.
min_integrated_intensity (-) – Minimum integrated intensity threshold for spots. Default is 0.
psf_size (-) – Point spread function size used in Gaussian fitting. Default is 1.6.
- Returns:
DataFrame containing properties of each spot, including area, intensity metrics, and location. - new_bin_img_log (numpy.ndarray): Refined binary image of spots after processing. - labeled_spots (numpy.ndarray): Image with labeled spots.
- Return type:
props_df (pandas.DataFrame)
The function performs several operations including labeling of spots, filtering based on area and intensity, and optional Gaussian fitting. It calculates various properties of the spots, such as area, intensity, and location coordinates, and returns a DataFrame with these properties along with refined binary and labeled images of the spots.
- Usage Example:
spots_props, refined_spots, labeled_spots = spots_information(binary_image, max_projection, gaussian_fit=True, min_area=5)
Note
Requires scipy, numpy, pandas, and optionally cv2 for Gaussian fitting. The parameters for area and intensity thresholds should be chosen based on the specific requirements of the image analysis task.
- gmask_fit(pic, xy_input=None, fit=False, psf_size=1.6)¶
Performs Gaussian mask fitting on an image to determine the centroid and photon number of a spot.
- Parameters:
pic (-) – The image (or a patch of the image) containing the spot to be analyzed.
xy_input (-) – Initial guess for the centroid coordinates (x0, y0). Required if ‘fit’ is False.
fit (-) – If True, performs iterative fitting to find the centroid. If False, uses ‘xy_input’ as the centroid. Default is False.
psf_size (-) – Point spread function size, used in the Gaussian mask. Default is 1.6.
- Returns:
A numpy array containing the fitted centroid coordinates (x0, y0) and the calculated photon number.
- Return type:
results (numpy.ndarray)
This function applies a Gaussian mask fitting method to an image to determine the centroid coordinates and the number of photons in a spot. It either uses an iterative fitting process or a fixed position based on the provided initial guess. The function subtracts the local background before the fitting process and uses the error function (erf) to create the Gaussian mask.
- Usage Example:
fitted_results = gmask_fit(image_patch, xy_input=(10, 10), fit=True, psf_size=1.5)
Note
Requires numpy and scipy (for the error function). The ‘pic’ should be a cropped image or a patch containing the spot for accurate fitting. The ‘fit’ parameter determines whether to perform iterative fitting or use a fixed centroid position.
- local_background(pic, display=False)¶
Calculates the local background of an image using a linear fit to the border pixels.
- Parameters:
pic (-) – The input image for which the local background needs to be calculated.
display (-) – Flag to display intermediate calculation steps. Default is False.
- Returns:
An array of the same shape as ‘pic’, containing the calculated local background plane.
- Return type:
plane (numpy.ndarray)
This function calculates the local background by fitting a linear plane to the border pixels of the input image. It uses a method similar to that described in Bevington’s book (p. 96) to calculate the fit parameters and then applies these parameters to define a background plane. This background can be subtracted from the original image to correct for varying background levels.
- Usage Example:
background_plane = local_background(image)
Note
Designed for use with 2D numpy arrays representing images. The ‘display’ parameter can be set to True for debugging purposes to observe the intermediate steps of the calculation.
- COORDINATES_TO_CIRCLE(coordinates, ImageForSpots, circ_radius=5)¶
Creates an image with circles drawn at specified coordinates.
- Parameters:
coordinates (-) – An array of coordinates where each row represents a point (y, x).
ImageForSpots (-) – The base image used to define the shape of the output image.
circ_radius (-) – The radius of the circles to be drawn. Default is 5.
- Returns:
An image of the same size as ‘ImageForSpots’ with circles drawn at the specified coordinates.
- Return type:
circles (numpy.ndarray)
This function takes a set of coordinates and draws circles of a given radius at these coordinates on an image. The output is a binary image where the circles are marked in white (255) on a black (0) background.
- Usage Example:
circle_image = COORDINATES_TO_CIRCLE(coordinates_array, base_image, circ_radius=10)
Note
Requires numpy and skimage.draw (for circle_perimeter). Ensure that the coordinates are within the bounds of ‘ImageForSpots’.
- SPOTS_TO_BOUNDARY(final_spots)¶
Converts a binary image of spots into an image where the boundaries of these spots are highlighted.
- Parameters:
final_spots (-) – A binary image where spots are represented by non-zero pixels.
- Returns:
An image where the boundaries of the spots in ‘final_spots’ are marked.
- Return type:
spot_boundary (numpy.ndarray)
This function identifies the boundaries of spots in a binary image and creates a new image where these boundaries are highlighted. The output is a binary image with boundaries marked in white (255) on a black (0) background.
- Usage Example:
boundary_image = SPOTS_TO_BOUNDARY(spots_image)
Note
Requires numpy and skimage.segmentation (for find_boundaries). The input should be a binary image with spots marked.
hitips.AnalysisGUI module¶
- class hitips.AnalysisGUI.analyzer(centralwidget, gridLayout_centralwidget, displaygui=None, ImDisplay=None, image_analyzer=None, gui_params=None)¶
Bases:
QWidget- __init__(centralwidget, gridLayout_centralwidget, displaygui=None, ImDisplay=None, image_analyzer=None, gui_params=None)¶
- set_image_analyzer(image_analyzer)¶
- set_imdisplay(ImDisplay)¶
- FIRST_THRESH_LABEL_UPDATE()¶
- SECOND_THRESH_LABEL_UPDATE()¶
- NUCLEI_AREA_LABEL_UPDATE()¶
- SPOT_THRESH_LABEL_UPDATE()¶
- set_gui_params(gui_params)¶
- INITIALIZE_SEGMENTATION_PARAMETERS()¶
hitips.BatchAnalyzer module¶
- class hitips.BatchAnalyzer.BatchAnalysis(params_dict=None)¶
Bases:
objectA class used to conduct batch analysis of biological image data, focusing on the analysis of cells and spots.
- Various shared data lists and attributes for storing analysis results and configuration details.
- __init__(self, Gui_Params, image_analyzer):
Initializes the BatchAnalysis object with required parameters and data structures.
- ON_APPLYBUTTON(self, Meta_Data_df):
Begins the batch analysis process, setting paths, reading metadata, and initiating various analyses.
- SAVE_NUCLEI_INFORMATION(self, cell_df, columns, rows):
Saves analyzed information about nuclei into designated output files.
- SAVE_SPOT_INFO(self, spot_df, coordinates_method, columns, rows, channel_name):
Saves the analyzed spot information for specific channels and methods.
- process_channel(self, channel_spot_df_list, columns, rows, channel_name):
Processes each channel and saves spot information if necessary.
- PROCESS_ALL_SPOT_CHANNELS(self):
Processes all spot channels and compiles their analyzed information.
- update_cell_index_in_channel(self, channel_attr, col, row, fov, time_point, previous_index, new_index):
Updates cell indices in a specified channel’s DataFrame.
- update_cell_index_in_all_spot_channels(self, col, row, fov, time_point, previous_index, new_index):
Updates cell indices across all spot channels.
- normalize_stack(self, images):
Normalizes a stack of images.
- cell_level_file_name(self, top_folder, folder_name, name_prefix, name_extention, col, row, fov, cell_ind, spot_ch=None):
Generates file names for saving cell level data.
- spot_level_file_name(self, top_folder, folder_name, name_prefix, name_extention, col, row, fov, cell_ind, spot_ch, spot_ind):
Generates file names for saving spot level data.
- BATCH_ANALYZER(self, col, row, fov, t):
Analyzes a batch of images for nuclei and spots, updating the results lists.
- Calculate_Spot_Distances(self, row, col):
Calculates the distances between spots for given cells.
- DISTANCE_calculator(self, spot_pd_dict, key1, key2, select_cell, row, col):
A helper function for calculating distances between spots.
- IMG_FOR_NUC_MASK(self):
Loads the image used for creating nuclei masks.
- RAW_IMAGE_LOADER(self, maskchannel):
Loads raw images for a specified channel.
- Z_STACK_NUC_SEGMENTER(self, ImageForNucMask):
Segments nuclei from a z-stack of images.
- Z_STACK_NUC_LABLER(self, ImageForLabel):
Labels nuclei in a z-stack of images.
- IMAGE_FOR_SPOT_DETECTION(self, ImageForNucMask):
Prepares images for spot detection and retrieves coordinates.
- XYZ_SPOT_COORDINATES(self, images_pd_df, ImageForNucMask, spot_channel):
Retrieves XYZ coordinates for spots in a specified channel.
- RADIAL_DIST_CALC(self, xyz_round, spot_nuc_labels, radial_dist_df, dist_img):
Calculates radial distances for spots.
- __init__(params_dict=None)¶
Initializes the BatchAnalysis object with necessary parameters and structures for analysis.
Parameters:
- Gui_Params[type]
Parameters from the GUI for controlling analysis settings.
- image_analyzer[type]
The image analyzer object to use for processing the images.
- Returns:
None
- update_params_dict(params_dict)¶
- check_and_append_args(col, row, fov, t, func_args)¶
- ON_APPLYBUTTON(Meta_Data_df)¶
Begins the batch analysis process, including setting paths, reading metadata, and initiating analyses.
Parameters:
- Meta_Data_dfDataFrame
Metadata DataFrame containing information about the images to be analyzed.
- Returns:
None
- remove_readonly(func, path, _)¶
Clear the readonly bit and reattempt the removal
- get_package_versions(packages)¶
- SAVE_NUCLEI_INFORMATION(cell_df, columns, rows)¶
Saves analyzed information about nuclei into designated output files.
- Parameters:
cell_df – DataFrame DataFrame containing the analyzed nuclei information.
columns – list List of column indices in the imaging plate.
rows – list List of row indices in the imaging plate.
- Returns:
None
- SAVE_SPOT_INFO(spot_df, coordinates_method, columns, rows, channel_name)¶
Saves the analyzed spot information for specific channels and methods.
Parameters:¶
- spot_dfDataFrame
DataFrame containing the analyzed spot information.
- coordinates_methodstr
The method used for determining the coordinates of spots.
- columnslist
List of column indices in the imaging plate.
- rowslist
List of row indices in the imaging plate.
- channel_namestr
Name of the channel for which the spot information is being saved.
Returns:¶
None
- process_channel(channel_spot_df_list, columns, rows, channel_name)¶
Processes each channel and saves spot information if necessary.
Parameters:¶
- channel_spot_df_listlist
A list of DataFrames, each containing spot information for a specific channel.
- columnslist
List of column indices in the imaging plate.
- rowslist
List of row indices in the imaging plate.
- channel_namestr
Name of the channel being processed.
Returns:¶
None
- gather_spot_df_list(channel_name)¶
- PROCESS_ALL_SPOT_CHANNELS()¶
Processes all spot channels and compiles their analyzed information.
Returns:¶
None
- update_cell_index_in_channel(channel_attr, col, row, fov, time_point, previous_index, new_index)¶
Updates cell indices in a specified channel’s DataFrame.
Parameters:¶
- channel_attrstr
The attribute name of the channel DataFrame to be updated.
- colint
Column index of the well.
- rowint
Row index of the well.
- fovint
Field of view index.
- time_pointint
Time point index.
- previous_indexint
The previous cell index.
- new_indexint
The new cell index to replace the previous one.
Returns:¶
None
- update_cell_index_in_all_spot_channels(col, row, fov, time_point, previous_index, new_index)¶
Updates cell indices across all spot channels.
Parameters:¶
- colint
Column index of the well.
- rowint
Row index of the well.
- fovint
Field of view index.
- time_pointint
Time point index.
- previous_indexint
The previous cell index.
- new_indexint
The new cell index to replace the previous one.
Returns:¶
None
- normalize_stack(images)¶
Normalizes a stack of images.
Parameters:¶
- imagesndarray
A stack of images to be normalized.
Returns:¶
- ndarray
The stack of normalized images.
- cell_level_file_name(top_folder, folder_name, name_prefix, name_extention, col, row, fov, cell_ind, spot_ch=None)¶
Generates file names for saving cell level data.
Parameters:¶
- top_folderstr
The top level directory where the files will be saved.
- folder_namestr
The name of the folder where the files will be saved.
- name_prefixstr
The prefix for the file name.
- name_extentionstr
The file extension.
- colint
Column index of the well.
- rowint
Row index of the well.
- fovint
Field of view index.
- cell_indint
The index of the cell.
- spot_chint, optional
The channel index of the spot.
Returns:¶
- str
The generated file path for saving the data.
- spot_level_file_name(top_folder, folder_name, name_prefix, name_extention, col, row, fov, cell_ind, spot_ch, spot_ind)¶
Generates file names for saving spot level data.
Parameters:¶
- top_folderstr
The top level directory where the files will be saved.
- folder_namestr
The name of the folder where the files will be saved.
- name_prefixstr
The prefix for the file name.
- name_extentionstr
The file extension.
- colint
Column index of the well.
- rowint
Row index of the well.
- fovint
Field of view index.
- cell_indint
The index of the cell.
- spot_chint
The channel index of the spot.
- spot_indint
The index of the spot.
Returns:¶
- str
The generated file path for saving the data.
- BATCH_ANALYZER(col, row, fov, t)¶
Analyzes a batch of images for nuclei and spots, updating the results lists.
Parameters:¶
- colint
Column index of the well.
- rowint
Row index of the well.
- fovint
Field of view index.
- tint
Time point index.
Returns:¶
None
- Calculate_Spot_Distances(row, col)¶
Calculates the distances between spots for given cells.
Parameters:¶
- rowint
Row index of the well.
- colint
Column index of the well.
Returns:¶
None
- DISTANCE_calculator(spot_pd_dict, key1, key2, select_cell, row, col)¶
A helper function for calculating distances between spots.
Parameters:¶
- spot_pd_dictdict
Dictionary of spot DataFrames keyed by channel name.
- key1str
The first channel key for comparison.
- key2str
The second channel key for comparison.
- select_cellDataFrame
DataFrame of selected cells for distance calculation.
- rowint
Row index of the well.
- colint
Column index of the well.
Returns:¶
- DataFrame
A DataFrame containing the calculated distances.
- IMG_FOR_NUC_MASK()¶
Loads the image used for creating nuclei masks.
Returns:¶
- ndarray
The loaded image for creating nuclei masks.
- RAW_IMAGE_LOADER(maskchannel)¶
Loads raw images for a specified channel.
Parameters:¶
- maskchannelstr
The channel for which the raw images are to be loaded.
Returns:¶
- ndarray
The loaded raw image for the specified channel.
- Z_STACK_NUC_SEGMENTER(ImageForNucMask)¶
Segments nuclei from a z-stack of images.
Parameters:¶
- ImageForNucMaskndarray
The z-stack image for nuclei segmentation.
Returns:¶
- tuple
A tuple containing the boundary and mask images for segmented nuclei.
- Z_STACK_NUC_LABLER(ImageForLabel)¶
Labels nuclei in a z-stack of images.
Parameters:¶
- ImageForLabelndarray
The z-stack image for nuclei labeling.
Returns:¶
- ndarray
The labeled nuclei image stack.
- IMAGE_FOR_SPOT_DETECTION(ImageForNucMask, nuc_mask=None)¶
Prepares images for spot detection and retrieves coordinates.
Parameters:¶
- nuc_maskndarray
The nuclei mask to assist in spot detection.
Returns:¶
- tuple
A tuple containing the XYZ coordinates and final spots for different channels.
- XYZ_SPOT_COORDINATES(images_pd_df, nuc_mask, spot_channel)¶
Calculates XYZ coordinates of spots in given images, processing each z-slice and generating a max projection.
Parameters:¶
- images_pd_dfDataFrame
DataFrame containing image data, including image paths and z-slice information.
- ImageForNucMaskndarray
Nuclei image used as a mask for spot detection.
- spot_channelstr
Channel identifier used for spot detection.
Returns:¶
- tuple
A tuple containing three elements: 1. xyz_coordinates (ndarray): Array of XYZ coordinates of detected spots in the max projection. 2. coordinates_stack (ndarray): Stack of XYZ coordinates of spots in each z-slice. 3. final_spots (DataFrame): DataFrame containing the final processed spot data.
- RADIAL_DIST_CALC(xyz_round, spot_nuc_labels, radial_dist_df, dist_img)¶
Calculates the radial distance of each spot from the center of its respective nucleus.
Parameters:¶
- xyz_roundndarray
Rounded XYZ coordinates of detected spots.
- spot_nuc_labelsndarray
Labels indicating to which nucleus each spot belongs.
- radial_dist_dfDataFrame
DataFrame containing radial distance information for nuclei.
- dist_imgndarray
Distance transform image of nuclei.
Returns:¶
- ndarray
Array containing the radial distance of each spot from the center of its nucleus.
- SAVE_CONFIGURATION(csv_filename, params_dict)¶
hitips.Cell_Spot_Tracker module¶
- class hitips.Cell_Spot_Tracker.Tracking¶
Bases:
objectThis class provides functionalities for tracking biological cells in image stacks using various tracking algorithms.
Methods: - RUN_BTRACK: Performs Bayesian tracking on a stack of labeled images. - deepcell_tracking: Uses DeepCell for tracking cells in an image stack. - mutual_information: Calculates the mutual information between two images. - zero_pad_patch: Pads an image to a desired size with zeros. - registration_features: Extracts registration features between reference and registered images. - rotation_register_img_prep: Prepares images for rotational registration. - run_registration_rotation: Performs image registration considering rotation. - phase_correlation: Computes phase correlation between reference and registered images. - rotate_point: Rotates a point around a given origin by a specified angle. - get_spot_patch: Extracts small patches around detected spots in an image. - merge_small_clusters: Merges small clusters based on a distance threshold. - run_clustering: Performs clustering on points with options for handling outliers.
- RUN_BTRACK(parms_dict)¶
Performs Bayesian tracking on a stack of labeled images.
Parameters: - label_stack (numpy.ndarray): Stack of labeled images to be tracked. - parms_dict (object): Parameters from the GUI controlling tracking behavior.
Returns: - tracks_pd (pandas.DataFrame): DataFrame containing the tracking information.
This method initializes a Bayesian tracker, configures it using the provided parameters, and performs tracking on the input label stack. It returns a DataFrame containing the tracked objects and their properties.
- deepcell_tracking(masks_stack, params_dict)¶
Performs cell tracking using the DeepCell tracking algorithm.
Parameters: - t_stack_nuc (numpy.ndarray): Time-lapse stack of nuclear images. - masks_stack (numpy.ndarray): Corresponding stack of masks for the nuclei. - parms_dict (object): GUI parameters for tracking.
Returns: - tracks_pd (pandas.DataFrame): DataFrame containing tracked cell information over time.
This method uses DeepCell for tracking cells in a time-lapse image stack. It returns a DataFrame with detailed tracking information.
- mutual_information()¶
Calculates the mutual information between two images based on their joint histogram.
Parameters: - hgram (numpy.ndarray): Joint histogram of the two images.
Returns: - mi (float): Mutual information value.
This method computes the mutual information, a measure of the mutual dependence between two images.
- zero_pad_patch(desired_size=(128, 128))¶
Pads an image with zeros to a desired size.
Parameters: - input_image (numpy.ndarray): The input image to be padded. - desired_size (tuple): The desired size of the output image.
Returns: - padded_image (numpy.ndarray): The zero-padded image.
This method pads an input image with zeros to reach the specified size, centering the original image in the padded area.
- registration_features(ref_mask, reg_img, reg_mask)¶
Extracts various features to evaluate the quality of image registration.
Parameters: - ref_img (numpy.ndarray): The reference image. - ref_mask (numpy.ndarray): Mask of the reference image. - reg_img (numpy.ndarray): The registered image to compare with the reference. - reg_mask (numpy.ndarray): Mask of the registered image.
Returns: - features (numpy.ndarray): Array of registration quality features.
This method computes features such as cosine similarity, mutual information, SSIM, and others to evaluate registration quality.
- rotation_register_img_prep(reg_img, rotation_angle, median_disk_size=3)¶
Prepares images for rotational registration.
Parameters: - ref_img (numpy.ndarray): The reference image. - reg_img (numpy.ndarray): The image to be registered. - rotation_angle (float): The angle for initial rotation. - median_disk_size (int): The size of the median filter disk.
Returns: - median_ref_img, median_reg_img (numpy.ndarray): Preprocessed images ready for registration.
This method prepares images for rotation-based registration by applying median filtering and adjusting for initial rotation.
- run_registration_rotation()¶
Performs image registration considering rotation.
Parameters: - angle (float): The rotation angle to be applied.
Returns: - registration_features (numpy.ndarray): Features indicative of registration quality.
This method performs image registration by considering a specific rotation angle and returns features to evaluate the registration.
- phase_correlation(reg_img, intial_rotation=15, rescale_factor=5, nuc_length=50)¶
Computes phase correlation between two images to determine the rotational alignment.
Parameters: - ref_img (numpy.ndarray): The reference image. - reg_img (numpy.ndarray): The image to be registered. - initial_rotation (float): Initial rotation angle applied to the registered image. - rescale_factor (int): Factor by which the images are rescaled. - nuc_length (int): Length of the nucleus for determining the rescaling radius.
Returns: - final_angle (float): The calculated final rotation angle. - rotated_img (numpy.ndarray): The rotated image after alignment.
This method computes the phase correlation to align two images rotationally and returns the final rotation angle and the aligned image.
- rotate_point(point, angle)¶
Rotates a point counterclockwise by a given angle around a given origin.
Parameters: - origin (tuple): The origin point for rotation. - point (tuple): The point to be rotated. - angle (float): The rotation angle in radians.
Returns: - (qx, qy) (tuple): The coordinates of the rotated point.
This utility method rotates a point around a given origin by the specified angle.
- get_spot_patch(chnl, lbl1, rot_spot_patches, spot_boundary=4)¶
Extracts small patches around detected spots in an image.
Parameters: - single_track_copy (pandas.DataFrame): DataFrame containing spot tracking information. - chnl (int): Channel number to be considered. - lbl1 (int): Label number for the spot. - rot_spot_patches (numpy.ndarray): Array of rotated spot patches. - spot_boundary (int): Size of the boundary around the spot for patch extraction.
Returns: - small_spot_patches (dict): Dictionary of extracted spot patches. - spot_patches_center_coords (dict): Dictionary of center coordinates for each spot patch.
This method extracts small patches around detected spots based on the provided tracking information and spot boundaries.
- merge_small_clusters(labels, max_dist, min_burst_duration)¶
Merges small clusters of points based on a distance threshold.
Parameters: - points (numpy.ndarray): Array of point coordinates. - labels (numpy.ndarray): Array of cluster labels for each point. - max_dist (float): Maximum distance threshold for merging clusters.
Returns: - labels (numpy.ndarray): Updated array of cluster labels after merging.
This method merges small clusters into larger ones based on proximity, using the specified distance threshold.
- run_clustering(outlier_threshold=2, max_dist=6, min_burst_duration=1)¶
Performs clustering on a set of points, with options for handling outliers.
Parameters: - points (numpy.ndarray): Array of points to be clustered. - outlier_threshold (float): Threshold for determining outliers. - max_dist (float): Maximum distance for clustering points.
Returns: - clusters (numpy.ndarray): Array of cluster labels for each point.
This method performs hierarchical clustering on points, treats outliers based on the specified threshold, and merges small clusters.
hitips.Display module¶
- class hitips.Display.imagedisplayer(centralwidget, gui_params, analysisgui)¶
Bases:
object- METADATA_DATAFRAME = Empty DataFrame Columns: [] Index: []¶
- imgchannels = Empty DataFrame Columns: [] Index: []¶
- grid_data = array([0, 0, 0, 0, 0])¶
- __init__(centralwidget, gui_params, analysisgui)¶
- display_initializer(out_df, displaygui, IO_GUI)¶
- MAX_HIST_SLIDER_UPDATE(displaygui)¶
- MIN_HIST_SLIDER_UPDATE(displaygui)¶
- GET_IMAGE_NAME(displaygui)¶
- READ_IMAGE(displaygui, image_channels)¶
- ADJUST_IMAGE_CONTRAST(displaygui, all_channels_dict)¶
- MERGEIAMGES(displaygui, all_channels_dict)¶
- apply_lut_color(displaygui, img, rgb_values)¶
- SHOWIMAGE(displaygui, img, width, height, totalBytes)¶
- IMAGE_TO_BE_MASKED()¶
- IMAGE_FOR_SPOT_DETECTION(nuclei_image, displaygui, nuc_mask=None)¶
- ON_ADJUST_INTENSITY(input_img, min_range, max_range)¶
hitips.GUI_parameters module¶
- class hitips.GUI_parameters.Gui_Params(analysisgui, inout_resource_gui, displaygui, ImDisplay=None)¶
Bases:
object- __init__(analysisgui, inout_resource_gui, displaygui, ImDisplay=None)¶
- gather_analysis_params()¶
- update_values()¶
- set_ImDisplay(ImDisplay)¶
- INITIALIZE_SPOT_ANALYSIS_PARAMS()¶
- UPDATE_SPOT_ANALYSIS_PARAMS()¶
- UPDATE_SPOT_ANALYSIS_GUI_PARAMS()¶
- SAVE_CONFIGURATION(csv_filename)¶
- file_save()¶
- LOAD_CONFIGURATION()¶
- OUTPUT_FOLDER_LOADBTN()¶
hitips.GridLayout module¶
- class hitips.GridLayout.gridgenerator(ControlPanel, centralwidget, gridLayout_centralwidget, displaygui, inout_resource_gui, ImDisplay)¶
Bases:
QWidget- first_time = True¶
- __init__(ControlPanel, centralwidget, gridLayout_centralwidget, displaygui, inout_resource_gui, ImDisplay)¶
- disable_well_signals(state)¶
- disable_field_signals(state)¶
- disable_z_signals(state)¶
- disable_time_signals(state)¶
- setup_connections()¶
- on_click_table_save_wells(out_df)¶
- on_click_FOV_list(item)¶
- on_click_Z_list(item)¶
- on_click_Time_list(item)¶
- GRID_INITIALIZER(out_df, displaygui, inout_resource_gui, ImDisplay)¶
- on_click_table(out_df, displaygui, inout_resource_gui, ImDisplay)¶
- on_click_list(df_checker, ImDisplay, displaygui)¶
- itemActivated_event()¶
hitips.HiTIPS module¶
- class hitips.HiTIPS.ControlPanel¶
Bases:
QWidget- EXIT_CODE_REBOOT = -1234567890¶
- Meta_Data_df = Empty DataFrame Columns: [] Index: []¶
- controlUi(MainWindow)¶
- on_run_analysis()¶
- select_data_subset()¶
- retranslateUi(MainWindow)¶
- ON_RESET_BUTTON()¶
- hitips.HiTIPS.main()¶
hitips.IO_ResourceGUI module¶
- class hitips.IO_ResourceGUI.InOut_resource(centralwidget, gridLayout_centralwidget, analysisgui=None, MetaData_Reader=None)¶
Bases:
QWidget- Num_CPU_cores = 0¶
- Num_GPU_inuse = 0¶
- __init__(centralwidget, gridLayout_centralwidget, analysisgui=None, MetaData_Reader=None)¶
- OUTPUT_FOLDER_LOADBTN()¶
- ON_CPU_INQUIRY_BUTTON()¶
- ON_GPU_num_change()¶
- set_analysisgui(analysisgui)¶
- set_MetaData_Reader(MetaData_Reader)¶
hitips.InputOutput module¶
hitips.MetaData_Reader module¶
- class hitips.MetaData_Reader.ImageReader(ControlPanel, inout_resource_gui, displaygui, analysisgui)¶
Bases:
objectThis class provides functionality for reading and loading various types of biological image data.
Attributes: - ControlPanel: A reference to the ControlPanel object. - analysisgui: A reference to the AnalysisGUI object. - inout_resource_gui: A reference to the IO_ResourceGUI object. - displaygui: A reference to the DisplayGUI object.
Methods: - __init__: Initializes the ImageReader with references to GUI components. - ON_CLICK_LOADBUTTON: Handles the action to load metadata from selected files. - ON_CLICK_LOADIMGBUTTON: Handles the action to load images from selected files. - READ_FROM_METADATA: Reads metadata from a given file and extracts relevant information. - MICROMANAGER_READER: Reads and processes metadata from MicroManager software. - LOAD_BIOFORMAT_DATA: Loads image data from various bioformats supported files.
- __init__(ControlPanel, inout_resource_gui, displaygui, analysisgui)¶
Initializes the ImageReader object with references to GUI components.
Parameters: - ControlPanel: Reference to the ControlPanel object. - inout_resource_gui: Reference to the IO_ResourceGUI object. - displaygui: Reference to the DisplayGUI object. - analysisgui: Reference to the AnalysisGUI object.
- ON_CLICK_LOADBUTTON()¶
Handles the action to load metadata from selected files based on the selected device type in the GUI.
This method allows users to select and load metadata files, processes these files depending on the device type selected in the GUI, and updates the GUI components with the loaded metadata information.
- ON_CLICK_LOADIMGBUTTON()¶
Handles the action to load image files from selected paths.
This method allows users to select and load image files in various formats. It updates the GUI components with information about the loaded images and prepares the data for further analysis.
- READ_FROM_METADATA(metadatafilename)¶
Reads metadata from a specified file and extracts relevant image information.
Parameters: - metadatafilename (str): Path to the metadata file.
Returns: - DataFrame: A pandas DataFrame containing the extracted metadata information.
This method reads and processes metadata from specified CellVoyager files, extracts relevant information, and returns it in a structured DataFrame format.
- MICROMANAGER_READER(metadatadir)¶
Reads and processes metadata from the MicroManager software.
Parameters: - metadatadir (str): Directory containing the metadata files.
Returns: - DataFrame: A pandas DataFrame containing metadata information processed from MicroManager files.
This method processes metadata from a specified directory containing MicroManager files, organizes the metadata into a structured format, and returns it as a pandas DataFrame.
- LOAD_BIOFORMAT_DATA(image_full_path)¶
Loads image data from various bioformats supported files.
Parameters: - image_full_path (list of str): Paths to the image files to be loaded.
Returns: - DataFrame: A pandas DataFrame containing information extracted from the image files.
This method supports loading and processing image data from various file formats (like .czi, .tiff, .tif, .nd2, .ims), organizing this information into a structured DataFrame format.
hitips.logging_decorator module¶
- hitips.logging_decorator.log_errors(logger)¶