visualizer
tit.analyzer.visualizer ¶
Stateless visualization and output helpers for the analyzer pipeline.
Module-level functions that write output artifacts (mesh overlays,
NIfTI overlays, histograms, CSV, metadata JSON) without any shared mutable
state. These are package-internal; the public API is
:class:~tit.analyzer.Analyzer.
See Also¶
tit.analyzer.analyzer : Analyzer class that calls these helpers.
save_mesh_roi_overlay ¶
save_mesh_roi_overlay(surface_mesh_path: Path, field_values: ndarray, roi_mask: ndarray, field_name: str, output_dir: Path, normal_mesh_path: Path | None = None) -> Path
Write .msh + .msh.opt overlay with ROI field highlighted.
Loads a fresh surface mesh copy, zeros everything outside the ROI, and writes both the mesh and a Gmsh options file for colour-map / range / transparency. When normal_mesh_path is given the TI_normal field is added as a second (initially hidden) view.
Parameters¶
surface_mesh_path : pathlib.Path Path to the cortical surface mesh file. field_values : numpy.ndarray Per-node field values for the entire surface. roi_mask : numpy.ndarray Boolean mask selecting ROI nodes. field_name : str Name of the primary field (used in the mesh view label). output_dir : pathlib.Path Directory where the overlay files are written. normal_mesh_path : pathlib.Path or None, optional Path to the TI_normal mesh file. When provided, the normal field is added as an additional (hidden) view.
Returns¶
pathlib.Path
Path to the written roi_overlay.msh file.
Source code in tit/analyzer/visualizer.py
save_nifti_roi_overlay ¶
save_nifti_roi_overlay(field_data: ndarray, roi_mask: ndarray, output_dir: Path, affine: ndarray) -> Path
Write NIfTI overlay with field values only inside ROI.
Parameters¶
field_data : numpy.ndarray 3-D field intensity array. roi_mask : numpy.ndarray Boolean mask selecting ROI voxels. output_dir : pathlib.Path Directory where the overlay file is written. affine : numpy.ndarray 4x4 affine matrix for the NIfTI image.
Returns¶
pathlib.Path
Path to the written roi_overlay.nii.gz file.
Source code in tit/analyzer/visualizer.py
save_histogram ¶
save_histogram(whole_head_values: ndarray, roi_values: ndarray, output_dir: Path, whole_head_weights: ndarray | None = None, roi_weights: ndarray | None = None, roi_mean: float | None = None) -> Path | None
Generate focality histogram PDF.
Delegates to :func:tit.plotting.focality.plot_whole_head_roi_histogram.
Returns the PDF path or None if the plotter declines (empty data).
Parameters¶
whole_head_values : numpy.ndarray Field values for the whole GM surface/volume. roi_values : numpy.ndarray Field values inside the ROI. output_dir : pathlib.Path Directory where the histogram PDF is written. whole_head_weights : numpy.ndarray or None, optional Per-element areas/volumes for the whole-head distribution. roi_weights : numpy.ndarray or None, optional Per-element areas/volumes for the ROI distribution. roi_mean : float or None, optional ROI mean value, drawn as a vertical line on the histogram.
Returns¶
pathlib.Path or None
Path to the histogram PDF, or None if data was empty.
Source code in tit/analyzer/visualizer.py
save_results_csv ¶
Write analysis result dict to a two-column CSV (Metric, Value).
Entries whose value is None are silently skipped.
Parameters¶
result : dict of str to Any
Flat dictionary of metric names to scalar values.
output_dir : pathlib.Path
Directory where results.csv is written.
Returns¶
pathlib.Path
Path to the written results.csv file.
Source code in tit/analyzer/visualizer.py
save_analysis_metadata ¶
Write analysis configuration to analysis.json.
Parameters¶
output_dir : pathlib.Path
Directory where analysis.json is written.
metadata : dict of str to Any
Analysis configuration dictionary to persist.
Returns¶
pathlib.Path
Path to the written analysis.json file.