API Reference

This page contains the autodocumented API for the primary alexandria modules.

Alexandria - Unified CatPhan Phantom Analysis Library

A comprehensive library for analyzing CatPhan CT phantom DICOM images. Provides modular analyzers for uniformity, resolution, contrast, and linearity analysis.

class alexandria.CTP401Analyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, roi_radius: float = 3.5, material_distance: float = 58.5, edge_threshold: float = 100.0, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = -980, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer for CTP401 linearity module (4-ROI version).

This module measures HU values for 4 material inserts (LDPE, Air, Teflon, Acrylic), calculates low contrast visibility, verifies spatial scaling, and can automatically detect phantom rotation.

Supports both single-image mode and DICOM-series mode with 3-slice averaging.

Key Features: - 4 Material ROI analysis (LDPE at 0°, Air at 90° (south/bottom), Teflon at 180°, Acrylic at 270° (north/top)) - Automatic rotation detection using air ROI position - Low Contrast Visibility (LCV) calculation - Spatial scaling verification (X and Y axes)

image

2D CT image of the module.

Type:

np.ndarray

center

(x, y) coordinates of phantom center in pixels.

Type:

tuple

pixel_spacing

Pixel spacing in mm.

Type:

float

results

Analysis results.

Type:

dict

ROI_CONFIG = {'Acrylic': 270, 'Air': 90, 'LDPE': 0, 'Teflon': 180}
analyze(t_offset: float = 0.0, verbose: bool = False) Dict[source]

Perform ROI analysis on the stored image.

Parameters:
  • t_offset – Rotational offset for ROIs in degrees

  • verbose – Print progress information

Returns:

  • ‘ROIs’: Dictionary of ROI results (mean, std for each material)

  • ’LCV_percent’: Low contrast visibility percentage

  • ’Scale’: Spatial scaling factors (scaleX_cm, scaleY_cm)

Return type:

Dictionary containing analysis results with

detect_rotation(initial_angle_deg: float = 0.0) float[source]

Detect phantom rotation using material insert positions.

Finds the Air insert (90°, top) and Acrylic insert (270°, bottom) and calculates rotation based on their offset from vertical alignment. Uses iterative refinement with safety threshold to prevent invalid results.

class alexandria.CTP401ModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, roi_radius: float = 3.5, material_distance: float = 58.5, edge_threshold: float = 100.0)[source]

Bases: object

