oxytcmri.domain.use_cases.compute_dti_normative_values
¶
Classes:
| Name | Description |
|---|---|
StatisticStrategy |
A statistical calculation strategy that encapsulates both the type |
StatisticsStrategies |
A collection of statistical calculation strategies for DTI metrics. |
NormativeValue |
Represents a normative value for a DTI metric. |
NormativeValueRepository |
Abstract base class for Normative Value repository. |
ComputeDTINormativeValues |
Use case for computing normative DTI values from healthy volunteers. |
StatisticStrategy(name, calculate)
dataclass
¶
A statistical calculation strategy that encapsulates both the type and the calculation method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A human-readable name for the statistical strategy |
required |
calculate
|
Callable[[List[float]], float]
|
A function that calculates a specific statistical measure |
required |
Methods:
| Name | Description |
|---|---|
__call__ |
Allows the strategy to be called directly like a function |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
calculate |
Callable[[List[float]], float]
|
|
StatisticsStrategies
¶
A collection of statistical calculation strategies for DTI metrics.
This class defines various statistical methods that can be applied to lists of float values, with built-in handling for empty lists.
Methods:
| Name | Description |
|---|---|
mean |
Calculate the arithmetic mean of the values |
std_dev |
Calculate the standard deviation of the values |
quartile_25 |
Calculate the 25th quantile (first quartile) |
quartile_75 |
Calculate the 75th quantile (third quartile) |
iqr |
Calculate the interquartile range |
Attributes:
| Name | Type | Description |
|---|---|---|
MEAN_STRATEGY |
|
|
STD_DEV_STRATEGY |
|
|
QUARTILE_25_STRATEGY |
|
|
QUARTILE_75_STRATEGY |
|
|
IQR_STRATEGY |
|
|
QUANTILE_5_STRATEGY |
|
|
QUANTILE_95_STRATEGY |
|
MEAN_STRATEGY = StatisticStrategy('mean', mean)
class-attribute
instance-attribute
¶
STD_DEV_STRATEGY = StatisticStrategy('standard deviation', std_dev)
class-attribute
instance-attribute
¶
QUARTILE_25_STRATEGY = StatisticStrategy('quartile 25', quartile_25)
class-attribute
instance-attribute
¶
QUARTILE_75_STRATEGY = StatisticStrategy('quartile 75', quartile_75)
class-attribute
instance-attribute
¶
IQR_STRATEGY = StatisticStrategy('interquartile range', iqr)
class-attribute
instance-attribute
¶
QUANTILE_5_STRATEGY = StatisticStrategy('quantile 5', quantile_5)
class-attribute
instance-attribute
¶
QUANTILE_95_STRATEGY = StatisticStrategy('quantile 95', quantile_95)
class-attribute
instance-attribute
¶
mean(values)
staticmethod
¶
Calculate mean with handling for empty lists.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
86 87 88 89 | |
std_dev(values)
staticmethod
¶
Calculate standard deviation with handling for empty lists.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
91 92 93 94 | |
parametric_percentile(values, quantile)
staticmethod
¶
Calculate the quantile for a given percentile q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
List[float]
|
The list of values to calculate the quantile on |
required |
quantile
|
float
|
The desired percentile (0-100) |
required |
Returns:
| Type | Description |
|---|---|
float
|
The calculated quantile value |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
quartile_25(values)
staticmethod
¶
Calculate 25th percentile with handling for empty lists.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
115 116 117 118 | |
quartile_75(values)
staticmethod
¶
Calculate 75th quantile with handling for empty lists.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
120 121 122 123 | |
quantile_5(values)
staticmethod
¶
Calculate 5th quantile with handling for empty lists.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
125 126 127 128 | |
quantile_95(values)
staticmethod
¶
Calculate 95th quantile with handling for empty lists.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
130 131 132 133 | |
iqr(values)
staticmethod
¶
Calculate interquartile range with handling for empty lists.
Returns the difference between 75th and 25th percentiles.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
135 136 137 138 139 140 141 142 143 144 145 146 | |
all()
classmethod
¶
Retrieve all defined statistical strategies.
Returns:
| Type | Description |
|---|---|
List[StatisticStrategy]
|
A list of all available statistical strategies |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
get_by_name(name)
classmethod
¶
Retrieve a statistical strategy by its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the statistical strategy |
required |
Returns:
| Type | Description |
|---|---|
StatisticStrategy
|
The corresponding statistical strategy |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no strategy with the given name exists |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
NormativeValue(center, dti_metric, atlas, atlas_label, statistic_strategy, value)
dataclass
¶
Represents a normative value for a DTI metric.
A normative value is a statistical measure calculated from healthy subjects for a specific DTI metric in a specific anatomical region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Center
|
The medical center where the normative value was calculated |
required |
dti_metric
|
DTIMetric
|
The type of DTI metric (e.g., MD, FA) |
required |
atlas
|
Atlas
|
The atlas used for segmentation |
required |
atlas_label
|
int
|
The specific label within the atlas |
required |
statistic_strategy
|
StatisticStrategy
|
The statistical strategy used to compute the value |
required |
value
|
float
|
The calculated statistical value |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
center |
Center
|
|
dti_metric |
DTIMetric
|
|
atlas |
Atlas
|
|
atlas_label |
int
|
|
statistic_strategy |
StatisticStrategy
|
|
value |
float
|
|
NormativeValueRepository
¶
Bases: Repository[NormativeValue, None], ABC
Abstract base class for Normative Value repository.
Defines the interface for saving and retrieving normative values.
Methods:
| Name | Description |
|---|---|
get_by_parameters |
Retrieve a normative value by its parameters. |
get_by_parameters(center, dti_metric, atlas, atlas_label, statistic_strategy)
abstractmethod
¶
Retrieve a normative value by its parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Center
|
The medical center where the normative value was calculated |
required |
dti_metric
|
DTIMetric
|
The type of DTI metric (e.g., MD, FA) |
required |
atlas
|
Atlas
|
The atlas used for segmentation |
required |
atlas_label
|
int
|
The specific label within the atlas |
required |
statistic_strategy
|
StatisticStrategy
|
The statistical strategy used to compute the value |
required |
Returns:
| Type | Description |
|---|---|
NormativeValue
|
The corresponding normative value |
Raises:
| Type | Description |
|---|---|
EntityIdNotFoundException
|
If no normative value with the given parameters exists |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
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 | |
ComputeDTINormativeValues(repositories_registry, dispatcher=None)
¶
Use case for computing normative DTI values from healthy volunteers.
This class orchestrates the process of extracting DTI values from healthy subjects and computing various statistical measures.
Attributes:
| Name | Type | Description |
|---|---|---|
subjects_repository |
SubjectRepository
|
Repository for accessing subject information |
mri_repository |
MRIExamRepository
|
Repository for accessing MRI data |
atlas_repository |
AtlasRepository
|
Repository for accessing atlas information |
centers_repository |
CenterRepository
|
Repository for accessing center information |
Initialize the use case with a subject repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repositories_registry
|
RepositoriesRegistry
|
Registry for accessing various repositories |
required |
dispatcher
|
EventDispatcher
|
Event dispatcher for dispatching events (progress bar, logs, etc.) |
None
|
Methods:
| Name | Description |
|---|---|
compute_total_steps |
Get the total number of steps for the progress bar. |
initialize_progress_bar |
Initialize the progress bar using the dispatcher. |
update_progress_bar |
Update the progress bar using the dispatcher. |
compute_all_normative_values |
Compute normative values for all DTI metrics, statistical strategies, centers, atlases, and labels. |
process_center |
Process a specific center for a given DTI metric and statistical strategy. |
collect_dti_values_for_region |
Collect DTI values for a specific region from multiple subjects. |
get_regions_of_interest |
Retrieve the list of regions of interest. |
store_normative_value |
Store the normative value in the repository. |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
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 | |
atlas_repository = repositories_registry.get_repository(Atlas)
instance-attribute
¶
centers_repository = repositories_registry.get_repository(Center)
instance-attribute
¶
subjects_repository = repositories_registry.get_repository(Subject)
instance-attribute
¶
mri_repository = repositories_registry.get_repository(MRIExam)
instance-attribute
¶
normative_values_repository = repositories_registry.get_repository(NormativeValue)
instance-attribute
¶
dispatcher = dispatcher
instance-attribute
¶
current_step = None
instance-attribute
¶
total_steps = None
instance-attribute
¶
compute_total_steps(dti_metrics_count, statistics_strategies_count)
¶
Get the total number of steps for the progress bar.
Returns:
| Type | Description |
|---|---|
int
|
The total number of steps |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
initialize_progress_bar(dti_metrics_to_process, statistics_strategies_to_process)
¶
Initialize the progress bar using the dispatcher.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
412 413 414 415 416 417 418 419 420 421 422 423 | |
update_progress_bar()
¶
Update the progress bar using the dispatcher.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
425 426 427 428 429 430 431 | |
compute_all_normative_values(statistics_strategies=None, dti_metrics=None)
¶
Compute normative values for all DTI metrics, statistical strategies, centers, atlases, and labels.
This is the main entry point that orchestrates the computation process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
statistics_strategies
|
List[StatisticStrategy]
|
List of statistical strategies to include in computations. If provided, only this subset will be computed. |
None
|
dti_metrics
|
List[DTIMetric]
|
List of DTI metrics to include in computations. If provided, only this subset will be computed. |
None
|
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
process_center(center, dti_metric, statistic_strategy, region_of_interest)
¶
Process a specific center for a given DTI metric and statistical strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Center
|
The center to process |
required |
dti_metric
|
DTIMetric
|
The DTI metric to process |
required |
statistic_strategy
|
StatisticStrategy
|
The statistical strategy to apply |
required |
region_of_interest
|
RegionOfInterest
|
The region of interest to process |
required |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
collect_dti_values_for_region(subjects, dti_metric, region_of_interest)
¶
Collect DTI values for a specific region from multiple subjects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subjects
|
List[Subject]
|
List of subjects to extract values from |
required |
dti_metric
|
DTIMetric
|
The DTI metric to extract |
required |
region_of_interest
|
RegionOfInterest
|
The region of interest to extract values from |
required |
Returns:
| Type | Description |
|---|---|
List[float]
|
Combined list of DTI values from all subjects |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
get_regions_of_interest()
¶
Retrieve the list of regions of interest.
Returns:
| Type | Description |
|---|---|
List[RegionOfInterest]
|
A list of regions of interest |
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
store_normative_value(normative_value)
¶
Store the normative value in the repository.
Source code in oxytcmri/domain/use_cases/compute_dti_normative_values.py
592 593 594 595 596 597 598 599 600 | |