-
Notifications
You must be signed in to change notification settings - Fork 1
PyPlaque_view_fp_readout_object
PyPlaque.view.fp_readout_object
Class PlaqueObjectReadout is designed to encapsulate data related to a single instance of a plaque from a fluorescence plaque well.
Attributes: nuclei_image_name (str, required): The name of the nuclei image, which serves as an identifier for the nuclei image.
nuclei_object (np.ndarray, required): A 2D numpy array representing the image of the nuclei
image.
nuclei_object_mask (np.ndarray, required): A 2D numpy array serving as a mask for the nuclei
image.
plaque_image_name (str, required): The name of the plaque image plate, which serves as an
identifier for the plaque image.
plaque_object (np.ndarray, required): A 2D numpy array representing the image of the plaque
image.
plaque_object_mask (np.ndarray, required): A 2D numpy array serving as a mask for the plaque
image.
plaque_object_properties (regionprops object, required): Properties of the plaque object,
typically obtained using `skimage.measure`.
virus_params (dict, required): A dictionary containing parameters specific to the virus
channel, which can be used in further analyses or experiments.
Raises: TypeError: If the data types for any of the arguments do not match their expected types as specified in the class definition.
eccentricity Method
Calculates and returns the eccentricity of the plaque object. The eccentricity is determined by fitting an ellipse to the contour of the plaque and calculating it based on the ratio of the semi-major axis (a) to the semi-minor axis (b), using the formula sqrt(1 - (b^2 / a^2)). This method finds the first contour with more than five points, fits an ellipse to it, and computes the eccentricity. If no suitable contours are found or if the rotation angle of the fitted ellipse is zero, resulting values may not be reliable.
Args:
Returns: float: The calculated eccentricity value of the plaque object.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_area Method
Returns the area of the plaque object. If the parameter 'use_picks' is set to True, this method uses Pick's measurements to calculate the area; otherwise, it calculates the area by summing the pixel values of the binary representation of the plaque object.
Args:
Returns: float or int: The calculated or retrieved area of the plaque object. Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_bbox Method
Returns the bounding box coordinates of the plaque object. The bounding box is derived from the properties of the plaque object's image, specifically its minimum bounding rectangle. This method returns a tuple containing the x-coordinate and y-coordinate of the top-left corner of the bounding box, followed by the width and height of the box.
Args:
Returns: tuple: A tuple (x1, y1, width, height) where (x1, y1) is the coordinate of the top-left corner of the bounding box, and width and height are its dimensions.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_centroid Method
Returns the centroid coordinates of the plaque object. The centroid is a property derived from the properties of the plaque object's image, specifically its moments which are used to calculate the center of mass.
Args:
Returns: tuple: A tuple (x_coordinate, y_coordinate) representing the centroid coordinates of the plaque object.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_column Method
Searches for and returns the first match of a specified column pattern in the nuclei
image name. The method uses the regular expression module re to find matches within the
string representing the nuclei image name. If no pattern is provided, it defaults to using
the one stored with the object.
Args: column_pattern (str or re.Pattern, optional): A regular expression pattern as a string or compiled regular expression object used for matching against the nuclei image name. If not provided, the default pattern associated with the object is used.
Returns: str: The first match found in the nuclei image name based on the given column pattern.
Raises: IndexError: If there are no matches found and the function tries to access an element of a non-existing list, this error may be raised. Ensure that the pattern provided is appropriate for the string format or consider adding checks before accessing results.
get_convex_area Method
Returns the convex area of the plaque object, which is a property derived from its convex hull transformation.
Args:
Returns: float: The convex area of the plaque object.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_eccentricity Method
Calls and returns the result of the eccentricity calculation for the plaque object.
This method simply wraps a call to the private method eccentricity() to retrieve the
eccentricity value of the plaque object.
Args:
Returns:
float: The calculated eccentricity value of the plaque object as obtained from the
eccentricity() method.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_infected_nuclei_in_plaque Method
Calculates and returns the number of infected nuclei in the plaque. The method uses a mask to identify areas where both the plaque object and the nuclei object are non-zero, then calculates the sum of these areas to estimate the number of infected cells. It optionally uses Pick's measurement for cell area if specified.
Args:
Returns: float: The estimated number of infected nuclei in the plaque based on the masked areas.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_major_minor_axis_length Method
Returns the lengths of the major and minor axes of the ellipse fitted to the plaque object's contour. These lengths are properties derived from the convex hull transformation of the plaque object's image.
Args:
Returns: tuple: A tuple containing two float values, the first being the length of the major axis and the second being the length of the minor axis.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_max_intensity_GFP Method
Calculates and returns the maximum intensity of GFP in the plaque object.
Args:
Returns: float: The maximum intensity of GFP in the plaque object, calculated as the maximum value after applying the mask to the plaque image.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_mean_intensity_GFP Method
Calculates and returns the mean intensity of GFP in the plaque object.
Args:
Returns: float: The mean intensity of GFP in the plaque object, or 0 if no non-zero values are found.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_nuclei_in_plaque Method
Calculates and returns the number of nuclei in the plaque. The method uses a mask to identify areas where both the plaque object (after convex hull transformation) and the nuclei object are non-zero, then calculates the sum of these areas to estimate the number of cells. It optionally uses Pick's measurements for cell area if specified.
Args:
Returns: float: The estimated number of nuclei in the plaque based on the masked areas.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_number_of_peaks Method
Identifies and returns the coordinates of peaks in the plaque object based on a Gaussian-blurred image. The method applies a Gaussian filter to enhance peak detection, then uses skimage.feature.peak_local_max to find local maxima.
Args:
Returns: numpy.ndarray or None: An array of shape (N, 2) containing the coordinates of peaks if fine plaque detection is enabled; otherwise, returns None.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_perimeter Method
Returns the perimeter of the plaque object. If the parameter 'use_picks' is set to True, this method uses Picks' measurements to calculate the perimeter; otherwise, it returns the stored perimeter value from the properties of the plaque object's image.
Args:
Returns: float or int: The calculated or retrieved perimeter of the plaque object.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_roundness Method
Calls and returns the result of the roundness calculation for the plaque object.
This method simply wraps a call to the private method roundness() to retrieve the
roundness value of the plaque object.
Args:
Returns:
float: The calculated roundness value of the plaque object as obtained from the
roundness() method.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
get_row Method
Searches for and returns the first match of a specified row pattern in the nuclei image
name. The method uses the regular expression module re to find matches within the string
representing the nuclei image name.
Args: row_pattern (str or re.Pattern, optional): A regular expression pattern as a string or compiled regular expression object used for matching against the nuclei image name. If not provided, the default pattern associated with the object is used.
Returns: str: The first match found in the nuclei image name based on the given row pattern.
Raises: IndexError: If there are no matches found and the function tries to access an element of a non-existing list, this error may be raised. Ensure that the pattern provided is appropriate for the string format or consider adding checks before accessing results.
get_total_intensity_GFP Method
Calculates and returns the total intensity of GFP in the plaque object.
Args:
Returns: float: The total intensity of GFP in the plaque object, calculated as the sum of non-zero values after applying the mask.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.
roundness Method
Calculates and returns the roundness of the plaque object. The roundness is determined based on the perimeter and area of the plaque object, using either Pick's measurements or bounding box calculations if Pick's is not used.
Args:
Returns: float: The calculated roundness value of the plaque object.
Raises: Any exceptions that might be raised by the operations within this method can be handled here, but this method does not explicitly raise any errors itself.