-
Notifications
You must be signed in to change notification settings - Fork 1
Add choice of type of attenuation/HU/density map for inpit #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,12 +10,15 @@ | |||||||||
| import shutil | ||||||||||
| from dataclasses import dataclass, field | ||||||||||
| from pathlib import Path | ||||||||||
| from typing import Any, Dict, Optional, Union | ||||||||||
| from typing import Any, Dict, Literal, Optional, Union | ||||||||||
|
|
||||||||||
| import numpy as np | ||||||||||
|
|
||||||||||
| from sirf_simind_connection.connectors.base import BaseConnector | ||||||||||
| from sirf_simind_connection.converters.attenuation import attenuation_to_density | ||||||||||
| from sirf_simind_connection.converters.attenuation import ( | ||||||||||
| attenuation_to_density, | ||||||||||
| hu_to_density_schneider, | ||||||||||
| ) | ||||||||||
| from sirf_simind_connection.converters.simind_to_stir import SimindToStirConverter | ||||||||||
| from sirf_simind_connection.core.config import RuntimeSwitches, SimulationConfig | ||||||||||
| from sirf_simind_connection.core.executor import SimindExecutor | ||||||||||
|
|
@@ -31,6 +34,7 @@ | |||||||||
|
|
||||||||||
| ConfigSource = Union[str, os.PathLike[str], SimulationConfig] | ||||||||||
| PathLike = Union[str, os.PathLike[str]] | ||||||||||
| MuMapType = Literal["attenuation", "density", "hu"] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @dataclass(frozen=True) | ||||||||||
|
|
@@ -108,15 +112,31 @@ def configure_voxel_phantom( | |||||||||
| mu_map: np.ndarray, | ||||||||||
| voxel_size_mm: float = 4.0, | ||||||||||
| scoring_routine: Union[ScoringRoutine, int] = ScoringRoutine.SCATTWIN, | ||||||||||
| mu_map_type: MuMapType = "attenuation", | ||||||||||
| ) -> tuple[Path, Path]: | ||||||||||
| """ | ||||||||||
| Configure voxel geometry and write source/density input files. | ||||||||||
|
|
||||||||||
| Args: | ||||||||||
| source: Source activity array in SIMIND image axes (z, y, x). | ||||||||||
| mu_map: Input volume interpreted according to ``mu_map_type``. | ||||||||||
| voxel_size_mm: Isotropic voxel size in mm. | ||||||||||
| scoring_routine: SIMIND scoring routine identifier. | ||||||||||
| mu_map_type: Interpretation of ``mu_map`` values: | ||||||||||
| - ``"attenuation"``: linear attenuation (cm^-1), converted to density. | ||||||||||
| - ``"density"``: density (g/cm^3), written directly. | ||||||||||
|
||||||||||
| - ``"density"``: density (g/cm^3), written directly. | |
| - ``"density"``: density (g/cm^3); values are expected in g/cm^3 and | |
| are internally scaled to mg/cm^3 and quantized to ``uint16`` when | |
| writing the SIMIND density file. |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalized_map_type is computed as a plain str and then passed into _convert_mu_input_to_density(), which is typed to accept MuMapType (a Literal[...]). This is a type-hint mismatch that will trip static type checkers and makes the intent less clear. After validating membership, cast normalized_map_type to MuMapType (or change _convert_mu_input_to_density to accept str) so the types align.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HU conversion relies on
hu_to_density_schneider(), which readsSchneider2000.jsonfrom package resources. Currentlypyproject.tomlonly includessirf_simind_connection/data/*.atnas package data, so installed distributions may missSchneider2000.jsonand HU workflows will fail at runtime. IncludeSchneider2000.json(ordata/*.json) in package data / manifest so the resource is shipped with the wheel/sdist.