Skip to content

Commit

Permalink
print settings and add updates option for run_OSEM
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisThielemans committed Oct 9, 2024
1 parent 0436d4d commit 5b86e1a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions SIRF_data_preparation/create_Hoffman_VOIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@
os.makedirs(downloaddir, exist_ok=True)
os.makedirs(intermediate_data_path, exist_ok=True)

print(
f"srcdir: {srcdir}\ndownloaddir: {downloaddir}\nprocessingdir: {intermediate_data_path}\nwrite_VOIs: {write_PETRIC_VOIs}"
)
print("srcdir:", srcdir)
print("downloaddir:", downloaddir)
print("processingdir:", intermediate_data_path)
print("write_VOIs:", write_PETRIC_VOIs)


# %% Function to find the n-th connected component (counting by size)
Expand Down
4 changes: 3 additions & 1 deletion SIRF_data_preparation/run_BSREM.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

scanID = args['<data_set>']
num_updates = int(args['--updates'])
print(f"num_updates {num_updates}")

if not all((SRCDIR.is_dir(), OUTDIR.is_dir())):
PETRICDIR = Path('~/devel/PETRIC').expanduser()
Expand All @@ -46,6 +45,9 @@
settings = get_settings(scanID)

data = get_data(srcdir=srcdir, outdir=outdir)
print("Penalisation factor:", data.prior.get_penalisation_factor())
print("num_subsets:", settings.num_subsets)
print("num_updates:", num_updates)
data_sub, acq_models, obj_funs = partitioner.data_partition(data.acquired_data, data.additive_term, data.mult_factors,
settings.num_subsets, mode="staggered",
initial_image=data.OSEM_image)
Expand Down
10 changes: 7 additions & 3 deletions SIRF_data_preparation/run_OSEM.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
Arguments:
<data_set> path to data files as well as prefix to use
Options:
--updates=<u> number of updates to run [default: 400]
"""
# Copyright 2024 Rutherford Appleton Laboratory STFC
# Copyright 2024 University College London
# Licence: Apache-2.0
__version__ = '0.1.0'

__version__ = '0.2.0'
from pathlib import Path

import matplotlib.pyplot as plt
Expand All @@ -27,6 +28,7 @@
# logging.basicConfig(level=logging.INFO)

scanID = args['<data_set>']
num_updates = int(args['--updates'])

if not all((SRCDIR.is_dir(), OUTDIR.is_dir())):
PETRICDIR = Path('~/devel/PETRIC').expanduser()
Expand All @@ -40,9 +42,11 @@
settings = get_settings(scanID)

data = get_data(srcdir=srcdir, outdir=outdir)
print("num_subsets:", settings.num_subsets)
print("num_updates:", num_updates)
# %%
algo = main_OSEM.Submission(data, settings.num_subsets, update_objective_interval=20)
algo.run(400, callbacks=[MetricsWithTimeout(**settings.slices, seconds=5000, outdir=outdir)])
algo.run(num_updates, callbacks=[MetricsWithTimeout(**settings.slices, seconds=5000, outdir=outdir)])
# %%
fig = plt.figure()
data_QC.plot_image(algo.get_output(), **settings.slices)
Expand Down

0 comments on commit 5b86e1a

Please sign in to comment.