Skip to content
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

Feature/whole body #26

Merged
merged 5 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ python scripts/experiment.py --config-name config_prod params=params_test params
python scripts/experiment.py --config-name config_prod params=params_test params/scanner=discovery params.do_simulation=0 params.scanner.scanner_radius=35
```

# Whole Body Simulation

You can perform whole body simulations following the same logic described in the last section. You may want to add `z_min` and `z_max` parameters to the `params` configuration group. Here you can find the configuration templates:

- Example of [`global`](configs/config_test_wholebody.yaml) configuration.
- Example of [`params`](configs/params/test_wholebody.yaml) configuration group.

Then you can launch an experiment with:

```
python3.9 scripts/experiment_wholebody.py --config-name <your_config_name>
```

Even add `z_min` and `z_max` on the fly:

```
python3.9 scripts/experiment_wholebody.py --config-name <your_config_name> +params.z_min=29 +params.z_max=89
```

Or override them:

```
python3.9 scripts/experiment_wholebody.py --config-name <your_config_name> params.z_min=29 params.z_max=89
```

**NOTES ON USAGE**:

- Monte Carlo simulations usually take a lot of space. If you want to change the default Data and Results directories you can do so in the in the `global` configuration group or using [facebook-hydra](https://hydra.cc) CLI overriding syntax.
Expand All @@ -80,7 +105,7 @@ python scripts/experiment.py --config-name config_prod params=params_test params
- Jesús Silva-Rodríguez
- Pablo Aguiar
- Aida Ninyerola-Baizan
- Jeremiah Póveda
- Jeremiah Poveda
- Francisco Javier López-González
- Nikos Efthimiou
- Arnau Farre
Expand Down
21 changes: 21 additions & 0 deletions configs/config_test_wholebody.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defaults:
- params: test_wholebody
interactive_mode: 0
dir_stir: ${root_path:root}/include/STIR/install
dir_simset: ${root_path:root}/include/SimSET/2.9.2
matlab_mcr_path: ""
spm_path: ""
dir_data_path: ${root_path:root}/Data
dir_results_path: ${root_path:root}/Results
stratification: "true"
forced_detection: "true"
forced_non_absortion: "true"
acceptance_angle: 90.0
positron_range: "true"
isotope: "f18"
non_colinearity: "true"
minimum_energy: 350.0
weight_window_ratio: 1.0
point_source_voxels: "false"
coherent_scatter_object: "false"
coherent_scatter_detector: "false"
26 changes: 26 additions & 0 deletions configs/params/test_wholebody.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
defaults:
- scanner: discovery_st

simulation_environment: 0
sim_type: "SimSET"
do_simulation: 1
do_reconstruction: 1
divisions: 2
model_type: "cylindrical"
patient_dirname: "test_image"
act_map: "act.hdr"
att_map: "att.hdr"
output_dir: "test_image"
center_slice: 7
total_dose: 0.1
simulation_time: 30
sampling_photons: 0
photons: 0
add_randoms: 1
phglistmode: 0
detlistmode: 1
maximumIteration: 1

# Variables needed for whole body simulation
z_min: 75
z_max: 316
29 changes: 29 additions & 0 deletions scripts/experiment_wholebody.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import sys
import hydra
import yaml
from typing import Union, Mapping, Any
from pathlib import Path
from pyprojroot import here
from omegaconf import DictConfig, OmegaConf

sys.path.append(str(here()))
import wholebody


try:
OmegaConf.register_new_resolver("root_path", lambda s: str(here()))
OmegaConf.register_new_resolver("home_path", lambda s: str(Path.home()))
except ValueError:
pass


@hydra.main(version_base=None, config_path=str(here().joinpath("configs")), config_name="config_test_wholebody")
def simulate(cfg: DictConfig) -> None:
OmegaConf.resolve(cfg)
wb = wholebody.WholebodySimulation(cfg)
wb.run()
cfg = OmegaConf.to_container(cfg)


if __name__ == "__main__":
simulate()
Loading
Loading