Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
url = https://github.com/UCL/STIR
[submodule "submodules/simset_simpet"]
path = submodules/simset_simpet
url = https://github.com/txusser/simset_simpet.git
url = https://github.com/arnaufme8/simset_simpet.git
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The SIMPET project is intended to allow to setup and launch MC simulation on a s
- Apply the BrainViset procedure to obtain realistic Activity and Attenuation maps.
- Run Analytic simulations using STIR simulation procedure and MC simulation using SimSET.

# Installtion
# Installation

1. Install [Git LFS](https://git-lfs.com/).
2. Clone the repository by adding the `--recurse-submodules` flag:
Expand Down Expand Up @@ -52,6 +52,7 @@ Sometimes, even activating the virtual environemnt, the shell will use the wide
```
make install
```
_NOTE:_ At the moment, to install SimPET you need to have sudo available in your computer. If you don't (e.g., when installing on a HPC), you can make use of the makefile that does not require sudo: ```makefile-withoutsudo```. To use it, simply remove or change the name of ```makefile```, and rename the file ```makefile-withoutsudo``` to ```makefile```. This will allow the installation without root privileges.

7. Decompress dummy data with:
```
Expand Down Expand Up @@ -277,8 +278,9 @@ See [SimSET](https://depts.washington.edu/simset/html/simset_main.html) document

#### Attenuation correction

- **analytical_att_correction**: performed by SimSET calcattenuation.
- **analytical_att_correction**: performed by SimSET calcattenuation. (_NOTE: obsolete at the moment and will be removed in further updates_).
- **stir_recons_att_corr**: performed in STIR by entering the att image as a normalization map.
- **attenuation_mode**: it has three options. 0 (no attenuation), 1 (attenuation by SimSET calcattenuation) or 2 (attenuation by STIR computation of the ACFs).

#### Scatter Correction

Expand Down Expand Up @@ -316,11 +318,13 @@ See [SimSET](https://depts.washington.edu/simset/html/simset_main.html) document

- Jesús Silva-Rodríguez
- Pablo Aguiar
- Aida Ninyerola-Baizan
- Aida Niñerola-Baizán
- Jeremiah Poveda
- Francisco Javier López-González
- Nikos Efthimiou
- Arnau Farre
- Arnau Farré-Melero
- Claudia Dominguez-Borrero


# References

Expand Down
6 changes: 4 additions & 2 deletions configs/params/scanner/discovery_st.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stir_scatt_corr_smoothing: 0
stir_scatt_simulation: 0
analytic_randoms_corr_factor: 0.2
stir_randoms_corr_smoothing: 0
recons_type: "OSEM3D"
recons_type: "OSEM3D" #"FBP3D" #"OSEM3D"
inter_iteration_filter: 0
subiteration_interval: 4
x_dir_filter_FWHM: 1.5
Expand All @@ -32,7 +32,9 @@ z_dir_filter_FWHM: 3
psf_value: 0
add_noise: 0
max_segment: 23
zoomFactor: 1.55
zoomFactor: 1 #For brain: 1.55
xyOutputSize: 128
zOutputSize: 47
zOutputVoxelSize: 3.27

attenuation_mode: 2 #0: no attenuation, 1: attenuation with SimSET, 2: attenuation with STIR
42 changes: 42 additions & 0 deletions configs/params/scanner/siemens_quadra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
scanner_name: "Siemens Quadra"
simset_material: 18
average_doi: 0.7
scanner_radius: 41.0
num_rings: 320 #Real: 320, With module gaps: 323
axial_fov: 106
z_crystal_size: 0.32 #cm
transaxial_crystal_size: 0.32 #cm
crystal_thickness: 2 #cm
energy_resolution: 9
num_aa_bins: 399
num_td_bins: 520
min_energy_window: 435
max_energy_window: 585
coincidence_window: 4.7 #ns

numberOfSubsets: 7
numberOfIterations: 14
savingInterval: 7
analytical_att_correction: 0
stir_recons_att_corr: 0
analytic_scatt_corr_factor: 0.15
stir_scatt_corr_smoothing: 0
stir_scatt_simulation: 0
analytic_randoms_corr_factor: 0.2
stir_randoms_corr_smoothing: 0
recons_type: "OSEM3D" #Options: "FBP2D", "FBP3D", "OSEM2D", "OSEM3D"
inter_iteration_filter: 0
subiteration_interval: 4
x_dir_filter_FWHM: 1.5
y_dir_filter_FWHM: 1.5
z_dir_filter_FWHM: 3
psf_value: 0
add_noise: 0

max_segment: 85 #Reduced protocol: 85; Full protocol: 319 or 322
zoomFactor: 1
xyOutputSize: 220
zOutputSize: 645
zOutputVoxelSize: 1.65

attenuation_mode: 0 #0: no attenuation, 1: attenuation with SimSET, 2: attenuation with STIR
10 changes: 6 additions & 4 deletions configs/params/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ patient_dirname: "test_image"
act_map: "act.hdr"
att_map: "att.hdr"
output_dir: "test_image"
center_slice: 7
center_slice: 0
total_dose: 0.1
simulation_time: 30
sampling_photons: 0
photons: 0
add_randoms: 1
phglistmode: 0
detlistmode: 1
maximumIteration: 1

listmode: True # TODO: to unify both listmodes to only the necessary.
phglistmode: 1 #MUST BE ACTIVATED IF listmode.
detlistmode: 0 #At the moment unused, but may be used in the future.
maximumIteration: 1 #Unused at the moment.
231 changes: 231 additions & 0 deletions makefile-withoutsudo
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
SHELL := /bin/bash
TMPDIR := /tmp
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
ASSETS_DIR := ${ROOT_DIR}assets
INCLUDE_DIR := ${ROOT_DIR}include
SUBMODULES_DIR := ${ROOT_DIR}submodules

.PHONY: install-simset check-simset clean-simset
.PHONY: install-stir check-stir clean-stir
.PHONY: install-resources check-resources clean-resources
.PHONY: config-git clean-git smudge-filer config-paths clean-paths
.PHONY: dummy-data install clean help

SIMSET_SUBMODULE_DIR = ${ROOT_DIR}/submodules/simset_simpet
SIMSET_DEST_DIR = ${INCLUDE_DIR}/SimSET
SIMSET_PATH = ${SIMSET_DEST_DIR}/2.9.2
SIMSET_BIN = ${SIMSET_PATH}/bin
SIMSET_LIB = ${SIMSET_PATH}/lib
SIMSET_MKALL = ${SIMSET_PATH}/make_all.sh
SIMSET_MKFILE = ${SIMSET_PATH}/make.files/simset.make

install-simset:
if [ ! -d ${SIMSET_DEST_DIR} ]; then \
mkdir -p ${SIMSET_PATH} ;\
cp -r ${SIMSET_SUBMODULE_DIR}/* ${SIMSET_PATH} ;\
sed -i 's/^\(SIMSET_PATH = \).*$$/\1$(subst /,\/,${SIMSET_PATH})/' ${SIMSET_MKFILE} ;\
cd ${SIMSET_PATH} && mkdir -p ${SIMSET_LIB} && bash ${SIMSET_MKALL} ;\
else \
echo "${SIMSET_DEST_DIR} already exists, run clean-simset if you really want to remove it (you will have to intall SimSET again.)" ;\
fi

SIMSET_TAR = ${ASSETS_DIR}/phg.2.9.2.tar.Z
SIMSET_STIR_PATCH = ${ASSETS_DIR}/simset_for_stir.patch

install-canonic-simset: ${SIMSET_TAR}
if [ ! -d ${SIMSET_DEST_DIR} ]; then \
mkdir -p ${SIMSET_DEST_DIR} && tar -xvf "${SIMSET_TAR}" --directory=${SIMSET_DEST_DIR} ;\
cd ${SIMSET_DEST_DIR} && patch -s -p0 < ${SIMSET_STIR_PATCH} ;\
sed -i 's/^\(SIMSET_PATH = \).*$$/\1$(subst /,\/,${SIMSET_PATH})/' ${SIMSET_MKFILE} ;\
cd ${SIMSET_PATH} && mkdir -p ${SIMSET_LIB} && bash ${SIMSET_MKALL} ;\
else \
echo "${SIMSET_DEST_DIR} already exists, run clean-simset if you really want to remove it (you will have to intall SimSET again.)" ;\
fi

check-simset:
declare -a simset_files=(addrandoms bin calcattenuation combinehist makeindexfile phg timesort) ;\
for file in "$${simset_files[@]}"; do \
if [ ! -f "${SIMSET_BIN}/$${file}" ]; then \
echo "${SIMSET_BIN}/$${file} does not exists, check your installation." ;\
else \
echo "${SIMSET_BIN}/$${file} exists." ;\
fi ;\
done

clean-simset:
rm -rf ${SIMSET_DEST_DIR}

SIMSET_SRC = ${SIMSET_PATH}/src
SIMSET_LIBSIMSET = ${SIMSET_LIB}/libsimset.so
STIR_DIR = ${SUBMODULES_DIR}/STIR/STIR
STIR_BUILD_DIR = ${SUBMODULES_DIR}/STIR/build
STIR_INSTALL_DIR = ${SUBMODULES_DIR}/STIR/install
STIR_INSTALL_BIN = ${STIR_INSTALL_DIR}/bin
STIR_MKFILE = ${STIR_BUILD_DIR}/CMakeCache.txt
STIR_FINAL_DEST_DIR = ${INCLUDE_DIR}/STIR
NPROC = $(shell nproc)

install-stir: install-simset ${STIR_DIR}
if [ ! -d ${STIR_FINAL_DEST_DIR} ]; then \
mkdir -p ${STIR_BUILD_DIR} ${STIR_INSTALL_DIR} ${STIR_FINAL_DEST_DIR} ;\
cd ${STIR_BUILD_DIR} && cmake ${STIR_DIR} ;\
sed -i \
-e 's/^\(BUILD_SWIG_PYTHON\).*$$/\1:BOOL=OFF/' \
-e 's/^\(CMAKE_INSTALL_PREFIX\).*$$/\1:PATH=$(subst /,\/,${STIR_INSTALL_DIR})/' \
-e 's/^\(SIMSET_INCLUDE_DIRS\).*$$/\1:PATH=$(subst /,\/,${SIMSET_SRC})/' \
-e 's/^\(SIMSET_LIBRARY\).*$$/\1:FILEPATH=$(subst /,\/,${SIMSET_LIBSIMSET})/' \
-e 's/^\(STIR_OPENMP\).*$$/\1:BOOL=ON/' \
${STIR_MKFILE} ;\
cmake ${STIR_DIR} ;\
make -s -j${NPROC} ;\
make install ;\
mv ${STIR_BUILD_DIR} ${STIR_INSTALL_DIR} ${STIR_FINAL_DEST_DIR} ;\
else \
echo "${STIR_FINAL_DEST_DIR} already exists, run clean-stir if you really want to remove it (you will have to intall STIR again)." ;\
fi

check-stir:
declare -a stir_files=(FBP2D FBP3DRP forward_project lm_to_projdata OSMAPOSL zoom_image) ;\
for file in "$${stir_files[@]}"; do \
if [ ! -f "${STIR_FINAL_DEST_DIR}/install/bin/$${file}" ]; then \
echo "${STIR_FINAL_DEST_DIR}/install/bin/$${file} does not exists, check your installation." ;\
else \
echo "${STIR_FINAL_DEST_DIR}/install/bin/$${file} exists." ;\
fi ;\
done

clean-stir:
rm -rf ${STIR_FINAL_DEST_DIR}

RESOURCES_ZIP = ${ASSETS_DIR}/fruitcake.zip
RESOURCES_TMP = ${TMPDIR}/resources

install-resources: ${RESOURCES_ZIP}
mkdir -p ${RESOURCES_TMP} ${INCLUDE_DIR} && unzip -o ${RESOURCES_ZIP} -d ${RESOURCES_TMP} ;\
declare -a resources=(fruitcake format_converters) ;\
for rce in "$${resources[@]}"; do \
include_path="${INCLUDE_DIR}/$${rce}" ;\
tmp_path="${RESOURCES_TMP}/$${rce}" ;\
if [ ! -d $${include_path} ]; then \
mv $${tmp_path} ${INCLUDE_DIR} ;\
chmod -R +x $${include_path} ;\
else \
echo "$${include_path} already exists, run make clean-resources in order to clean resources installation (fruitcake will be removed as well)." ;\
fi ;\
done ;\
rm -rf ${RESOURCES_TMP}

check-resources:
declare -a resources_paths=(${FRUITCAKE_PATH} ${FORMAT_CONVERTERS_PATH}) ;\
for path in "$${resources_paths[@]}"; do \
if [ ! -d "$${path}" ]; then \
echo "$${path} does not exists, clean fruitcake and format_converters with clean-resources and run install-resources." ;\
else \
echo "$${path} exists." ;\
fi ;\
done

clean-resources:
rm -rf ${INCLUDE_DIR}/fruitcake ${INCLUDE_DIR}/format_converters

config-git:
git config --local filter.config-test.smudge ${ROOT_DIR}scripts/smudge-config_test.sh
git config --local filter.config-test.clean ${ROOT_DIR}scripts/clean-config_test.sh
chmod +x -R ${ROOT_DIR}scripts

clean-git:
git config --local --unset filter.config-test.smudge
git config --local --unset filter.config-test.clean

smudge-filter:
rm -f ${ROOT_DIR}configs/config.yaml 2> /dev/null
git checkout HEAD -- ${ROOT_DIR}configs/config.yaml

FRUITCAKE_PATH = ${INCLUDE_DIR}/fruitcake
FRUITCAKE_BIN = ${FRUITCAKE_PATH}/bin
FRUITCAKE_LIB = ${FRUITCAKE_PATH}/book/lib
FORMAT_CONVERTERS_PATH = ${INCLUDE_DIR}/format_converters

config-paths:
touch "$${HOME}"/.bashrc ;\
declare -a simpet_paths=( \
'export PATH=${FRUITCAKE_BIN}:$$PATH' \
'export LD_LIBRARY_PATH=${FRUITCAKE_LIB}:$$LD_LIBRARY_PATH' \
'export PATH=${FORMAT_CONVERTERS_PATH}:$$PATH' \
) ;\
for path in "$${simpet_paths[@]}"; do \
grep -qxF "$${path}" "$${HOME}"/.bashrc || echo "$${path}" >> "$${HOME}"/.bashrc ;\
done

clean-paths:
touch "$${HOME}/.bashrc"
sed -i \
-e '/export PATH=$(subst /,\/,${FRUITCAKE_BIN}):$$PATH/d' \
-e '/export LD_LIBRARY_PATH=$(subst /,\/,${FRUITCAKE_LIB}):$$LD_LIBRARY_PATH/d' \
-e '/export PATH=$(subst /,\/,${FORMAT_CONVERTERS_PATH}):$$PATH/d' \
"$${HOME}/.bashrc"

DATA_DIR = ${ROOT_DIR}Data
DATA_ZIP = ${ASSETS_DIR}/Data.zip

dummy-data: ${DATA_ZIP}
if [ ! -d "${DATA_DIR}" ]; then \
mkdir -p ${DATA_DIR} && unzip -o ${DATA_ZIP} -d ${ROOT_DIR} ;\
else \
echo "${DATA_DIR} already exists, remove it manually." ;\
fi

install:
${MAKE} \
install-simset \
check-simset \
install-stir \
check-stir \
install-resources \
check-resources \
config-paths \

clean:
${MAKE} \
clean-simset \
clean-stir \
clean-resources

help:
@echo "Help:"
@echo " - install-simset: Install tweaked version of SimSET.
@echo ""
@echo " - install-canonic-simset: Install non-tweaked version of SimSET with STIR patch at directory ${SIMSET_DEST_DIR}."
@echo ""
@echo " - check-simset: Check that SimSET binaries exist."
@echo ""
@echo " - clean-simset: Clean SimSET installation (removes ${SIMSET_DEST_DIR} directory)."
@echo ""
@echo " - install-stir: Install STIR at directory $(shell dirname ${STIR_DIR}), install-simset is a prerequisite. Set NPROC=n to use n CPU cores in compilation."
@echo ""
@echo " - check-stir: Check that STIR binaries exist."
@echo ""
@echo " - clean-stir: Clean STIR installation removing ${STIR_INSTALL_DIR} and ${STIR_BUILD_DIR} directories."
@echo ""
@echo " - install-resources: Decompress ${RESOURCES_ZIP} and move fruitcake and format_converters to ${INCLUDE_DIR}"
@echo ""
@echo " - check-resources: Checks that fruitcake and format_converters are in ${INCLUDE_DIR}."
@echo ""
@echo " - clean-resources: Remove fruitcake and format_converters from ${INCLUDE_DIR}."
@echo ""
@echo " - config-git: Add project filter drivers to local git configuration and make them executable."
@echo ""
@echo " - clean-git: Remove project filter drivers from local git configuration."
@echo ""
@echo " - smudge-filer: Apply smudge filter to config file (updates paths)."
@echo ""
@echo " - config-paths: Iff not present in .bashrc, the paths of the projects will be appended to the file. If ~/.bashrc does not exists it will be created."
@echo ""
@echo " - clean-paths: If the paths of the project are present in .bashrc file, they will be deleted. If ~/.bashrc does not exists it will be created."
@echo ""
@echo " - dummy-data: Uncompress ${DATA_ZIP} at ${DATA_DIR} if ${DATA_DIR} does not exists."
@echo ""
@echo " - install: Run all install, config and check recipes."
@echo ""
@echo " - clean: Run all clean recipes."

Loading
Loading