API Reference
This section contains the API documentation for all modules in the Napari Chromosome Analysis project.
Main Module
Image Processor
Author: Md Abdul Kader Sagar Email: sagarm2@nih.gov Institute: National Cancer Institute/NIH
This code is designed for analyzing metaphase chromosomes using the Napari platform. It facilitates the visualization and segmentation of chromosome images, enabling users to efficiently assess chromosome structures and perform quantitative analysis. The code integrates tools for detecting centromeres and measuring CENP-A levels within metaphase chromosome regions, enhancing the accuracy of chromosome analysis.
- class image_processor.ImageProcessor[source]
Bases:
object- get_spots_in_common_regions(df_spots, common_nuclei)[source]
Filter spots to only include those in common regions.
Parameters:
- df_spotspandas.DataFrame
DataFrame containing spot coordinates with columns [‘Y’, ‘X’]
- common_nucleinumpy.ndarray
Label image of common regions
Returns:
- pandas.DataFrame
Filtered DataFrame containing only spots in common regions
- segment_image(image, save_dir=None)[source]
Segment the image using Cellpose and optionally save the results.
- Parameters:
image – Input image to segment
save_dir – Optional directory to save intermediate results
- Returns:
The segmented image masks
- ndi = <module 'scipy.ndimage' from '/home/docs/checkouts/readthedocs.org/user_builds/metachrome/envs/latest/lib/python3.9/site-packages/scipy/ndimage/__init__.py'>
- detect_spots_cent(image, channel_type, threshold, save_dir=None)[source]
Detect spots and save results if save_dir is provided.
- Parameters:
image – Input image
channel_type – Type of channel (‘DNA-FISH’ or ‘CENPC’)
threshold – Detection threshold
save_dir – Directory to save results (optional)
- Returns:
Array of centroids if spots are detected, None otherwise
- Return type:
- detect_spots_no_segmentation(image, threshold=0.4, channel=None)[source]
Detect spots in an image without segmentation.
- Parameters:
image – Input image
threshold – Detection threshold (default: 0.4)
channel – Channel type (‘DNA-FISH’ or ‘CENPC’)
- Returns:
(labeled_spots, centroids) or (None, None) if no spots detected
- Return type:
- find_common()[source]
Find Channel 1 spots in chromosomes that also contain Channel 2 spots and calculate Channel 2 intensity.
- Returns:
Labeled image showing chromosomes with both types of spots None: If no spots are found or an error occurs
- Return type:
Note
Requires prior segmentation (self.nuclei must be set)
Requires prior spot detection for both channels
Updates self.common_nuclei with the labeled image
Updates self.df_centroid_dna_fish with spot locations and intensities
- measure_intensity_at_spots(intensity_image, spots_df, channel_name)[source]
Measure intensity values at spot locations for a single channel.
- Parameters:
intensity_image – Image to measure intensities from
spots_df – DataFrame with spot locations (must have ‘Y’ and ‘X’ columns)
channel_name – Name of the channel (‘Channel1’ or ‘Channel2’)
- Returns:
DataFrame with spot locations and their corresponding intensities
- gen_intensity_from_df(intensity_image_ch2, spots_df_ch1, intensity_image_ch1=None, spots_df_ch2=None)[source]
Generate intensity measurements for both channels at each other’s spot locations.
- Parameters:
intensity_image_ch2 – Channel 2 intensity image
spots_df_ch1 – DataFrame with Channel 1 spot locations
intensity_image_ch1 – Channel 1 intensity image (optional)
spots_df_ch2 – DataFrame with Channel 2 spot locations (optional)
- Returns:
DataFrame with both channels’ spot locations and their corresponding intensities
- calculate_intensity_all_cenpc(intensity_image_ch1=None)[source]
Calculate Channel 1 intensity at all Channel 2 spot locations without segmentation.
- Parameters:
intensity_image_ch1 – Optional Channel 1 intensity image. If not provided, uses self.img_dna_fish
- Returns:
- DataFrame containing spot locations and corresponding intensities,
or None if spots or intensity image are missing
- Return type:
pandas.DataFrame
- calculate_intensity_all_dna_fish(intensity_image_ch2=None)[source]
Calculate Channel 2 intensity at all Channel 1 spot locations without segmentation.
- Parameters:
intensity_image_ch2 – Optional Channel 2 intensity image. If not provided, uses self.img_cenpc
- Returns:
- DataFrame containing spot locations and corresponding intensities,
or None if spots or intensity image are missing
- Return type:
pandas.DataFrame
- delete_dna_fish_spots_with_line(viewer)[source]
Delete DNA-FISH spots that intersect with the drawn line or points.
Batch Processor
Segmentation Post-processing
Author: Md Abdul Kader Sagar Email: sagarm2@nih.gov Institute: National Cancer Institute/NIH
This code is designed for analyzing metaphase chromosomes using the Napari platform. It facilitates the visualization and segmentation of chromosome images, enabling users to efficiently assess chromosome structures and perform quantitative analysis. The code integrates tools for detecting centromeres and measuring CENP-A levels within metaphase chromosome regions, enhancing the accuracy of chromosome analysis.