Skip to content

Commit

Permalink
Some small tweaks to the text displayed on screen when executing loca…
Browse files Browse the repository at this point in the history
…l sims. Aimed to improve clarity
  • Loading branch information
txusser committed Apr 30, 2024
1 parent 0a593ee commit f7d7298
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
4 changes: 2 additions & 2 deletions configs/params/scanner/NeuroLF_BPET.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ num_aa_bins: 128
num_td_bins: 256
min_energy_window: 425
max_energy_window: 650
coincidence_window: 8 #falta por revisar
coincidence_window: 5 #falta por revisar
numberOfSubsets: 8
numberOfIterations: 128 #48
savingInterval: 2 #8
Expand All @@ -29,7 +29,7 @@ subiteration_interval: 4
x_dir_filter_FWHM: 1.30 #valor inicial 1.5 #rango aceptable 1.20 a 1.45
y_dir_filter_FWHM: 1.30 #valor inicial 1.5 #rango aceptable 1.20 a 1.45
z_dir_filter_FWHM: 0.50 #valor inicial 1.5
psf_value: 0.65
psf_value: 0
add_noise: 0
max_segment: 47
zoomFactor: 1.264
Expand Down
2 changes: 1 addition & 1 deletion configs/params/scanner/discovery_st.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ subiteration_interval: 4
x_dir_filter_FWHM: 1.5
y_dir_filter_FWHM: 1.5
z_dir_filter_FWHM: 3
psf_value: 1.125
psf_value: 0
add_noise: 0
max_segment: 23
zoomFactor: 1.55
Expand Down
1 change: 1 addition & 0 deletions simpet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

import sys
import shutil
from pathlib import Path
Expand Down
37 changes: 27 additions & 10 deletions src/simset/simset_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def __init__(
def run(self):
processes = []

print("\nLaunching simulation with %d divisions" % self.divisions)
print('------------------------------------------------------------')
print('Scanner: %s' % self.scanner.get("scanner_name"))
print('Activity map: %s' % self.act_map)
print('Attenuation map: %s' % self.att_map)
print('Dose: %s mCi' % self.sim_dose)
print('Acquisition time: %s seconds' % self.sim_time)
print('------------------------------------------------------------')

for division in range(self.divisions):
division_dir = join(self.output_dir, "division_" + str(division))
os.makedirs(division_dir)
Expand All @@ -93,7 +102,6 @@ def run(self):
p.start()
time.sleep(5)

print(" ")

for process in processes:
process.join()
Expand All @@ -103,9 +111,8 @@ def run(self):
self.simulation_postprocessing()

def run_simset_simulation(self, sim_dir):
log_file = join(sim_dir, "logging.log")

print("Starting simulation for %s" % os.path.basename(sim_dir))
log_file = join(sim_dir, "logging.log")

act, act_data = tools.nib_load(self.act_map)

Expand All @@ -127,15 +134,14 @@ def run_simset_simulation(self, sim_dir):
# If Sampling Photons is 0, importance sampling is deactivated, so we use photons as the input.
if self.add_randoms == 1:
sim_photons = 0
print("WARNING: add_randoms=1, so simulation is forced to realistic noise")
print("Importance sampling is also being deactivated")
print("All these means the simulation can take very long...")
needed_sims = 1

elif self.s_photons == 0 and self.photons != 0:
sim_photons = self.photons / self.divisions

needed_sims = 1
else:
sim_photons = self.s_photons
needed_sims = 3

sim_time = float(self.sim_time) / self.divisions

Expand All @@ -150,7 +156,14 @@ def run_simset_simulation(self, sim_dir):
)
my_log = join(sim_dir, "simset_s0_init.log")

print("Running first simulation without importance sampling...")
print("Running first simulation without importance sampling...(1/%s simulations needed for %s)" %
(needed_sims, os.path.basename(sim_dir)))

if self.add_randoms == 1:
print("WARNING: add_randoms=1, so simulation is forced to realistic noise")
print("Importance sampling is also being deactivated")
print("All these means the simulation can take very long...")

command = "%s/bin/phg %s > %s" % (self.simset_dir, my_phg, my_log)
tools.osrun(command, log_file)

Expand Down Expand Up @@ -182,7 +195,9 @@ def run_simset_simulation(self, sim_dir):
)
my_log = join(sim_dir, "simset_s0.log")

print("Running second sampling simulation to calculate photons...")
print("Running second sampling simulation to calculate photons...(2/%s simulations needed for %s)" %
(needed_sims, os.path.basename(sim_dir)))

command = "%s/bin/phg %s > %s" % (self.simset_dir, my_phg, my_log)
tools.osrun(command, log_file)
w_quotient = read_ws_from_simset_log(my_log)
Expand All @@ -205,7 +220,9 @@ def run_simset_simulation(self, sim_dir):
)
my_log = join(sim_dir, "simset_s1.log")

print("Running full simulation with importance sampling...")
print("Running third sampling simulation to calculate photons...(3/%s simulations needed for %s)" %
(needed_sims, os.path.basename(sim_dir)))

command = "%s/bin/phg %s > %s" % (self.simset_dir, my_phg, my_log)
tools.osrun(command, log_file)

Expand Down

0 comments on commit f7d7298

Please sign in to comment.