Skip to content

Commit 88f5627

Browse files
authored
Merge branch 'develop' into T_371_seg_many_wvs
2 parents 2d91eed + 85463ef commit 88f5627

File tree

6 files changed

+157
-11
lines changed

6 files changed

+157
-11
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ once for checking if it works and then parse [--number 100] to run it at eg 100
199199
Please see [benchmarking.md](docs/source/benchmarking.md) for a complete explanation.
200200

201201

202+
# Understanding SIMPA
203+
204+
**Tags** are identifiers in SIMPA used to categorize settings and components within simulations, making configurations
205+
modular, readable, and manageable. Tags offer organizational, flexible, and reusable benefits by acting as keys in
206+
configuration dictionaries.
207+
208+
**Settings** in SIMPA control simulation behavior. They include:
209+
210+
- **Global Settings**: Apply to the entire simulation, affecting overall properties and parameters.
211+
- **Component Settings**: Specific to individual components, allowing for detailed customization and optimization of
212+
each part of the simulation.
213+
214+
Settings are defined in a hierarchical structure, where global settings are established first, followed by
215+
component-specific settings. This approach ensures comprehensive and precise control over the simulation process.
216+
For detailed information, users can refer to the [understanding SIMPA documentation](./docs/source/understanding_simpa.md).
217+
202218
# Troubleshooting
203219

204220
In this section, known problems are listed with their solutions (if available):
@@ -211,6 +227,11 @@ If you encounter an error similar to:
211227
The filename specified was either not found on the MATLAB path or it contains unsupported characters.
212228

