generators
tit.reporting.generators ¶
Report generators for TI-Toolbox modules.
This module provides specialized report generators for different TI-Toolbox pipelines.
BaseReportGenerator ¶
BaseReportGenerator(project_dir: str | Path, subject_id: str | None = None, session_id: str | None = None, report_type: str = 'general')
Bases: ABC
Abstract base class for all TI-Toolbox report generators.
Provides common functionality including: - BIDS-compliant output path management - Software version collection - Error and warning tracking - Dataset description generation
Initialize the base report generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
str | Path
|
Path to the project directory |
required |
subject_id
|
str | None
|
BIDS subject ID (without 'sub-' prefix) |
None
|
session_id
|
str | None
|
Optional session/run identifier |
None
|
report_type
|
str
|
Type of report being generated |
'general'
|
Source code in tit/reporting/generators/base_generator.py
add_error ¶
Add an error to the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Error message |
required |
context
|
str | None
|
Context (e.g., subject ID, montage name) |
None
|
step
|
str | None
|
Processing step where error occurred |
None
|
Source code in tit/reporting/generators/base_generator.py
add_warning ¶
Add a warning to the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Warning message |
required |
context
|
str | None
|
Context (e.g., subject ID, montage name) |
None
|
step
|
str | None
|
Processing step where warning occurred |
None
|
Source code in tit/reporting/generators/base_generator.py
get_output_dir ¶
get_output_dir() -> Path
Get the BIDS-compliant output directory for reports.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the reports directory |
Source code in tit/reporting/generators/base_generator.py
get_output_path ¶
Get the full output path for the report file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str | None
|
Optional timestamp string (uses current time if not provided) |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Full path to the report file |
Source code in tit/reporting/generators/base_generator.py
generate ¶
Generate the HTML report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str | Path | None
|
Optional custom output path |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated report file |
Source code in tit/reporting/generators/base_generator.py
SimulationReportGenerator ¶
SimulationReportGenerator(project_dir: str | Path, simulation_session_id: str | None = None, subject_id: str | None = None)
Bases: BaseReportGenerator
Report generator for TI/mTI simulation pipelines.
Creates comprehensive HTML reports including: - Simulation parameters and configuration - Electrode specifications - Conductivity values - Montage configurations - Simulation results with visualizations - Methods boilerplate and references
Initialize the simulation report generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
str | Path
|
Path to the project directory |
required |
simulation_session_id
|
str | None
|
Unique session identifier |
None
|
subject_id
|
str | None
|
BIDS subject ID (for single-subject reports) |
None
|
Source code in tit/reporting/generators/simulation.py
add_simulation_parameters ¶
add_simulation_parameters(conductivity_type: str = 'scalar', simulation_mode: str = 'TI', eeg_net: str | None = None, intensity_ch1: float = 1.0, intensity_ch2: float = 1.0, quiet_mode: bool = False, conductivities: dict[str, Any] | None = None, **kwargs) -> None
Add simulation configuration parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conductivity_type
|
str
|
Type of conductivity (scalar, anisotropic) |
'scalar'
|
simulation_mode
|
str
|
Simulation mode (TI, mTI) |
'TI'
|
eeg_net
|
str | None
|
EEG electrode net used |
None
|
intensity_ch1
|
float
|
Channel 1 intensity (mA) |
1.0
|
intensity_ch2
|
float
|
Channel 2 intensity (mA) |
1.0
|
quiet_mode
|
bool
|
Whether running in quiet mode |
False
|
conductivities
|
dict[str, Any] | None
|
Optional custom conductivity values |
None
|
**kwargs
|
Additional parameters |
{}
|
Source code in tit/reporting/generators/simulation.py
add_electrode_parameters ¶
add_electrode_parameters(shape: str = 'circular', dimensions: str | list[float] | None = None, gel_thickness: float | None = None, **kwargs) -> None
Add electrode specifications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
str
|
Electrode shape (circular, rectangular) |
'circular'
|
dimensions
|
str | list[float] | None
|
Electrode dimensions (string or list) |
None
|
gel_thickness
|
float | None
|
Saline gel layer thickness in mm |
None
|
**kwargs
|
Additional parameters |
{}
|
Source code in tit/reporting/generators/simulation.py
add_conductivities ¶
add_conductivities(conductivities: dict[str, dict[str, Any]], conductivity_type: str = 'scalar') -> None
Add tissue conductivity values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conductivities
|
dict[str, dict[str, Any]]
|
Dict mapping tissue names to conductivity info |
required |
conductivity_type
|
str
|
Type of conductivity values |
'scalar'
|
Source code in tit/reporting/generators/simulation.py
add_subject ¶
Add a subject to the simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str
|
BIDS subject ID |
required |
m2m_path
|
str | None
|
Path to the m2m folder |
None
|
status
|
str
|
Subject processing status |
'pending'
|
Source code in tit/reporting/generators/simulation.py
add_montage ¶
Add a montage configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
montage_name
|
str
|
Name of the montage |
required |
electrode_pairs
|
list[Any]
|
List of electrode pair specifications |
required |
montage_type
|
str
|
Type of montage (TI, mTI, unipolar, multipolar) |
'TI'
|
Source code in tit/reporting/generators/simulation.py
add_simulation_result ¶
add_simulation_result(subject_id: str, montage_name: str, output_files: list[str] | None = None, duration: float | None = None, status: str = 'completed', metrics: dict[str, Any] | None = None) -> None
Add simulation results for a subject/montage combination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str
|
Subject ID |
required |
montage_name
|
str
|
Montage name |
required |
output_files
|
list[str] | None
|
List of output file paths |
None
|
duration
|
float | None
|
Simulation duration in seconds |
None
|
status
|
str
|
Simulation status |
'completed'
|
metrics
|
dict[str, Any] | None
|
Optional computed metrics |
None
|
Source code in tit/reporting/generators/simulation.py
add_visualization ¶
add_visualization(subject_id: str, montage_name: str, image_type: str, base64_data: str, title: str | None = None, caption: str | None = None) -> None
Add a visualization image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str
|
Subject ID |
required |
montage_name
|
str
|
Montage name |
required |
image_type
|
str
|
Type of visualization |
required |
base64_data
|
str
|
Base64-encoded image data |
required |
title
|
str | None
|
Image title |
None
|
caption
|
str | None
|
Image caption |
None
|
Source code in tit/reporting/generators/simulation.py
FlexSearchReportGenerator ¶
Bases: BaseReportGenerator
Report generator for flex-search optimization results.
Creates comprehensive HTML reports including: - Optimization configuration - Target ROI specification - Search results and rankings - Best solution details - Visualization of optimal electrode placement
Initialize the flex-search report generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
str | Path
|
Path to the project directory |
required |
subject_id
|
str
|
BIDS subject ID |
required |
session_id
|
str | None
|
Optional session identifier |
None
|
Source code in tit/reporting/generators/flex_search.py
set_configuration ¶
set_configuration(electrode_net: str | None = None, optimization_target: str | None = None, n_candidates: int = 100, selection_method: str = 'best', intensity_ch1: float = 1.0, intensity_ch2: float = 1.0, **kwargs) -> None
Set the optimization configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
electrode_net
|
str | None
|
EEG net used |
None
|
optimization_target
|
str | None
|
Target metric to optimize |
None
|
n_candidates
|
int
|
Number of candidate solutions evaluated |
100
|
selection_method
|
str
|
Method for selecting best solution |
'best'
|
intensity_ch1
|
float
|
Channel 1 intensity |
1.0
|
intensity_ch2
|
float
|
Channel 2 intensity |
1.0
|
**kwargs
|
Additional configuration |
{}
|
Source code in tit/reporting/generators/flex_search.py
set_roi_info ¶
set_roi_info(roi_name: str, roi_type: str = 'mask', coordinates: list[float] | None = None, radius: float | None = None, volume_mm3: float | None = None, n_voxels: int | None = None, **kwargs) -> None
Set the target ROI information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roi_name
|
str
|
Name of the target ROI |
required |
roi_type
|
str
|
Type of ROI (mask, sphere, coordinates) |
'mask'
|
coordinates
|
list[float] | None
|
Center coordinates (if applicable) |
None
|
radius
|
float | None
|
Radius in mm (if sphere) |
None
|
volume_mm3
|
float | None
|
ROI volume in mm³ |
None
|
n_voxels
|
int | None
|
Number of voxels in ROI |
None
|
**kwargs
|
Additional ROI info |
{}
|
Source code in tit/reporting/generators/flex_search.py
add_search_result ¶
add_search_result(rank: int, electrode_1a: str, electrode_1b: str, electrode_2a: str, electrode_2b: str, score: float, mean_field_roi: float | None = None, max_field_roi: float | None = None, focality: float | None = None, **metrics) -> None
Add a search result entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rank
|
int
|
Ranking of this solution |
required |
electrode_1a
|
str
|
First electrode of pair 1 |
required |
electrode_1b
|
str
|
Second electrode of pair 1 |
required |
electrode_2a
|
str
|
First electrode of pair 2 |
required |
electrode_2b
|
str
|
Second electrode of pair 2 |
required |
score
|
float
|
Optimization score |
required |
mean_field_roi
|
float | None
|
Mean field in ROI (V/m) |
None
|
max_field_roi
|
float | None
|
Max field in ROI (V/m) |
None
|
focality
|
float | None
|
Focality metric |
None
|
**metrics
|
Additional metrics |
{}
|
Source code in tit/reporting/generators/flex_search.py
set_best_solution ¶
set_best_solution(electrode_pairs: list[dict[str, str]], score: float, metrics: dict[str, Any], montage_image_base64: str | None = None, field_map_base64: str | None = None, electrode_coordinates: list[list[float]] | None = None, channel_array_indices: list[list[int]] | None = None) -> None
Set the best (selected) solution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
electrode_pairs
|
list[dict[str, str]]
|
List of electrode pair specs |
required |
score
|
float
|
Final optimization score |
required |
metrics
|
dict[str, Any]
|
Solution metrics |
required |
montage_image_base64
|
str | None
|
Base64 montage visualization |
None
|
field_map_base64
|
str | None
|
Base64 field map visualization |
None
|
Source code in tit/reporting/generators/flex_search.py
populate_from_data ¶
Populate the report from a data dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary containing all optimization data |
required |
Source code in tit/reporting/generators/flex_search.py
load_from_output_dir ¶
Load optimization data from an output directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str | Path
|
Path to the flex-search output directory |
required |
Source code in tit/reporting/generators/flex_search.py
PreprocessingReportGenerator ¶
PreprocessingReportGenerator(project_dir: str | Path, subject_id: str, session_id: str | None = None)
Bases: BaseReportGenerator
Report generator for preprocessing pipelines.
Creates comprehensive HTML reports including: - Input data summary - Processing steps with status - Output data summary - Software versions - Quality control visualizations - Methods boilerplate and references
Initialize the preprocessing report generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
str | Path
|
Path to the project directory |
required |
subject_id
|
str
|
BIDS subject ID |
required |
session_id
|
str | None
|
Optional session identifier |
None
|
Source code in tit/reporting/generators/preprocessing.py
set_pipeline_config ¶
Set the pipeline configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**config
|
Pipeline configuration parameters |
{}
|
add_input_data ¶
add_input_data(data_type: str, file_paths: list[str], metadata: dict[str, Any] | None = None) -> None
Add input data information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_type
|
str
|
Type of data (T1w, T2w, DWI, etc.) |
required |
file_paths
|
list[str]
|
List of input file paths |
required |
metadata
|
dict[str, Any] | None
|
Optional metadata about the data |
None
|
Source code in tit/reporting/generators/preprocessing.py
add_output_data ¶
add_output_data(data_type: str, file_paths: list[str], metadata: dict[str, Any] | None = None) -> None
Add output data information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_type
|
str
|
Type of data (m2m, FreeSurfer, etc.) |
required |
file_paths
|
list[str]
|
List of output file paths |
required |
metadata
|
dict[str, Any] | None
|
Optional metadata about the data |
None
|
Source code in tit/reporting/generators/preprocessing.py
add_processing_step ¶
add_processing_step(step_name: str, description: str | None = None, parameters: dict[str, Any] | None = None, status: StatusType | str = PENDING, duration: float | None = None, output_files: list[str] | None = None, figures: list[dict[str, Any]] | None = None, error_message: str | None = None) -> None
Add a processing step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_name
|
str
|
Name of the processing step |
required |
description
|
str | None
|
Step description |
None
|
parameters
|
dict[str, Any] | None
|
Step parameters |
None
|
status
|
StatusType | str
|
Step status |
PENDING
|
duration
|
float | None
|
Duration in seconds |
None
|
output_files
|
list[str] | None
|
Output file paths |
None
|
figures
|
list[dict[str, Any]] | None
|
QC figures |
None
|
error_message
|
str | None
|
Error message if failed |
None
|
Source code in tit/reporting/generators/preprocessing.py
add_qc_image ¶
add_qc_image(title: str, base64_data: str, step_name: str | None = None, caption: str | None = None, image_type: str = 'qc') -> None
Add a quality control image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Image title |
required |
base64_data
|
str
|
Base64-encoded image data |
required |
step_name
|
str | None
|
Associated processing step |
None
|
caption
|
str | None
|
Image caption |
None
|
image_type
|
str
|
Type of QC image |
'qc'
|
Source code in tit/reporting/generators/preprocessing.py
scan_for_data ¶
Automatically scan directories for input and output data.
Only scans for outputs that correspond to the processing steps that were added to this report.
Source code in tit/reporting/generators/preprocessing.py
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 | |
create_flex_search_report ¶
create_flex_search_report(project_dir: str | Path, subject_id: str, data: dict[str, Any], output_path: str | Path | None = None) -> Path
Convenience function to create a flex-search report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
str | Path
|
Path to project directory |
required |
subject_id
|
str
|
BIDS subject ID |
required |
data
|
dict[str, Any]
|
Dictionary containing optimization data |
required |
output_path
|
str | Path | None
|
Optional custom output path |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated report |
Source code in tit/reporting/generators/flex_search.py
create_preprocessing_report ¶
create_preprocessing_report(project_dir: str | Path, subject_id: str, processing_steps: list[dict[str, Any]] | None = None, output_path: str | Path | None = None, auto_scan: bool = True) -> Path
Convenience function to create a preprocessing report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
str | Path
|
Path to project directory |
required |
subject_id
|
str
|
BIDS subject ID |
required |
processing_steps
|
list[dict[str, Any]] | None
|
List of processing step dictionaries |
None
|
output_path
|
str | Path | None
|
Optional custom output path |
None
|
auto_scan
|
bool
|
Whether to auto-scan for data |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated report |