nema_quant.reporting
Report generation and data export tools for analysis results.
Provides utilities for generating and formatting textual reports, intended for use in CLI workflows.
Author: Edwing Ulin-Briseno Date: 2025-07-16
- nema_quant.reporting.save_results_to_txt(results: List[Dict[str, Any]], output_path: Path, cfg: yacs.config.CfgNode, input_image_path: Path, voxel_spacing: Tuple[float, float, float]) None[source]
Saves NEMA analysis results to a formatted text file.
Writes analysis results for each sphere, along with configuration and metadata, to the specified output path.
- Parameters:
results (List[Dict[str, Any]]) – List of analysis results for each sphere.
output_path (Path) – Destination path for saving the results file.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
input_image_path (Path) – Path to the input image file.
voxel_spacing (Tuple[float, float, float]) – Voxel spacing used during analysis.
- Returns:
This function does not return a value; results are saved to disk.
- Return type:
None
- nema_quant.reporting.save_results_to_txt_nu4(crc_results: Dict[str, Dict[str, Any]], spillover_results: Dict[str, Any], uniformity_results: Dict[str, Any], output_path: Path, cfg: yacs.config.CfgNode, input_image_path: Path, voxel_spacing: Tuple[float, float, float]) None[source]
Saves NEMA analysis results to a formatted text file.
Writes analysis results for each sphere, along with configuration and metadata, to the specified output path.
- Parameters:
crc_results (Dict[str, Dict[str, Any]]) – Dictionary of CRC results for each rod.
spillover_results (Dict[str, Any]) – Dictionary of spillover results for each rod.
uniformity_results (Dict[str, Any]) – Dictionary of uniformity results for the phantom.
output_path (Path) – Destination path for saving the results file.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
input_image_path (Path) – Path to the input image file.
voxel_spacing (Tuple[float, float, float]) – Voxel spacing used during analysis.
- Returns:
This function does not return a value; results are saved to disk.
- Return type:
None
- nema_quant.reporting.generate_reportlab_report(results: List[Dict[str, Any]], output_path: Path, cfg: yacs.config.CfgNode, input_image_path: Path, voxel_spacing: Tuple[float, float, float], lung_results: Dict[str, Any], plot_path: Path | None = None, rois_loc_path: Path | None = None, boxplot_path: Path | None = None) None[source]
Generates a PDF report for NEMA quality analysis results using ReportLab.
Creates a formatted PDF summarizing sphere and lung analysis results, configuration, and relevant plots.
- Parameters:
results (List[Dict[str, Any]]) – List of analysis results for each sphere.
output_path (Path) – Destination path for saving the PDF report.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
input_image_path (Path) – Path to the input image file.
voxel_spacing (Tuple[float, float, float]) – Voxel spacing used during analysis.
lung_results (Dict[str, Any]) – Dictionary of results from the lung analysis.
plot_path (Path) – Path to the summary plot image file.
rois_loc_path (Path) – Path to the ROIs plot image file.
boxplot_path (Path) – Path to the boxplot image file.
- Returns:
This function does not return a value; it writes the PDF report to disk.
- Return type:
None
- nema_quant.reporting.generate_reportlab_report_nu4(crc_results: Dict[str, Dict[str, Any]], spillover_results: Dict[str, Any], uniformity_results: Dict[str, Any], output_path: Path, cfg: yacs.config.CfgNode, input_image_path: Path, voxel_spacing: Tuple[float, float, float], plot_path: Path | None = None, rois_loc_path: Path | None = None, spillover_ratio_path: Path | None = None) None[source]
Generates a PDF report for NEMA NU 4-2008 quality analysis results using ReportLab.
Creates a formatted PDF summarizing CRC, spillover, and uniformity results, configuration, and relevant plots.
- Parameters:
crc_results (Dict[str, Dict[str, Any]]) – Dictionary of CRC results for each rod.
spillover_results (Dict[str, Any]) – Dictionary of spillover results for each rod.
uniformity_results (Dict[str, Any]) – Dictionary of uniformity results for the phantom.
output_path (Path) – Destination path for saving the PDF report.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
input_image_path (Path) – Path to the input image file.
voxel_spacing (Tuple[float, float, float]) – Voxel spacing used during analysis.
plot_path (Path) – Path to the summary plot image file.
rois_loc_path (Path) – Path to the ROIs plot image file.
spillover_ratio_path (Path) – Path to the spillover ratio image file.
- Returns:
This function does not return a value; it writes the PDF report to disk.
- Return type:
None
- nema_quant.reporting.generate_plots(results: List[Dict[str, Any]], output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates the plot for the results of the NEMA analysis.
Creates and saves a figure summarizing sphere analysis results using the given configuration.
- Parameters:
results (List[Dict[str, Any]]) – List of analysis results for each sphere.
output_path (Path) – Destination path for saving the plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_crc_plots_nu4(crc_results: Dict[str, Dict[str, Any]], output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates CRC plots for NEMA NU 4-2008 results.
Creates and saves a figure summarizing CRC and %STD by sphere diameter.
- Parameters:
crc_results (Dict[str, Dict[str, Any]]) – CRC results keyed by sphere name.
output_dir (Path) – Directory to save outputs.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_spillover_barplot_nu4(spillover_ratio: Dict[str, Dict[str, float]], output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates a bar plot for NU 4-2008 spill-over ratios with %STD error bars.
- Parameters:
spillover_ratio (Dict[str, Dict[str, float]]) – Dictionary with keys “air” and “water” containing “SOR” and “%STD”.
output_dir (Path) – Directory to save outputs.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_boxplot_with_mean_std(data_dict: Dict[int, float], output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates a high-contrast boxplot from a dataset dictionary with integer keys and float values.
Displays means as red dots and standard deviations as error bars, and saves the plot to the specified directory.
- Parameters:
data_dict (Dict[int, float]) – Dictionary containing the dataset (e.g., for different spheres or samples).
output_dir (Path) – Directory path for saving the generated plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_rois_plots(image: numpy.typing.NDArray.typing.Any, output_dir: Path, cfg: yacs.config.CfgNode, protocol: str) None[source]
Generates a plot of the ROIs for the input image.
Creates and saves a visualization highlighting the regions of interest (ROIs) defined for the analysis.
- Parameters:
image (numpy.ndarray) – The image loaded for analysis.
output_dir (Path) – Directory path for saving the resulting plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_transverse_sphere_plots(image: numpy.typing.NDArray.typing.Any, output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates a plot of the transverse view of all the spheres.
- Parameters:
image (numpy.ndarray) – The image loaded for analysis.
output_dir (Path) – Directory path for saving the resulting plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_coronal_sphere_plots(image: numpy.typing.NDArray.typing.Any, output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates a plot of the coronal view of all the spheres.
- Parameters:
image (numpy.ndarray) – The image loaded for analysis.
output_dir (Path) – Directory path for saving the resulting plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_torso_plot(image: numpy.typing.NDArray.typing.Any, output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates a plot of the input image.
- Parameters:
image (numpy.ndarray) – The image loaded for analysis.
output_dir (Path) – Directory path for saving the resulting plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None
- nema_quant.reporting.generate_iq_plot(image: numpy.typing.NDArray.typing.Any, output_dir: Path, cfg: yacs.config.CfgNode) None[source]
Generates plot of IQ Rois for NEMA NU 4 2008
- Parameters:
image (npt.NDArray[Any]) – PET image of phatom to show
output_dir (Path) – Directory path for saving the resulting plot.
cfg (yacs.config.CfgNode) – Configuration object used for the analysis.
- Returns:
This function does not return a value; the plot is saved to disk.
- Return type:
None