Skip to content

Commit 6825bc8

Browse files
committed
update option name
1 parent 4048972 commit 6825bc8

8 files changed

Lines changed: 36 additions & 21 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ opengate_temporaire
9494
/opengate/tests/src/test030_save
9595
/opengate/tests/src/test_log*
9696
/opengate/tests/src/save_tests
97+
/opengate/tests/src/external/coresi/logs/*
98+
/opengate/tests/src/external/coresi/checkpoi*
9799

98100
/opengate/data/isomeric_transition/save
99101
/opengate/data/isomeric_transition/save2

core/opengate_core/opengate_lib/GateFluenceActor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void GateFluenceActor::InitializeUserInfo(py::dict &user_info) {
8787
// IMPORTANT: call the base class method
8888
GateVActor::InitializeUserInfo(user_info);
8989
fTranslation = DictGetG4ThreeVector(user_info, "translation");
90-
fSecondaries = DictGetBool(user_info, "images_for_scattering_processes");
90+
fSecondaries = DictGetBool(user_info, "score_by_process");
9191
}
9292

9393
void GateFluenceActor::InitializeCpp() {

docs/source/user_guide/user_guide_reference_actors.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ This actor scores the particle fluence on a voxel grid, essentially by counting
323323
fluence_actor.hit_type = "random"
324324
325325
326-
In addition, it is possible to generate fluence maps for individual scattering processes (Compton and Rayleigh), as well as a combined map including both processes. These maps are created as follows: if the incoming particle is a gamma photon and its last interaction was either Compton or Rayleigh scattering, the counts (and optionally the photon energy) are recorded in the corresponding scattering-process maps. At present, pair production is not yet included as a recordable process. This actor is also compatible with the FreeFlightAngularAcceptance variance reduction technique. To enable the recording of these additional maps, simply set the following boolean to True:
326+
In addition, it is possible to generate separate fluence maps resolving the particle's tracking state and underlying physics processes (`primaries`, `secondaries`, `compton`, and `rayleigh`). These maps are created as follows: particles originating directly from the source without interacting are recorded as `primaries`, while all others are recorded as `secondaries`. Furthermore, if the incoming particle is a gamma photon and its last interaction was either Compton or Rayleigh scattering, the counts (and optionally the photon energy) are also recorded in the corresponding scattering-process maps. At present, pair production is not yet included as a recordable process. This actor is also compatible with the FreeFlightAngularAcceptance variance reduction technique. To enable the recording of these additional maps, simply set the following boolean to True:
327327

328328
.. code-block:: python
329329
330-
fluence_actor.images_for_scattering_processes = True
330+
fluence_actor.score_by_process = True
331331
332332
The activation of the squared counts (and energies) and their associated uncertainty maps is handled automatically, according to the global settings defined by the user for counts and energy scoring.
333333

opengate/actors/doseactors.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,9 +1629,9 @@ class FluenceActor(VoxelDepositActor, g4.GateFluenceActor):
16291629
"""
16301630

16311631
# hints for IDE
1632-
images_for_scattering_processes: bool
1632+
score_by_process: bool
16331633
user_info_defaults = {
1634-
"images_for_scattering_processes": (
1634+
"score_by_process": (
16351635
False,
16361636
{
16371637
"doc": "If yes, realise imgs where scattering processes are also recorded separately",
@@ -1919,7 +1919,7 @@ def initialize(self):
19191919

19201920
VoxelDepositActor.initialize(self)
19211921
self.check_user_input()
1922-
secondary_flag = self.user_info.images_for_scattering_processes
1922+
secondary_flag = self.user_info.score_by_process
19231923
self.user_output.counts_with_uncertainty.set_active(True, item=0)
19241924
if secondary_flag:
19251925
for user_output_images in self.list_of_output_counts:
@@ -2025,7 +2025,7 @@ def BeginOfRunActionMasterThread(self, run_index):
20252025
self.cpp_counts_image,
20262026
self.cpp_counts_squared_image,
20272027
)
2028-
if self.user_info.images_for_scattering_processes:
2028+
if self.user_info.score_by_process:
20292029
for process, img, squared_img in zip(
20302030
self.list_of_processes,
20312031
self.list_of_counts_images,
@@ -2049,7 +2049,7 @@ def BeginOfRunActionMasterThread(self, run_index):
20492049
self.cpp_energy_image,
20502050
self.cpp_energy_squared_image,
20512051
)
2052-
if self.user_info.images_for_scattering_processes:
2052+
if self.user_info.score_by_process:
20532053
for process, img, squared_img in zip(
20542054
self.list_of_processes,
20552055
self.list_of_energy_images,
@@ -2068,7 +2068,6 @@ def BeginOfRunActionMasterThread(self, run_index):
20682068
g4.GateFluenceActor.BeginOfRunActionMasterThread(self, run_index)
20692069

20702070
def EndOfRunActionMasterThread(self, run_index):
2071-
20722071
self.fetch_from_cpp_image(
20732072
"counts_with_uncertainty",
20742073
run_index,
@@ -2079,7 +2078,7 @@ def EndOfRunActionMasterThread(self, run_index):
20792078
self.user_output.counts_with_uncertainty.store_meta_data(
20802079
run_index, number_of_samples=self.NbOfEvent
20812080
)
2082-
if self.user_info.images_for_scattering_processes:
2081+
if self.user_info.score_by_process:
20832082
for process, img, squared_img, output in zip(
20842083
self.list_of_processes,
20852084
self.list_of_counts_images,
@@ -2109,7 +2108,7 @@ def EndOfRunActionMasterThread(self, run_index):
21092108
self.user_output.energy_with_uncertainty.store_meta_data(
21102109
run_index, number_of_samples=self.NbOfEvent
21112110
)
2112-
if self.user_info.images_for_scattering_processes:
2111+
if self.user_info.score_by_process:
21132112
for process, img, squared_img, output in zip(
21142113
self.list_of_processes,
21152114
self.list_of_energy_images,

opengate/tests/src/actors/test067_cbct_fluence_actor_mt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
# print output statistics
9191
print(stats)
92-
out_path = detector_actor.get_output_path()
92+
out_path = detector_actor.get_output_path("counts")
9393

9494
# check images
9595
is_ok = utility.assert_images(

opengate/tests/src/actors/test099_fluence_actor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ def img_generation_from_phsp(nb_pixel_x, nb_pixel_y, dim_x, dim_y, df, type="E")
164164
type=type,
165165
)
166166
std_dev_tab = std_dev_img_calculation(source.n, tab, s_tab)
167-
rel_err_tab_phsp = np.divide(std_dev_tab, (tab / source.n))
167+
rel_err_tab_phsp = np.divide(
168+
std_dev_tab,
169+
(tab / source.n),
170+
out=np.zeros_like(std_dev_tab),
171+
where=(tab != 0),
172+
)
168173

169174
if type == "E":
170175
rel_err_img = itk.imread(output_path / "test099_energy_uncertainty.mhd")

opengate/tests/src/actors/test099_fluence_actor_processes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def img_generation_from_phsp(
143143

144144
# add fluence actor
145145
fluence_actor = sim.add_actor("FluenceActor", "fluence_actor")
146-
fluence_actor.images_for_scattering_processes = True
146+
fluence_actor.score_by_process = True
147147
# let the actor score other quantities additional to edep (default)
148148
fluence_actor.counts_uncertainty.active = True
149149
fluence_actor.counts_squared.active = True
@@ -208,8 +208,12 @@ def img_generation_from_phsp(
208208
process=process,
209209
)
210210
std_dev_phsp = std_dev_img_calculation(source.n, img_phsp, img_squared_phsp)
211-
img_uncertainty_phsp = np.divide(std_dev_phsp, (img_phsp / source.n))
212-
img_uncertainty_phsp[np.isnan(img_uncertainty_phsp)] = 0
211+
img_uncertainty_phsp = np.divide(
212+
std_dev_phsp,
213+
(img_phsp / source.n),
214+
out=np.zeros_like(std_dev_phsp),
215+
where=(img_phsp != 0),
216+
)
213217
dict_comp[f"{string}"] = [img_fluence, img_phsp]
214218
dict_comp[f"{string}_squared"] = [img_squared_fluence, img_squared_phsp]
215219
dict_comp[f"{string}_uncertainty"] = [

opengate/tests/src/actors/test099_fluence_actor_processes_ffaa.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def img_generation_from_phsp(
145145

146146
# add fluence actor
147147
fluence_actor = sim.add_actor("FluenceActor", "fluence_actor")
148-
fluence_actor.images_for_scattering_processes = True
148+
fluence_actor.score_by_process = True
149149
# let the actor score other quantities additional to edep (default)
150150
fluence_actor.counts_uncertainty.active = True
151151
fluence_actor.counts_squared.active = True
@@ -227,8 +227,12 @@ def img_generation_from_phsp(
227227
process=process,
228228
)
229229
std_dev_phsp = std_dev_img_calculation(source.n, img_phsp, img_squared_phsp)
230-
img_uncertainty_phsp = np.divide(std_dev_phsp, (img_phsp / source.n))
231-
img_uncertainty_phsp[np.isnan(img_uncertainty_phsp)] = 0
230+
img_uncertainty_phsp = np.divide(
231+
std_dev_phsp,
232+
(img_phsp / source.n),
233+
out=np.zeros_like(std_dev_phsp),
234+
where=(img_phsp != 0),
235+
)
232236
dict_comp[f"{string}"] = [img_fluence, img_phsp]
233237
dict_comp[f"{string}_squared"] = [img_squared_fluence, img_squared_phsp]
234238
dict_comp[f"{string}_uncertainty"] = [
@@ -238,9 +242,10 @@ def img_generation_from_phsp(
238242

239243
l_bool = []
240244
for key, elem in dict_comp.items():
241-
diff = np.round((elem[0] - elem[1]) / elem[1])
245+
diff = np.divide(
246+
elem[0] - elem[1], elem[1], out=np.zeros_like(elem[0]), where=(elem[1] != 0)
247+
)
242248
diff = np.round(diff, decimals=5)
243-
diff[np.isnan(diff)] = 0
244249
is_ok = np.all(diff == 0)
245250
if not is_ok:
246251
print(key)

0 commit comments

Comments
 (0)