utils
tit.opt.flex.utils ¶
ROI configuration and output naming for flex-search.
generate_run_dirname ¶
Generate a datetime-based directory name for a flex-search run.
Format: YYYYMMDD_HHMMSS. Appends _1, _2, etc. if the folder already exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Parent directory (e.g. flex-search/) to check for collisions. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Directory name string (not full path). |
Source code in tit/opt/flex/utils.py
generate_label ¶
Build a human-readable label for a flex-search run.
This label is stored in flex_meta.json for GUI display purposes. It is NOT used for folder naming or machine parsing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FlexConfig instance. |
required | |
pareto
|
bool
|
True if this is a pareto sweep run. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Label string like "mean_maxTI_sphere(-42,-20,55)r10". |
Source code in tit/opt/flex/utils.py
parse_optimization_output ¶
Extract the optimization function value from a SimNIBS log line.
Handles patterns
- "Final goal function value: -42.123"
- "Goal function value.*: -42.123"
- Table row with max_TI column (scientific notation)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
A single line of SimNIBS stdout/stderr. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
The function value as a float, or None if the line does not match. |
Source code in tit/opt/flex/utils.py
configure_roi ¶
configure_roi(opt, config: FlexConfig) -> None
Configure ROI based on the config's ROI specification.
This is the main entry point for ROI configuration that delegates to the appropriate method-specific function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opt
|
SimNIBS |
required | |
config
|
FlexConfig
|
Flex-search configuration with ROI spec. |
required |