analyze(t_offset: float = 0.0, verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(t_offset: float = 0.0, verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
detect_rotation(initial_angle_deg: float = 0.0) float[source]
get_summary() str[source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 150, **kwargs)[source]
class alexandria.CTP404Analyzer(image: ndarray | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, rotation_offset: float = 0.0, roi_radius: float = 3.5, material_distance: float = 58.5)[source]

Bases: object

Unified CTP404 sensitometry analyzer.

This analyzer computes mean and standard deviation values for the standard CatPhan CTP404 contrast module which contains nine circular ROIs containing different materials. The implementation supports two initialization modes:

  • Single-image mode: caller passes a prepared 2D NumPy image array via the image parameter.

  • DICOM-series mode: caller provides a list of pydicom dataset objects and a slice_index; the analyzer will form a simple 3-slice average to improve SNR before analysis.

MATERIALS = ['Delrin', 'none', 'Acrylic', 'Air', 'Polystyrene', 'LDPE', 'PMP', 'Teflon', 'Air2']
ROI_ANGLES = [0, 30, 60, 90, 120, 180, -120, -60, -90]
analyze(verbose: bool = False) Dict[source]

Perform contrast analysis on all 9 ROIs.

Parameters:

verbose – Print progress information

Returns:

Dictionary containing analysis results

detect_rotation(initial_angle_deg: float = 0.0) float[source]

Detect phantom rotation using insert positions (delegates to shared utility).

Parameters:

initial_angle_deg – Initial rotation guess in degrees (default 0)

Returns:

Rotation angle in degrees (sets and returns self.rotation_offset)

get_results_summary() str[source]

Get formatted summary of analysis results.

Returns:

Multi-line string summary

to_dict() Dict[source]

Export results as dictionary.

Returns:

Results dictionary

class alexandria.CTP404ModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, rotation_offset: float = 0.0, roi_radius: float = 3.5, material_distance: float = 58.5)[source]

Bases: object

analyze(verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() str[source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 150, **kwargs)[source]
class alexandria.CTP515Analyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, angle_offset: float = 0.0, dicom_set: List | None = None, slice_index: int | None = None, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = 400.0, center_threshold_fallback: float = -900.0)[source]

Bases: object

Low-contrast detectability analyzer for CatPhan CTP515 module.

Detects and analyzes six low-contrast circular inserts of varying diameters positioned at fixed angles and distance from center. Computes Contrast-to-Noise Ratio (CNR) and contrast percentage for each ROI relative to a background region.

CNR quantifies detectability: higher values indicate the insert is more easily distinguished from background noise.

Supports both single-image mode and DICOM-series mode with 3-slice averaging.

image

2D CT image of the low-contrast module.

Type:

np.ndarray

center

(x, y) center of phantom in pixels.

Type:

tuple

pixel_spacing

Pixel spacing in mm.

Type:

float

angle_offset

Angular offset for ROI positioning in degrees.

Type:

float

results

Analysis results populated by analyze().

Type:

dict

ROI_ANGLES = [-87.4, -69.1, -52.7, -38.5, -25.1, -12.9]
ROI_DISTANCE_MM = 50
ROI_RADII_MM = [6, 3.5, 3, 2.5, 2, 1.5]
ROI_SETTINGS = {'15': {'angle_idx': 0, 'radius_mm': 6}, '5': {'angle_idx': 5, 'radius_mm': 1.5}, '6': {'angle_idx': 4, 'radius_mm': 2}, '7': {'angle_idx': 3, 'radius_mm': 2.5}, '8': {'angle_idx': 2, 'radius_mm': 3}, '9': {'angle_idx': 1, 'radius_mm': 3.5}}
analyze(verbose: bool = True) Dict[str, Any][source]

Perform low-contrast detectability analysis.

This method: 1. Defines ROI locations based on predefined angles and distances. 2. For each ROI, creates a circular mask and computes mean/std. 3. Computes a common background ROI for noise reference. 4. Calculates CNR for each ROI against the background. 5. Returns a summary of detected ROIs and their metrics.

Parameters:

verbose – Whether to print progress information.

Returns:

Contains ‘n_detected’ (int) and ‘blobs’ (dict of blob stats).

Each blob entry has position, size, means, std, and CNR.

Return type:

Dict

get_plot_data() Dict[str, Any][source]

Get data needed for plotting visualizations.

get_results_summary() Dict[str, str][source]

Get a formatted summary of analysis results.

Returns:

Dictionary with key measurements formatted as strings.

prepare_image()[source]

Prepare image for analysis.

In DICOM mode: Create 3-slice averaged image for improved SNR. In single-image mode: Use the provided image directly.

Returns:

Prepared image array

to_dict() Dict[str, Any][source]

Return JSON-compatible results dictionary.

Returns:

Dictionary with all analysis results.

class alexandria.CTP515ModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, angle_offset: float = 0.0, dicom_set: List | None = None, slice_index: int | None = None)[source]

Bases: object