213229
Look up the solution in [this thread of the k-Wave forum](http://www.k-wave.org/forum/topic/error-reading-h5-files-when-using-binaries).
230+
231+
## 2. KeyError: 'time_series_data'
232+
233+
This is the error which will occur for ANY k-Wave problem. For the actual root of the problem, please either look above in
234+
the terminal for the source of the bug or run the scripts in Matlab to find it manually.
214235

215236
# Citation
216237

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ pipeline according to their specific use cases and tool requirements.
2020
:caption: SIMPA toolkit
2121

2222
intro_link
23-
contributing_link
23+
understanding_link.md
2424
bench_link.md
25+
contributing_link
2526

2627
===================================
2728

docs/source/understanding_link.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```{include} understanding_simpa.md
2+
```

docs/source/understanding_simpa.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Understanding SIMPA
2+
3+
## Understanding Tags
4+
5+
### What are Tags?
6+
7+
In SIMPA, Tags are identifiers used to specify and categorize various settings and components within the simulation.
8+
They act as keys in the configuration dictionaries, enabling a clear and organized way to define simulation parameters.
9+
Tags ensure that the configuration is modular, readable, and easy to manage.
10+
11+
### Purpose of Tags
12+
13+
- **Organization**: Tags help in structuring the configuration settings systematically.
14+
- **Flexibility**: They allow users to easily modify and extend configurations.
15+
- **Reusability**: Tags facilitate the reuse of settings across different simulations.
16+
17+
### How Tags Work
18+
19+
Tags are used to identify different components and their settings within the configuration dictionaries. Each component
20+
has a predefined set of tags associated with it. These tags are used to specify the parameters and properties of the
21+
components.
22+
23+
### What Tags are Available?
24+
25+
The list of Tags available in SIMPA is very extensive (see [simpa.utils](simpa.utils.rst) for full list), due to the
26+
level of customisation available to the user. To get to grips with the more commonly used Tags, we highly recommend
27+
consulting the [examples](simpa_examples.rst).
28+
29+
## Concept of Settings
30+
31+
Settings in SIMPA are configurations that control the behavior of the simulation. They are used to specify parameters
32+
and options for both the overall simulation and individual components of the simulation pipeline. Proper configuration
33+
of these settings is crucial for accurate and efficient simulations. This documentation provides a foundational
34+
understanding of these settings, allowing users to customize their simulations effectively. For more detailed
35+
information on specific settings and components, users are encouraged to refer to the source code and additional
36+
documentation provided within the SIMPA repository.
37+
38+
### Global Settings
39+
40+
Global settings apply to the entire simulation and include parameters that are relevant across multiple components.
41+
These settings typically encompass general simulation properties such as physical constants and overarching simulation
42+
parameters.
43+
44+
#### Example of Global Settings
45+
46+
- `Tags.SPACING_MM`: The voxel spacing in the simulation.
47+
- `Tags.GPU`: Whether there is a GPU available to perform the computation.
48+
- `Tags.WAVELENGTHS`: The wavelengths that will later be simulated.
49+
50+
### Component Settings
51+
52+
Component settings are specific to individual components within the simulation pipeline. Each component can have its own
53+
set of settings that determine how it behaves. These settings allow for fine-grained control over the simulation
54+
process, enabling customization and optimization for specific experimental conditions.
55+
56+
#### Difference Between Global and Component Settings
57+
58+
- **Scope**:
59+
- Global settings affect the entire simulation framework.
60+
- Component settings only influence the behavior of their respective components.
61+
62+
- **Usage**:
63+
- Global settings are defined once and applied universally.
64+
- Component settings are defined for each component individually, allowing for component-specific customization.
65+
66+
#### Implementation
67+
For a given simulation, the overall simulation settings will first be created from the global settings. Then, each
68+
components setting will be added. Overall, a dictionary instance will be created with all of the global settings as well
69+
as the components settings as sub-dictionaries.
70+
71+
## Available Component Settings
72+
73+
The following list describes the available component settings for various components in the SIMPA framework. Each component may have a unique set of settings that control its behavior.
74+
75+
### 1. Volume Creation
76+
77+
Settings for the volume creation component, which defines the method used to create the simulation volume; and therefore
78+
ultimately decides the properties of the simulation volume. It is added to the simulation settings using:
79+
[set_volume_creator_settings](../../simpa/utils/settings.py).
80+
81+
#### Examples of Volume Creation Settings
82+
- `Tags.STRUCTURES`: When using the model based volume creation adapter, sets the structures to be fill the volume.
83+
- `Tags.INPUT_SEGMENTATION_VOLUME`: When using the segmentation based volume creation adapter, the segmentation mapping
84+
will be specified under this tag.
85+
86+
### 2. Acoustic Model
87+
88+
Settings for the acoustic forward model component, which simulates the propagation of acoustic waves. It is added to the
89+
simulation settings using: [set_acoustic_settings](../../simpa/utils/settings.py).
90+
91+
#### Examples of Acoustic Settings
92+
- `Tags.KWAVE_PROPERTY_ALPHA_POWER`: The exponent in the exponential acoustic attenuation law of k-Wave.
93+
- `Tags.RECORDMOVIE`: If true, a movie of the k-Wave simulation will be recorded.
94+
95+
### 3. Optical Model
96+
97+
Settings for the optical model component, which simulates the propagation of light through the medium. It is added to
98+
the simulation settings using: [set_optical_settings](../../simpa/utils/settings.py).
99+
100+
#### Examples of Optical Settings
101+
- `Tags.OPTICAL_MODEL_NUMBER_PHOTONS`: The number of photons used in the optical simulation.
102+
- `Tags.LASER_PULSE_ENERGY_IN_MILLIJOULE`: The laser pulse energy used in the optical simulation.
103+
104+
### 4. Reconstruction model
105+
106+
Settings for the reconstruction model, which reconstructs the image from the simulated signals. It is added to the
107+
simulation settings using: [set_reconstruction_settings](../../simpa/utils/settings.py).
108+
109+
#### Examples of Reconstruction Settings
110+
111+
- `Tags.RECONSTRUCTION_BMODE_AFTER_RECONSTRUCTION`: Specifies whether an envelope detection should be performed after
112+
reconstruction.
113+
- `Tags.RECONSTRUCTION_PERFORM_BANDPASS_FILTERING`: Whether bandpass filtering should be applied or not.

simpa/core/simulation_modules/simulation_module_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def get_additional_flags(self) -> List[str]:
4141
if Tags.ADDITIONAL_FLAGS in self.component_settings:
4242
for flag in self.component_settings[Tags.ADDITIONAL_FLAGS]:
4343
cmd.append(str(flag))
44-
return cmd
44+
return cmd

simpa_tests/automatic_tests/test_additional_flags.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: 2021 Division of Intelligent Medical Systems, DKFZ
2+
# SPDX-FileCopyrightText: 2021 Janek Groehl
3+
# SPDX-License-Identifier: MIT
4+
15
import unittest
26
import numpy as np
37

@@ -9,17 +13,18 @@ class TestAdditionalFlags(unittest.TestCase):
913
def setUp(self) -> None:
1014
self.additional_flags = ('-l', '-a')
1115
self.settings = Settings()
12-
16+
1317
def test_get_cmd_mcx_reflectance_adapter(self):
1418
self.settings.set_optical_settings({
1519
Tags.OPTICAL_MODEL_BINARY_PATH: '.',
1620
Tags.ADDITIONAL_FLAGS: self.additional_flags
1721
})
18-
mcx_reflectance_adapter = MCXReflectanceAdapter(global_settings=self.settings)
22+
mcx_reflectance_adapter = MCXReflectanceAdapter(global_settings=self.settings)
1923
cmd = mcx_reflectance_adapter.get_command()
2024
for flag in self.additional_flags:
21-
self.assertIn(flag, cmd, f"{flag} was not in command returned by mcx reflectance adapter but was defined as additional flag")
22-
25+
self.assertIn(
26+
flag, cmd, f"{flag} was not in command returned by mcx reflectance adapter but was defined as additional flag")
27+
2328
def test_get_cmd_mcx_adapter(self):
2429
self.settings.set_optical_settings({
2530
Tags.OPTICAL_MODEL_BINARY_PATH: '.',
@@ -28,25 +33,29 @@ def test_get_cmd_mcx_adapter(self):
2833
mcx_adapter = MCXAdapter(global_settings=self.settings)
2934
cmd = mcx_adapter.get_command()
3035
for flag in self.additional_flags:
31-
self.assertIn(flag, cmd, f"{flag} was not in command returned by mcx adapter but was defined as additional flag")
32-
36+
self.assertIn(
37+
flag, cmd, f"{flag} was not in command returned by mcx adapter but was defined as additional flag")
38+
3339
def test_get_cmd_kwave_adapter(self):
3440
self.settings.set_acoustic_settings({
3541
Tags.ADDITIONAL_FLAGS: self.additional_flags
3642
})
3743
kwave_adapter = KWaveAdapter(global_settings=self.settings)
3844
cmd = generate_matlab_cmd("./matlab.exe", "simulate_2D.m", "my_hdf5.mat", kwave_adapter.get_additional_flags())
3945
for flag in self.additional_flags:
40-
self.assertIn(flag, cmd, f"{flag} was not in command returned by kwave adapter but was defined as additional flag")
46+
self.assertIn(
47+
flag, cmd, f"{flag} was not in command returned by kwave adapter but was defined as additional flag")
4148

4249
def test_get_cmd_time_reversal_adapter(self):
4350
self.settings.set_reconstruction_settings({
4451
Tags.ADDITIONAL_FLAGS: self.additional_flags
4552
})
4653
time_reversal_adapter = TimeReversalAdapter(global_settings=self.settings)
47-
cmd = generate_matlab_cmd("./matlab.exe", "time_reversal_2D.m", "my_hdf5.mat", time_reversal_adapter.get_additional_flags())
54+
cmd = generate_matlab_cmd("./matlab.exe", "time_reversal_2D.m", "my_hdf5.mat",
55+
time_reversal_adapter.get_additional_flags())
4856
for flag in self.additional_flags:
49-
self.assertIn(flag, cmd, f"{flag} was not in command returned by time reversal adapter but was defined as additional flag")
57+
self.assertIn(
58+
flag, cmd, f"{flag} was not in command returned by time reversal adapter but was defined as additional flag")
5059

5160

5261
if __name__ == '__main__':

0 commit comments

Comments
 (0)