Skip to content

Commit

Permalink
Refactored code and optimized inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
txusser committed Feb 3, 2024
1 parent 26ea9d5 commit f31c4b7
Show file tree
Hide file tree
Showing 15 changed files with 1,300 additions and 1,305 deletions.
20 changes: 10 additions & 10 deletions Params_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ sim_type: "SimSET" # SimSET, STIR or GATE (only SimSET working)
# Run parameters
do_simulation: 1 # Set to 0 to reconstruction previous simulation
do_reconstruction: 1 # Set to 0 to generate adq data only
divisions: 8 # Number os subprocesses for parallel simulation
divisions: 6 # Number os subprocesses for parallel simulation


# PET system
scanner: "Vereos" # Scanner Model (Vereos, Siemens_mCT, Discovery_ST, Discovery_STE, GE_Advance)
model_type: "simple_pet" # SimSET Model (simple_pet, cylindrical)
scanner: "Discovery_ST" # Scanner Model (Vereos, Siemens_mCT, Discovery_ST, Discovery_STE, GE_Advance)
model_type: "cylindrical" # SimSET Model (simple_pet, cylindrical)


# Input and output directories
patient_dirname: "example_input_dir" # Name of the directory in Data where phantoms are located
output_dir: "example_output_dir" # Name of the Results Dir
patient_dirname: "test_brain_FDG" # Name of the directory in Data where phantoms are located
output_dir: "test_brain" # Name of the Results Dir


# Variables needed for single simulation
act_map: "example_act.hdr" # Activity map name
att_map: "example_att.hdr" # Attenuation map name
center_slice: 153 # The slice number to be placed on the center of the scanner. If 0, automatically, the middle slice will be used
act_map: "S1_actMap.nii" # Activity map name
att_map: "S1_attMap.nii" # Attenuation map name
center_slice: 153 # The slice number to be placed on the center of the scanner. If 0, automatically, the middle slice will be used


# Variables needed for whole_body simulation
z_min: 75 # Only for wholebody simulations (start of the acquisition, slice)
z_max: 316 # Only for wholebody simulations (end of the acquisition, slice).
z_min: 283 # Only for wholebody simulations (start of the acquisition, slice)
z_max: 584 # Only for wholebody simulations (end of the acquisition, slice).
# We calculate the number of beeds based on (z_max - z_min) and the scanner FOV.


Expand Down
2 changes: 1 addition & 1 deletion Params_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ output_dir: "Test" # Name of the Results Dir
# Variables needed for single simulation
act_map: "act.hdr"
att_map: "att.hdr"
center_slice: 7 # The slice number to be placed on the center of the scanner. If 0, automatically, the half of the slices will be calculated and used
center_slice: 7 # The slice number to be placed on the center of the scanner. If 0, automatically, the half of the slices will be calculated and used


# Variables needed for whole_body simulation
Expand Down
10 changes: 5 additions & 5 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Directories to the necesary binaries
dir_stir: "/home/jesus/simpet/include/STIR/install"
dir_simset: "/home/jesus/simpet/include/SimSET/2.9.2"
matlab_mcr_path: "/media/usuario3/HDD/SPM_standalone/MCR/v713"
spm_path: "/media/usuario3/HDD/SPM_standalone/spm12"
dir_stir: "/mnt/c/Users/jesus/Work/repos/simpet/include/STIR/install"
dir_simset: "/mnt/c/Users/jesus/Work/repos/simpet/include/SimSET"
matlab_mcr_path: "/media/usuario3/HDD/SPM_standalone/MCR/v713"
spm_path: "/media/usuario3/HDD/SPM_standalone/spm12"
dir_data_path: ""
dir_results_path: ""

Expand All @@ -14,7 +14,7 @@ stratification: "true"
forced_detection: "true"
forced_non_absortion: "true"
acceptance_angle: 90.0
positron_range: "true"
positron_range: "true"
non_colinearity: "true"
minimum_energy: 350.0
weight_window_ratio: 1.0
Expand Down
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Don't run this script if you think all the needed dependencies are already fulfilled.
"""
import os
from os.path import join, basename, exists
import shutil
from multiprocessing import cpu_count
from os.path import join, exists


def rsystem(command):
Expand Down Expand Up @@ -44,7 +44,6 @@ def install_simset(simset_dir, log_file):

os.chdir(simset_dir)


makefile = join(simset_dir, 'make.files', 'simset.make')
newmakefile = join(simset_dir, 'make.files', 'simset.make.new')

Expand Down Expand Up @@ -216,15 +215,15 @@ def verify_test_simulation(simpet_dir):
import numpy as np

results_dir = join(simpet_dir, 'Results', 'Test', 'SimSET_Sim_Discovery_ST', 'division_0')

checks = ['trues.hdr', 'scatter.hdr', 'randoms.hdr']

for i in checks:
file_ = join(results_dir, i)
if exists(file_):
img_d = nib.load(file_).get_fdata()
counts = np.sum(img_d)
print("Counts in %s: %s" % (i,counts))
print("Counts in %s: %s" % (i, counts))

else:
raise Exception('Failed to build %s' % i)
Expand All @@ -239,6 +238,7 @@ def verify_test_simulation(simpet_dir):
else:
raise Exception('Failed to reconstruct %s' % i)


# Setup run lines
simpet_dir = os.getcwd()
log_file = join(simpet_dir, 'log_setup.txt')
Expand All @@ -250,7 +250,6 @@ def verify_test_simulation(simpet_dir):
os.makedirs(dest_dir)
os.chdir(dest_dir)


simset_dir = join(dest_dir, "SimSET")
install_simset(simset_dir, log_file)
verify_simset_install(simset_dir)
Expand All @@ -273,5 +272,5 @@ def verify_test_simulation(simpet_dir):

verify_test_simulation(simpet_dir)

print("\nNice! It seems that we are good to go. Consider adding the lines in simpet_paths.sh to your .bashrc. Enjoy SimPET!.")

print(
"\nNice! It seems that we are good to go. Consider adding the lines in simpet_paths.sh to your .bashrc. Enjoy SimPET!.")
Loading

0 comments on commit f31c4b7

Please sign in to comment.