reporting
tit.reporting ¶
TI-Toolbox Reportlet-Based Reporting System.
A modular, NiPreps-inspired reporting system for TI-Toolbox that generates self-contained HTML reports across preprocessing, simulation, and flex-search modules.
ReportMetadata
dataclass
¶
ReportMetadata(title: str, subject_id: str | None = None, session_id: str | None = None, report_type: str = 'general', generation_time: datetime = now(), software_versions: dict[str, str] = dict(), project_dir: str | None = None, bids_version: str = '1.8.0', dataset_type: str = 'derivative')
Metadata for a generated report.
to_dict ¶
Convert metadata to dictionary.
Source code in tit/reporting/core/protocols.py
ReportSection
dataclass
¶
ReportSection(section_id: str, title: str, reportlets: list[Any] = list(), description: str | None = None, collapsed: bool = False, order: int = 0)
A section within a report containing multiple reportlets.
render_html ¶
render_html() -> str
Render the section and all its reportlets as HTML.
Source code in tit/reporting/core/protocols.py
to_dict ¶
Convert section to dictionary.
Source code in tit/reporting/core/protocols.py
BaseReportlet ¶
BaseReportlet(title: str | None = None)
Bases: ABC
Abstract base class for all reportlets.
Source code in tit/reporting/core/base.py
reportlet_type
abstractmethod
property
¶
reportlet_type: ReportletType
Return the type of this reportlet.
MetadataReportlet ¶
MetadataReportlet(data: dict[str, Any], title: str | None = None, display_mode: str = 'table', columns: int = 2)
Bases: BaseReportlet
Reportlet for displaying metadata as key-value pairs.
Supports two display modes: - 'table': Traditional table layout - 'cards': Modern card grid layout
Source code in tit/reporting/core/base.py
ImageReportlet ¶
ImageReportlet(image_source: str | Path | bytes | Any | None = None, title: str | None = None, caption: str | None = None, alt_text: str | None = None, width: str | None = None, height: str | None = None)
Bases: BaseReportlet
Reportlet for displaying images.
Supports embedding images as base64 or referencing external paths. Images can be loaded from file paths, PIL Images, or raw bytes.
Source code in tit/reporting/core/base.py
set_base64_data ¶
render_html ¶
render_html() -> str
Render image as HTML.
Source code in tit/reporting/core/base.py
TableReportlet ¶
TableReportlet(data: list[dict] | list[list] | Any, title: str | None = None, headers: list[str] | None = None, sortable: bool = False, striped: bool = True, compact: bool = False)
Bases: BaseReportlet
Reportlet for displaying tabular data.
Supports various input formats including lists of dicts, lists of lists, and pandas DataFrames.
Source code in tit/reporting/core/base.py
render_html ¶
render_html() -> str
Render table as HTML.
Source code in tit/reporting/core/base.py
TextReportlet ¶
TextReportlet(content: str, title: str | None = None, content_type: str = 'text', copyable: bool = False, monospace: bool = False)
Bases: BaseReportlet
Reportlet for displaying text content.
Supports plain text, HTML, and markdown-style formatting. Includes optional copy-to-clipboard functionality for boilerplate text.
Source code in tit/reporting/core/base.py
render_html ¶
render_html() -> str
Render text content as HTML.
Source code in tit/reporting/core/base.py
ErrorReportlet ¶
Bases: BaseReportlet
Reportlet for displaying errors and warnings.
Supports different severity levels with appropriate styling.
Source code in tit/reporting/core/base.py
add_message ¶
add_message(message: str, severity: SeverityLevel = ERROR, context: str | None = None, step: str | None = None) -> None
Add an error or warning message.
Source code in tit/reporting/core/base.py
add_error ¶
add_warning ¶
render_html ¶
render_html() -> str
Render errors and warnings as HTML.
Source code in tit/reporting/core/base.py
ReferencesReportlet ¶
Bases: BaseReportlet
Reportlet for displaying citations and references.
Automatically formats references in a consistent style.
Source code in tit/reporting/core/base.py
add_reference ¶
Add a reference.
Source code in tit/reporting/core/base.py
render_html ¶
render_html() -> str
Render references as HTML.
Source code in tit/reporting/core/base.py
ReportAssembler ¶
ReportAssembler(metadata: ReportMetadata | None = None, title: str | None = None)
Assembles reportlets into a complete HTML report.
The assembler manages sections, handles ordering, generates the table of contents, and renders the final HTML document.
Initialize the report assembler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
ReportMetadata | None
|
Report metadata (title, subject, etc.) |
None
|
title
|
str | None
|
Report title (overrides metadata.title if provided) |
None
|
Source code in tit/reporting/core/assembler.py
add_section ¶
add_section(section_id: str, title: str, description: str | None = None, collapsed: bool = False, order: int | None = None) -> ReportSection
Add a new section to the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section_id
|
str
|
Unique identifier for the section |
required |
title
|
str
|
Section title |
required |
description
|
str | None
|
Optional section description |
None
|
collapsed
|
bool
|
Whether section starts collapsed |
False
|
order
|
int | None
|
Sort order (lower = earlier in report) |
None
|
Returns:
| Type | Description |
|---|---|
ReportSection
|
The created ReportSection object |
Source code in tit/reporting/core/assembler.py
get_section ¶
get_section(section_id: str) -> ReportSection | None
Get a section by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section_id
|
str
|
The section identifier |
required |
Returns:
| Type | Description |
|---|---|
ReportSection | None
|
The ReportSection or None if not found |
Source code in tit/reporting/core/assembler.py
add_reportlet_to_section ¶
add_reportlet_to_section(section_id: str, reportlet: Any, create_if_missing: bool = True, section_title: str | None = None) -> None
Add a reportlet to a specific section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section_id
|
str
|
The section identifier |
required |
reportlet
|
Any
|
The reportlet to add |
required |
create_if_missing
|
bool
|
Create section if it doesn't exist |
True
|
section_title
|
str | None
|
Title for new section (if created) |
None
|
Source code in tit/reporting/core/assembler.py
render_toc ¶
render_toc() -> str
Render the table of contents as HTML.
Returns:
| Type | Description |
|---|---|
str
|
HTML string for the table of contents |
Source code in tit/reporting/core/assembler.py
render_metadata ¶
render_metadata() -> str
Render the header metadata as HTML.
Returns:
| Type | Description |
|---|---|
str
|
HTML string for the header metadata |
Source code in tit/reporting/core/assembler.py
render_sections ¶
render_sections() -> str
Render all sections as HTML.
Returns:
| Type | Description |
|---|---|
str
|
HTML string for all sections |
Source code in tit/reporting/core/assembler.py
render_html ¶
render_html() -> str
Render the complete report as HTML.
Returns:
| Type | Description |
|---|---|
str
|
Complete HTML document as a string |
Source code in tit/reporting/core/assembler.py
save ¶
Save the report to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str | Path
|
Path to save the HTML file |
required |
create_dirs
|
bool
|
Create parent directories if needed |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved file |
Source code in tit/reporting/core/assembler.py
to_dict ¶
from_dict
classmethod
¶
Create a ReportAssembler from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary containing report data |
required |
Returns:
| Type | Description |
|---|---|
Self
|
Reconstructed ReportAssembler instance |
Note
This reconstructs the structure but not the reportlet instances. Use this for loading report metadata, not for full reconstruction.
Source code in tit/reporting/core/assembler.py
SliceSeriesReportlet ¶
SliceSeriesReportlet(title: str | None = None, slices: list[dict[str, Any]] | None = None, orientation: str = 'axial', caption: str | None = None)
Bases: BaseReportlet
Reportlet for displaying a series of brain slices.
Displays multiple slices (typically 7) across axial, sagittal, or coronal views, commonly used for QC visualizations.
Initialize the slice series reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the slice series |
None
|
slices
|
list[dict[str, Any]] | None
|
List of slice data dicts with 'base64' and optional 'label' |
None
|
orientation
|
str
|
View orientation (axial, sagittal, coronal) |
'axial'
|
caption
|
str | None
|
Optional caption text |
None
|
Source code in tit/reporting/reportlets/images.py
add_slice ¶
add_slice(image_data: str | bytes | Path | Any, label: str | None = None, mime_type: str = 'image/png') -> None
Add a slice to the series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_data
|
str | bytes | Path | Any
|
Base64 string, bytes, path, or PIL Image |
required |
label
|
str | None
|
Optional label for this slice |
None
|
mime_type
|
str
|
MIME type of the image |
'image/png'
|
Source code in tit/reporting/reportlets/images.py
load_from_files ¶
render_html ¶
render_html() -> str
Render the slice series as HTML.
Source code in tit/reporting/reportlets/images.py
MontageImageReportlet ¶
MontageImageReportlet(title: str | None = None, image_source: str | Path | bytes | Any | None = None, electrode_pairs: list[dict[str, Any]] | None = None, montage_name: str | None = None)
Bases: BaseReportlet
Reportlet for displaying electrode montage visualizations.
Shows electrode placement with labeled pairs and optional intensity annotations.
Initialize the montage image reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the montage |
None
|
image_source
|
str | Path | bytes | Any | None
|
Montage image (path, bytes, or PIL Image) |
None
|
electrode_pairs
|
list[dict[str, Any]] | None
|
List of electrode pair configurations |
None
|
montage_name
|
str | None
|
Name of the montage |
None
|
Source code in tit/reporting/reportlets/images.py
set_base64_data ¶
add_electrode_pair ¶
add_electrode_pair(name: str, electrode1: str, electrode2: str, intensity: float | None = None) -> None
Add an electrode pair to the montage info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the pair (e.g., "Pair 1") |
required |
electrode1
|
str
|
First electrode position |
required |
electrode2
|
str
|
Second electrode position |
required |
intensity
|
float | None
|
Optional current intensity |
None
|
Source code in tit/reporting/reportlets/images.py
render_html ¶
render_html() -> str
Render the montage image as HTML.
Source code in tit/reporting/reportlets/images.py
MultiViewBrainReportlet ¶
MultiViewBrainReportlet(title: str | None = None, axial_image: str | Path | bytes | None = None, sagittal_image: str | Path | bytes | None = None, coronal_image: str | Path | bytes | None = None, caption: str | None = None)
Bases: BaseReportlet
Reportlet for displaying brain images in multiple views.
Shows the same brain data in axial, sagittal, and coronal orientations side by side.
Initialize the multi-view brain reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the visualization |
None
|
axial_image
|
str | Path | bytes | None
|
Axial view image |
None
|
sagittal_image
|
str | Path | bytes | None
|
Sagittal view image |
None
|
coronal_image
|
str | Path | bytes | None
|
Coronal view image |
None
|
caption
|
str | None
|
Optional caption |
None
|
Source code in tit/reporting/reportlets/images.py
set_view ¶
Set an image for a specific view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_name
|
str
|
One of 'axial', 'sagittal', 'coronal' |
required |
image_data
|
str | Path | bytes | Any
|
Image data (path, bytes, base64, or PIL Image) |
required |
Source code in tit/reporting/reportlets/images.py
render_html ¶
render_html() -> str
Render the multi-view visualization as HTML.
Source code in tit/reporting/reportlets/images.py
ConductivityTableReportlet ¶
ConductivityTableReportlet(conductivities: dict[str, dict[str, Any]] | None = None, title: str | None = None, show_sources: bool = True, conductivity_type: str = 'scalar')
Bases: BaseReportlet
Reportlet for displaying tissue conductivity values.
Shows conductivity values for different tissue types with their sources/references.
Initialize the conductivity table reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conductivities
|
dict[str, dict[str, Any]] | None
|
Dict mapping tissue names to conductivity info |
None
|
title
|
str | None
|
Title for the table |
None
|
show_sources
|
bool
|
Whether to show source references |
True
|
conductivity_type
|
str
|
Type of conductivity (scalar, anisotropic, etc.) |
'scalar'
|
Source code in tit/reporting/reportlets/metadata.py
set_conductivity ¶
Set conductivity for a tissue type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tissue
|
str
|
Tissue name |
required |
value
|
float
|
Conductivity value |
required |
unit
|
str
|
Unit of measurement |
'S/m'
|
source
|
str | None
|
Source reference |
None
|
Source code in tit/reporting/reportlets/metadata.py
render_html ¶
render_html() -> str
Render the conductivity table as HTML.
Source code in tit/reporting/reportlets/metadata.py
ProcessingStepReportlet ¶
Bases: BaseReportlet
Reportlet for displaying processing pipeline steps.
Shows collapsible processing steps with status, duration, and optional details.
Initialize the processing step reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the processing steps section |
None
|
steps
|
list[dict[str, Any]] | None
|
List of step dictionaries |
None
|
Source code in tit/reporting/reportlets/metadata.py
add_step ¶
add_step(name: str, description: str | None = None, status: StatusType | str = PENDING, duration: float | None = None, parameters: dict[str, Any] | None = None, output_files: list[str] | None = None, error_message: str | None = None) -> None
Add a processing step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Step name |
required |
description
|
str | None
|
Step description |
None
|
status
|
StatusType | str
|
Step status (pending, running, completed, failed, skipped) |
PENDING
|
duration
|
float | None
|
Duration in seconds |
None
|
parameters
|
dict[str, Any] | None
|
Step parameters |
None
|
output_files
|
list[str] | None
|
List of output file paths |
None
|
error_message
|
str | None
|
Error message if failed |
None
|
Source code in tit/reporting/reportlets/metadata.py
render_html ¶
render_html() -> str
Render the processing steps as HTML.
Source code in tit/reporting/reportlets/metadata.py
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 369 370 371 | |
SummaryCardsReportlet ¶
SummaryCardsReportlet(title: str | None = None, cards: list[dict[str, Any]] | None = None, columns: int = 4)
Bases: BaseReportlet
Reportlet for displaying key summary metrics as cards.
Shows important values in a prominent card grid layout.
Initialize the summary cards reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the summary section |
None
|
cards
|
list[dict[str, Any]] | None
|
List of card data dicts |
None
|
columns
|
int
|
Number of columns in grid |
4
|
Source code in tit/reporting/reportlets/metadata.py
add_card ¶
add_card(label: str, value: Any, icon: str | None = None, color: str | None = None, subtitle: str | None = None) -> None
Add a summary card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Card label |
required |
value
|
Any
|
Card value |
required |
icon
|
str | None
|
Optional icon character |
None
|
color
|
str | None
|
Optional accent color |
None
|
subtitle
|
str | None
|
Optional subtitle text |
None
|
Source code in tit/reporting/reportlets/metadata.py
render_html ¶
render_html() -> str
Render the summary cards as HTML.
Source code in tit/reporting/reportlets/metadata.py
ParameterListReportlet ¶
ParameterListReportlet(title: str | None = None, parameters: dict[str, dict[str, Any]] | None = None)
Bases: BaseReportlet
Reportlet for displaying a categorized list of parameters.
Organizes parameters into groups with clear visual hierarchy.
Initialize the parameter list reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the parameters section |
None
|
parameters
|
dict[str, dict[str, Any]] | None
|
Dict of category -> {param_name: param_value} |
None
|
Source code in tit/reporting/reportlets/metadata.py
add_category ¶
add_parameter ¶
render_html ¶
render_html() -> str
Render the parameter list as HTML.
Source code in tit/reporting/reportlets/metadata.py
MethodsBoilerplateReportlet ¶
MethodsBoilerplateReportlet(title: str | None = None, boilerplate_text: str | None = None, pipeline_type: str = 'simulation', parameters: dict[str, Any] | None = None)
Bases: BaseReportlet
Reportlet for displaying methods section boilerplate text.
Generates publication-ready text describing the methods used in the analysis, with a copy-to-clipboard button.
Initialize the methods boilerplate reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Title for the section |
None
|
boilerplate_text
|
str | None
|
Pre-written boilerplate text |
None
|
pipeline_type
|
str
|
Type of pipeline (simulation, preprocessing, optimization) |
'simulation'
|
parameters
|
dict[str, Any] | None
|
Parameters to include in generated text |
None
|
Source code in tit/reporting/reportlets/text.py
generate_boilerplate ¶
generate_boilerplate() -> str
Generate boilerplate text based on pipeline type and parameters.
Returns:
| Type | Description |
|---|---|
str
|
Generated boilerplate text |
Source code in tit/reporting/reportlets/text.py
render_html ¶
render_html() -> str
Render the boilerplate text as HTML.
Source code in tit/reporting/reportlets/text.py
DescriptionReportlet ¶
Bases: BaseReportlet
Reportlet for displaying descriptive text content.
Renders paragraphs of text with optional formatting.
Initialize the description reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Text content to display |
required |
title
|
str | None
|
Optional section title |
None
|
format_type
|
str
|
How to format content (paragraphs, html, preformatted) |
'paragraphs'
|
Source code in tit/reporting/reportlets/text.py
render_html ¶
render_html() -> str
Render the description text as HTML.
Source code in tit/reporting/reportlets/text.py
CommandLogReportlet ¶
Bases: BaseReportlet
Reportlet for displaying command execution logs.
Shows commands that were run with their outputs in a terminal-like display.
Initialize the command log reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Optional section title |
None
|
commands
|
list[dict[str, str]] | None
|
List of command dicts with 'command' and optional 'output' |
None
|
Source code in tit/reporting/reportlets/text.py
add_command ¶
Add a command to the log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
The command that was executed |
required |
output
|
str | None
|
Command output (if any) |
None
|
status
|
str
|
Execution status (success, error) |
'success'
|
Source code in tit/reporting/reportlets/text.py
render_html ¶
render_html() -> str
Render the command log as HTML.
Source code in tit/reporting/reportlets/text.py
TIToolboxReferencesReportlet ¶
TIToolboxReferencesReportlet(title: str | None = None, include_defaults: bool = True, pipeline_components: list[str] | None = None)
Bases: ReferencesReportlet
Specialized references reportlet with TI-Toolbox default citations.
Automatically includes relevant citations based on the pipeline components used.
Initialize the TI-Toolbox references reportlet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Section title |
None
|
include_defaults
|
bool
|
Whether to include default TI-Toolbox refs |
True
|
pipeline_components
|
list[str] | None
|
List of components used (to filter refs) |
None
|
Source code in tit/reporting/reportlets/references.py
add_default_reference ¶
Add a default reference by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The reference key (e.g., 'freesurfer', 'qsiprep') |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if reference was found and added, False otherwise |
Source code in tit/reporting/reportlets/references.py
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 | |
get_default_references ¶
get_reference_by_key ¶
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 |