visualizer
tit.analyzer.visualizer ¶
Stateless visualization and output helpers for the analyzer pipeline.
Module-level functions that write output artifacts (mesh overlays,
NIfTI overlays, the field-distribution histogram, CSV, metadata JSON)
without any shared mutable state.
The scene that shows an overlay is :mod:tit.analyzer.scene. 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, drops its own data (the whole-surface
field is the simulation's file, not this analysis's), adds <field>_ROI
-- the field at the ROI's nodes and exactly 0 everywhere else -- and
writes both the mesh and a Gmsh options file for colour-map / range.
When normal_mesh_path is given TI_normal_ROI 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, region_name: str | None = None, unit_label: str = 'Area (mm²)', n_bins: int = 100, dpi: int = 150) -> Path | None
Write histogram.png: the whole-head field distribution with the ROI's contribution.
One weighted histogram of the whole grey matter (area- or volume-weighted), each bar coloured by the fraction of it that lies inside the ROI (rainbow, blue -> red, with a colour bar), the ROI mean and the focality cutoffs (50/75/90/95 % of the GM 99.9th percentile) as vertical lines, and a stats box. One PNG at dpi.
Parameters¶
whole_head_values : numpy.ndarray Field values over the whole grey matter surface / volume. roi_values : numpy.ndarray Field values inside the ROI. output_dir : pathlib.Path Directory the PNG is written to. whole_head_weights, roi_weights : numpy.ndarray or None, optional Per-node areas (mm^2) or per-voxel volumes (mm^3). Both or neither; without them the histogram counts elements. roi_mean : float or None, optional Drawn as a vertical line. region_name : str or None, optional Named in the title. unit_label : str, optional The y-axis label when weights are given. n_bins : int, optional Bins over the whole-GM range (default 100). dpi : int, optional Output resolution (default 150).
Returns¶
pathlib.Path or None
<output_dir>/histogram.png, or None when either input is empty.
Source code in tit/analyzer/visualizer.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
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.