analyze(verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() Dict[str, str][source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 300, **kwargs)[source]
class alexandria.DetailedUniformityAnalyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, radii_mm: List[float] | None = None, sample_step_mm: float = 1.0, n_samples: int = 360, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = 400.0, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer that samples concentric circular profiles for uniformity checks.

analyze() Dict[str, Any][source]
prepare_image() ndarray[source]

Prepare image for analysis.

class alexandria.HighContrastAnalyzer(image: ndarray | None = None, pixel_spacing: float | None = None, center: Tuple[float, float] | None = None, t_offset_deg: float = 0.0, rotation_offset: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, lp_r_mm: float = 48.0, samples_per_segment: int = 50, center_threshold: float = -980, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer for CatPhan’s CTP528 high-contrast (line pair) module.

analyze(write_log: bool = False, verbose: bool = True) Dict[str, Any][source]
prepare_image()[source]
to_dict() Dict[str, Any][source]
class alexandria.HighContrastModuleReporter(image: Any | None = None, pixel_spacing: float | None = None, center: Tuple[float, float] | None = None, t_offset_deg: float = 0.0, rotation_offset: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, lp_r_mm: float = 48.0, samples_per_segment: int = 50)[source]

Bases: object

analyze(write_log: bool = False, verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() Dict[str, str][source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 300, **kwargs)[source]
class alexandria.UniformityAnalyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, roi_box_size: float = 15.0, roi_offset: float = 50.0, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = 400.0, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer for CT scanner uniformity using the CTP486 module.

This class evaluates uniformity by measuring mean and standard deviation in five fixed ROIs (center, north, south, east, west) relative to the phantom center. Supports both single-image analysis and DICOM series with 3-slice averaging for improved SNR.

REGIONS = ['centre', 'north', 'south', 'east', 'west']
analyze(verbose: bool = True) Dict[str, Any][source]

Perform the uniformity analysis on five ROIs.

analyze_uniformity() Tuple[List, ndarray, List][source]

Analyze uniformity by measuring HU values in 5 regions.

prepare_image()[source]

Prepare image for analysis.

class alexandria.UniformityModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, roi_box_size: float = 15.0, roi_offset: float = 50.0)[source]

Bases: object

analyze(verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() Dict[str, str][source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 300, **kwargs)[source]

Analyzers

Unified Uniformity Analyzer for CatPhan Phantom Analysis

This module combines the uniformity analysis functionality from both catphan404 and XVI-CatPhan projects, providing a comprehensive analyzer for CTP486 uniformity module with both single-image and DICOM-series modes.

class alexandria.analyzers.uniformity.UniformityAnalyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, roi_box_size: float = 15.0, roi_offset: float = 50.0, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = 400.0, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer for CT scanner uniformity using the CTP486 module.

This class evaluates uniformity by measuring mean and standard deviation in five fixed ROIs (center, north, south, east, west) relative to the phantom center. Supports both single-image analysis and DICOM series with 3-slice averaging for improved SNR.

REGIONS = ['centre', 'north', 'south', 'east', 'west']
analyze(verbose: bool = True) Dict[str, Any][source]

Perform the uniformity analysis on five ROIs.

analyze_uniformity() Tuple[List, ndarray, List][source]

Analyze uniformity by measuring HU values in 5 regions.

prepare_image()[source]

Prepare image for analysis.

Detailed Uniformity Analyzer

Samples pixel values along concentric circular profiles and records angle/value pairs for each radius.

class alexandria.analyzers.detailed_uniformity.DetailedUniformityAnalyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, radii_mm: List[float] | None = None, sample_step_mm: float = 1.0, n_samples: int = 360, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = 400.0, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer that samples concentric circular profiles for uniformity checks.

analyze() Dict[str, Any][source]
prepare_image() ndarray[source]

Prepare image for analysis.

Unified High Contrast Analyzer for CatPhan Phantom Analysis

This module combines the high-contrast/resolution analysis functionality from both catphan404 and XVI-CatPhan projects, providing a comprehensive analyzer for CTP528 line pair module with both single-image and DICOM-series modes.

class alexandria.analyzers.high_contrast.HighContrastAnalyzer(image: ndarray | None = None, pixel_spacing: float | None = None, center: Tuple[float, float] | None = None, t_offset_deg: float = 0.0, rotation_offset: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, lp_r_mm: float = 48.0, samples_per_segment: int = 50, center_threshold: float = -980, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer for CatPhan’s CTP528 high-contrast (line pair) module.

analyze(write_log: bool = False, verbose: bool = True) Dict[str, Any][source]
prepare_image()[source]
to_dict() Dict[str, Any][source]

CTP401 Analyzer - Linearity Module (4-ROI)

This module handles the CTP401 linearity analysis with 4 material ROIs: LDPE, Air, Teflon, and Acrylic positioned at 0°, 90°, 180°, and 270°.

Provides comprehensive analysis including: - Material ROI contrast measurements (HU accuracy) - Low Contrast Visibility (LCV) - Spatial scaling/linearity verification - Automatic rotation detection using air ROI positions

class alexandria.analyzers.ctp401.CTP401Analyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, roi_radius: float = 3.5, material_distance: float = 58.5, edge_threshold: float = 100.0, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = -980, center_threshold_fallback: float = -900.0)[source]

Bases: object

Analyzer for CTP401 linearity module (4-ROI version).

This module measures HU values for 4 material inserts (LDPE, Air, Teflon, Acrylic), calculates low contrast visibility, verifies spatial scaling, and can automatically detect phantom rotation.

Supports both single-image mode and DICOM-series mode with 3-slice averaging.

Key Features: - 4 Material ROI analysis (LDPE at 0°, Air at 90° (south/bottom), Teflon at 180°, Acrylic at 270° (north/top)) - Automatic rotation detection using air ROI position - Low Contrast Visibility (LCV) calculation - Spatial scaling verification (X and Y axes)

image

2D CT image of the module.

Type:

np.ndarray

center

(x, y) coordinates of phantom center in pixels.

Type:

tuple

pixel_spacing

Pixel spacing in mm.

Type:

float

results

Analysis results.

Type:

dict

ROI_CONFIG = {'Acrylic': 270, 'Air': 90, 'LDPE': 0, 'Teflon': 180}
analyze(t_offset: float = 0.0, verbose: bool = False) Dict[source]

Perform ROI analysis on the stored image.

Parameters:
  • t_offset – Rotational offset for ROIs in degrees

  • verbose – Print progress information

Returns:

  • ‘ROIs’: Dictionary of ROI results (mean, std for each material)

  • ’LCV_percent’: Low contrast visibility percentage

  • ’Scale’: Spatial scaling factors (scaleX_cm, scaleY_cm)

Return type:

Dictionary containing analysis results with

detect_rotation(initial_angle_deg: float = 0.0) float[source]

Detect phantom rotation using material insert positions.

Finds the Air insert (90°, top) and Acrylic insert (270°, bottom) and calculates rotation based on their offset from vertical alignment. Uses iterative refinement with safety threshold to prevent invalid results.

CTP404 Analyzer - Contrast and Sensitometry Module

Unified analyzer for CTP404 sensitometry analysis, combining functionality from catphan404 and XVI-CatPhan implementations.

class alexandria.analyzers.ctp404.CTP404Analyzer(image: ndarray | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, rotation_offset: float = 0.0, roi_radius: float = 3.5, material_distance: float = 58.5)[source]

Bases: object

Unified CTP404 sensitometry analyzer.

This analyzer computes mean and standard deviation values for the standard CatPhan CTP404 contrast module which contains nine circular ROIs containing different materials. The implementation supports two initialization modes:

  • Single-image mode: caller passes a prepared 2D NumPy image array via the image parameter.

  • DICOM-series mode: caller provides a list of pydicom dataset objects and a slice_index; the analyzer will form a simple 3-slice average to improve SNR before analysis.

MATERIALS = ['Delrin', 'none', 'Acrylic', 'Air', 'Polystyrene', 'LDPE', 'PMP', 'Teflon', 'Air2']
ROI_ANGLES = [0, 30, 60, 90, 120, 180, -120, -60, -90]
analyze(verbose: bool = False) Dict[source]

Perform contrast analysis on all 9 ROIs.

Parameters:

verbose – Print progress information

Returns:

Dictionary containing analysis results

detect_rotation(initial_angle_deg: float = 0.0) float[source]

Detect phantom rotation using insert positions (delegates to shared utility).

Parameters:

initial_angle_deg – Initial rotation guess in degrees (default 0)

Returns:

Rotation angle in degrees (sets and returns self.rotation_offset)

get_results_summary() str[source]

Get formatted summary of analysis results.

Returns:

Multi-line string summary

to_dict() Dict[source]

Export results as dictionary.

Returns:

Results dictionary

Unified CTP515 Low-Contrast Analyzer for CatPhan Phantom Analysis

This module provides low-contrast detectability analysis for the CatPhan CTP515 module. Analyzes circular inserts of varying diameters (15, 9, 8, 7, 6, 5 mm) to measure Contrast-to-Noise Ratio (CNR) and contrast detectability.

class alexandria.analyzers.ctp515.CTP515Analyzer(image: ndarray | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, angle_offset: float = 0.0, dicom_set: List | None = None, slice_index: int | None = None, center_finder: Callable[[...], Tuple] | None = None, center_finder_kwargs: Dict[str, Any] | None = None, center_threshold: float = 400.0, center_threshold_fallback: float = -900.0)[source]

Bases: object

Low-contrast detectability analyzer for CatPhan CTP515 module.

Detects and analyzes six low-contrast circular inserts of varying diameters positioned at fixed angles and distance from center. Computes Contrast-to-Noise Ratio (CNR) and contrast percentage for each ROI relative to a background region.

CNR quantifies detectability: higher values indicate the insert is more easily distinguished from background noise.

Supports both single-image mode and DICOM-series mode with 3-slice averaging.

image

2D CT image of the low-contrast module.

Type:

np.ndarray

center

(x, y) center of phantom in pixels.

Type:

tuple

pixel_spacing

Pixel spacing in mm.

Type:

float

angle_offset

Angular offset for ROI positioning in degrees.

Type:

float

results

Analysis results populated by analyze().

Type:

dict

ROI_ANGLES = [-87.4, -69.1, -52.7, -38.5, -25.1, -12.9]
ROI_DISTANCE_MM = 50
ROI_RADII_MM = [6, 3.5, 3, 2.5, 2, 1.5]
ROI_SETTINGS = {'15': {'angle_idx': 0, 'radius_mm': 6}, '5': {'angle_idx': 5, 'radius_mm': 1.5}, '6': {'angle_idx': 4, 'radius_mm': 2}, '7': {'angle_idx': 3, 'radius_mm': 2.5}, '8': {'angle_idx': 2, 'radius_mm': 3}, '9': {'angle_idx': 1, 'radius_mm': 3.5}}
analyze(verbose: bool = True) Dict[str, Any][source]

Perform low-contrast detectability analysis.

This method: 1. Defines ROI locations based on predefined angles and distances. 2. For each ROI, creates a circular mask and computes mean/std. 3. Computes a common background ROI for noise reference. 4. Calculates CNR for each ROI against the background. 5. Returns a summary of detected ROIs and their metrics.

Parameters:

verbose – Whether to print progress information.

Returns:

Contains ‘n_detected’ (int) and ‘blobs’ (dict of blob stats).

Each blob entry has position, size, means, std, and CNR.

Return type:

Dict

get_plot_data() Dict[str, Any][source]

Get data needed for plotting visualizations.

get_results_summary() Dict[str, str][source]

Get a formatted summary of analysis results.

Returns:

Dictionary with key measurements formatted as strings.

prepare_image()[source]

Prepare image for analysis.

In DICOM mode: Create 3-slice averaged image for improved SNR. In single-image mode: Use the provided image directly.

Returns:

Prepared image array

to_dict() Dict[str, Any][source]

Return JSON-compatible results dictionary.

Returns:

Dictionary with all analysis results.

Wrappers

Uniformity Module Wrapper

Combines UniformityAnalyzer with UniformityPlotter for convenient analysis and visualization in a single class.

class alexandria.wrappers.uniformity_wrapper.UniformityModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, roi_box_size: float = 15.0, roi_offset: float = 50.0)[source]

Bases: object

analyze(verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() Dict[str, str][source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 300, **kwargs)[source]

High Contrast Module Wrapper

Combines HighContrastAnalyzer with HighContrastPlotter for convenient MTF/resolution analysis and visualization.

class alexandria.wrappers.high_contrast_wrapper.HighContrastModuleReporter(image: Any | None = None, pixel_spacing: float | None = None, center: Tuple[float, float] | None = None, t_offset_deg: float = 0.0, rotation_offset: float | None = None, dicom_set: List | None = None, slice_index: int | None = None, lp_r_mm: float = 48.0, samples_per_segment: int = 50)[source]

Bases: object

analyze(write_log: bool = False, verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() Dict[str, str][source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 300, **kwargs)[source]

CTP401 Module Wrapper

Combines CTP401Analyzer with CTP401Plotter for convenient 4-ROI linearity analysis and visualization in a single class.

class alexandria.wrappers.ctp401_wrapper.CTP401ModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, roi_radius: float = 3.5, material_distance: float = 58.5, edge_threshold: float = 100.0)[source]

Bases: object

analyze(t_offset: float = 0.0, verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(t_offset: float = 0.0, verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
detect_rotation(initial_angle_deg: float = 0.0) float[source]
get_summary() str[source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 150, **kwargs)[source]

CTP404 Module Wrapper

Combines CTP404Analyzer with CTP404Plotter for convenient 9-ROI sensitometry analysis and visualization in a single class.

class alexandria.wrappers.ctp404_wrapper.CTP404ModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, spacing: float | None = None, dicom_set: List[Any] | None = None, slice_index: int | None = None, rotation_offset: float = 0.0, roi_radius: float = 3.5, material_distance: float = 58.5)[source]

Bases: object

analyze(verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() str[source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 150, **kwargs)[source]

CTP515 Module Wrapper

Combines CTP515Analyzer with CTP515Plotter for convenient low-contrast analysis and visualization.

class alexandria.wrappers.ctp515_wrapper.CTP515ModuleReporter(image: Any | None = None, center: Tuple[float, float] | None = None, pixel_spacing: float | None = None, angle_offset: float = 0.0, dicom_set: List | None = None, slice_index: int | None = None)[source]

Bases: object

analyze(verbose: bool = True) Dict[str, Any][source]
analyze_and_plot(verbose: bool = True, show: bool = False, **kwargs) Tuple[Dict[str, Any], Figure][source]
close_plot()[source]
get_summary() Dict[str, str][source]
plot(show: bool = False, **kwargs) Figure[source]
save_plot(filepath: str, dpi: int = 300, **kwargs)[source]

Plotters

Uniformity Plotter

Creates comprehensive visualization plots for uniformity analysis results.

class alexandria.plotters.uniformity_plotter.UniformityPlotter(analyzer)[source]

Bases: object

Plotter for UniformityAnalyzer results.

plot()[source]

Detailed Uniformity Plotter

Plots concentric profile values (angle vs HU) and overlayed histograms.

class alexandria.plotters.detailed_uniformity_plotter.DetailedUniformityPlotter(analyzer)[source]

Bases: object

Plotter for DetailedUniformityAnalyzer results.

plot(bins: int = 25, figsize: tuple = (12, 18)) Figure[source]

High Contrast Plotter

Creates visualization plots for MTF/resolution analysis results.

class alexandria.plotters.high_contrast_plotter.HighContrastPlotter(analyzer)[source]

Bases: object

Creates visualization plots for HighContrastAnalyzer results.

plot(figsize: tuple | None = None, vmin: float | None = None, vmax: float | None = None, **kwargs) Figure[source]

CTP401 Plotter

Creates comprehensive visualization plots for 4-ROI linearity analysis results. Displays main image with ROI circles, per-ROI histograms, and 2D heatmaps.

class alexandria.plotters.ctp401_plotter.CTP401Plotter(analyzer, vmin: float | None = None, vmax: float | None = None)[source]

Bases: object

Plotter for AnalyzerCTP401 results.

plot()[source]

CTP404 Plotter

Creates visualization plots for 9-ROI contrast/sensitometry analysis results.

class alexandria.plotters.ctp404_plotter.CTP404Plotter(analyzer)[source]

Bases: object

Creates visualization plots for CTP404Analyzer results.

plot(figsize: tuple | None = None, vmin: float | None = None, vmax: float | None = None, **kwargs) Figure[source]

CTP515 Plotter

Creates comprehensive visualization plots for low-contrast detectability analysis results. Displays image with color-coded ROIs, dual-axis CNR/Contrast plots, and statistics table.

class alexandria.plotters.ctp515_plotter.CTP515Plotter(analyzer)[source]

Bases: object

Plotter for AnalyzerCTP515 (low-contrast detectability) results.

Creates a 2x2 layout displaying:
  • Image with color-coded ROI circles and background ROI

  • Dual-axis plot of CNR and Contrast vs. ROI diameter

  • Statistics table showing mean, std, CNR, and contrast for each ROI

ROIs are color-coded by diameter size with adaptive contrast windowing to enhance visibility of low-contrast features.

Parameters:

analyzer (AnalyzerCTP515) – Completed analyzer instance with results.

plot()[source]

Generate visualization of low-contrast ROI analysis.

Layout:
  • Top left: Image with ROI overlays

  • Top right: CNR and Contrast vs. ROI Diameter (dual y-axes)

  • Bottom: Statistics table

Utilities

Image Processing utilities used across Alexandria analyzers.

This module collects lightweight, well-documented image processing helpers commonly needed by CatPhan analyzers and plotters.

class alexandria.utils.image_processing.ImageProcessor[source]

Bases: object

static apply_gaussian_filter(image: ndarray, sigma: float = 1.0) ndarray[source]
static estimate_noise(image: ndarray, roi_center: Tuple[float, float] | None = None, roi_size: int = 50) float[source]
static extract_profile(image: ndarray, start: Tuple[float, float], end: Tuple[float, float], n_points: int = 100) ndarray[source]
static find_edges(image: ndarray, method: str = 'sobel') ndarray[source]
static threshold_image(image: ndarray, threshold: float, mode: str = 'above') ndarray[source]

Geometry Utilities for CatPhan Phantom Analysis

Provides functions for finding phantom centers, rotations, and geometric measurements.

class alexandria.utils.geometry.CatPhanGeometry[source]

Bases: object

static calculate_slice_thickness(image: ndarray, pixel_spacing: float, center: Tuple[float, float]) float[source]
static find_center(image: ndarray, threshold: float = 400) Tuple[List[float], List[ndarray]][source]
static select_optimal_ctp528_slices(dicom_set: List, target_index: int, search_range: int = 2) Tuple[ndarray, ndarray, float][source]
alexandria.utils.geometry.circular_roi_mask(shape: Tuple[int, int], center: Tuple[float, float], radius: float) ndarray[source]
alexandria.utils.geometry.compute_phantom_boundary(image: ndarray, center: Tuple[float, float], pixel_spacing: float | None = None, threshold: float = -900, fallback_threshold: float = -900) Tuple[Tuple[float, float], Tuple[ndarray, ndarray]][source]
alexandria.utils.geometry.draw_boundary(center: Tuple[float, float], diameter_x_px: float | None, diameter_y_px: float | None, n_points: int = 100) Tuple[ndarray, ndarray][source]
alexandria.utils.geometry.find_center_edge_detection(img: ndarray, threshold: float = -900, fallback_threshold: float = -900, return_diameters: bool = False)[source]
alexandria.utils.geometry.find_rotation(image: ndarray, center: Tuple[float, float] | None, pixel_spacing: float | Tuple[float, float] | List[float], insert_radius_mm: float = 58.5, edge_threshold: float = 100.0, center_threshold: float = 30, iterations: int = 5, profile_length: int = 25, granularity: int = 3, interp_kwargs: dict | None = None, initial_angle_deg: float = 0.0)[source]