Graphical Analysis#

This module provides functions and a key class, GraphicalAnalysis, for performing graphical analysis on Time Activity Curve (TAC) data. It heavily utilizes Numpy and supports various analysis methods like Patlak, Logan, and alternative Logan analysis.

The GraphicalAnalysis class encapsulates the main functionality of the module. It provides an organized way to perform graphical analysis where it initializes with paths to input data and output details, runs an analysis using a specific method, calculates the best fit parameters, computes properties related to the fitting process, and stores the analysis results. All these properties and results are stored within an instance’s ‘analysis_props’ dictionary, providing an organized storage of result of an analysis task.

Todo

  • Check if it makes more sense to lift out the more mathy methods out into a separate module.

  • Add references for the TCMs and Patlak. Could maybe rely on Turku PET Center.

  • Handle cases when tac_vals = 0.0. Might be able to use t_thresh so that we are past the 0-values.

  • Add more detailed documentation to patlak analysis.

Classes#

GraphicalAnalysis

GraphicalAnalysis to handle Graphical Analysis for time activity curve (TAC) data.

MultiTACGraphicalAnalysis

A class that performs graphical analysis on multiple tissue TACs (Time Activity Curves).

Functions#

_line_fitting_make_rhs_matrix_from_xdata(→ numpy.ndarray)

Generates the RHS matrix for linear least squares fitting

fit_line_to_data_using_lls(→ numpy.ndarray)

Find the linear least squares solution given the x and y variables.

fit_line_to_data_using_lls_with_rsquared(...)

Fits a line to the data using least squares and explicitly computes the r-squared value.

linear_least_squares_fit_with_stats(→ tuple[float, ...)

Fits a line to the data using least squares and explicitly computes:

cumulative_trapezoidal_integral(→ numpy.ndarray)

Calculates the cumulative integral of ydata over xdata using the trapezoidal rule.

calculate_patlak_x(→ numpy.ndarray)

Calculates the x-variable in Patlak analysis

get_index_from_threshold(→ int)

Get the index after which all times are greater than the threshold.

patlak_analysis(→ numpy.ndarray)

Performs Patlak analysis given the input TAC, region TAC, times and threshold.

patlak_analysis_with_rsquared(→ Tuple[float, float, float])

Performs Patlak analysis given the input TAC, region TAC, times and threshold.

logan_analysis(→ numpy.ndarray)

Performs Logan analysis on given input TAC, regional TAC, times and threshold, considering

logan_analysis_with_rsquared(→ tuple[float, float, float])

Performs Logan analysis on given input TAC, regional TAC, times and threshold.

logan_ref_region_analysis(→ numpy.ndarray)

Performs Logan with reference region input function on given input TAC, regional TAC, times,

logan_ref_region_analysis_with_rsquared(→ tuple[float, ...)

Performs Logan with reference region input function on given input TAC, regional TAC, times,

alternative_logan_analysis(→ numpy.ndarray)

Performs Alternative Logan analysis on given input TAC, regional TAC, times and threshold,

alternative_logan_analysis_with_rsquared(...)

Performs alternative logan analysis on given input TAC, regional TAC, times and threshold.

get_graphical_analysis_method(→ collections.abc.Callable)

Function for obtaining the appropriate graphical analysis method.

get_graphical_analysis_method_with_rsquared(...)

Function for obtaining the appropriate graphical analysis method which also calculates the

km_multifit_analysis_to_tsv(analysis_props, ...)

Saves the analysis results to a TSV file as a table with fit parameters for each ROI.

km_multifit_analysis_to_jsons(analysis_props, ...)

Saves the analysis results to a JSON file for each segment/TAC.