motion_correction.desktop package¶
Submodules¶
motion_correction.desktop.flim_aligner module¶
- class motion_correction.desktop.flim_aligner.FlimAligner[source]¶
Bases:
objectA class for aligning and correcting FLIM (Fluorescence Lifetime Imaging Microscopy) data.
- Attributes:
ptfile (str): The path to the input PT3/PTU file. transforms (numpy.ndarray): Transformation matrices estimated from intensity frame alignment. global_method (AlignMethod): The global alignment method (e.g., AlignMethod.PHASE). local_method (AlignMethod): The local alignment method (e.g., AlignMethod.OPTICAL_POLY). channel (int): The channel index selected for intensity frame alignment. shape (tuple): The shape of the FLIM stack data. flim_dict (dict): A dictionary containing the indices and values of non-zero FLIM data entries. flim_frames (numpy.ndarray): FLIM intensity frames before correction. flim_frames_corrected (numpy.ndarray): Corrected FLIM intensity frames. curve_fit (numpy.ndarray): Curve decay curve histogramed data. curve_fit_corrected (numpy.ndarray): Corrected decay curve histogramed data. curve_fit_corrected_int (numpy.ndarray): Corrected curve histogramed data as integers. save_dir (str): The directory where results will be saved. sim_metric (SimMetric): The similarity metric for frame alignment (e.g., SimMetric.NCC). old_sim (numpy.ndarray): Similarity values before alignment for all intensity frames. new_sim (numpy.ndarray): Similarity values after alignment for all intensity frames. meta (dict): Metadata associated with the FLIM data.
- Methods:
set_methods(global_method=None, local_method=None): Set global and local alignment methods. set_sim_metric(sim=SimMetric.NCC): Set the similarity metric for alignment. get_intensity_stack(pt_file, is_raw=False): Load and prepare FLIM intensity data. apply_correction_intensity(ptfile, ref_frame_idx=0): Apply intensity correction to FLIM frames. export_results(save_dir=None): Export corrected results to files. apply_correction_flim(): Apply FLIM data correction.
- apply_correction_flim()[source]¶
Apply FLIM data correction to the loaded data.
This method applies FLIM data correction to the loaded raw FLIM data. It uses the transformations estimated in function apply_correction_intensity to correct the data.
- Note:
This method assumes that the FLIM data has already been loaded using the get_intensity_stack method.
- apply_correction_intensity(ptfile, ref_frame_idx=0)[source]¶
Apply intensity correction to FLIM frames.
- Args:
ptfile (str): The path to the PT3 file. ref_frame_idx (int): The index of the reference frame for alignment.
- export_results(save_dir=None)[source]¶
Export corrected results to files.
- Args:
save_dir (str): The directory where results will be saved.
- get_intensity_stack(pt_file, is_raw=False)[source]¶
Load and prepare FLIM intensity data from a PT3 file.
- Args:
pt_file (str): The path to the PT3 file. is_raw (bool): Whether the data is raw intensity data.
motion_correction.desktop.utility module¶
- motion_correction.desktop.utility.display_images(images: List[str | ndarray], rows: int | None = None, cols: int | None = None, colorbar=True, figsize: Tuple[int, int] = (12, 12)) None[source]¶
Display a list of images in a grid layout using Matplotlib.
- Args:
images (list): List of image paths or NumPy arrays. rows (int): Number of rows in the grid (default: None, automatic calculation). cols (int): Number of columns in the grid (default: None, automatic calculation). figsize (tuple): Size of the figure (default: (10, 10)).
Note: This function displays a grid of images using Matplotlib. It supports both image paths and NumPy arrays as input.
- motion_correction.desktop.utility.plot_grids(u: ndarray, v: ndarray, ax: Axes | None = None, **kwargs) None[source]¶
Plot grid lines on a Matplotlib Axes object.
Parameters: - u (np.ndarray): Horizontal grid lines. - v (np.ndarray): Vertical grid lines. - ax (plt.Axes, optional): Matplotlib Axes object to plot on (default: None).
Note: This function plots grid lines on a Matplotlib Axes object using horizontal and vertical arrays u and v.
- motion_correction.desktop.utility.plot_sequence_images(image_array)[source]¶
Display a sequence of images as an animation/video in a Jupyter notebook.
- Args:
image_array (numpy.ndarray): An array of images with shape (num_images, height, width, num_channels).
Note: This function displays a sequence of images as an animation in a Jupyter notebook.
- motion_correction.desktop.utility.save_sequence_images(file_path, image_array, fps=15)[source]¶
Save a sequence of images as a video file.
- Args:
file_path (str): The file path to save the video. image_array (numpy.ndarray): An array of images with shape (num_images, height, width, num_channels). fps (int): Frames per second for the video (default: 15).
Note: This function saves a sequence of images as a video file at the specified file_path.