Skip to content

Commit 4907eaf

Browse files
committed
ENH: Add parameter to specify maximum phantom length in pctweplfit
1 parent ed30b3e commit 4907eaf

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

applications/pctweplfit/pctweplfit.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
epsilon_mm = 1e-5
1212

13-
PROTON_RANGE = 260 # mm
14-
1513

1614
def pv(verbose, *args, **kwargs):
1715
if verbose:
@@ -338,6 +336,7 @@ def pctweplfit(
338336
path_type,
339337
phantom_length_samples,
340338
phantom_width,
339+
max_phantom_length,
341340
detector_distance,
342341
number_of_detectors,
343342
initial_energy,
@@ -350,7 +349,7 @@ def pctweplfit(
350349
verbose,
351350
):
352351
phantom_lengths = np.linspace(
353-
0.0, min(PROTON_RANGE, detector_distance), phantom_length_samples
352+
0.0, min(max_phantom_length, detector_distance), phantom_length_samples
354353
)
355354

356355
seed_seq = np.random.SeedSequence(seed)
@@ -426,6 +425,13 @@ def build_parser():
426425
default=40.0,
427426
type=float,
428427
)
428+
parser.add_argument(
429+
"-l",
430+
"--max-phantom-length",
431+
help="Maximum phantom length to consider (defaults to proton range in water)",
432+
type=float,
433+
default=260.0,
434+
)
429435
parser.add_argument(
430436
"-d",
431437
"--detector-distance",
@@ -491,6 +497,7 @@ def process(args_info: argparse.Namespace):
491497
path_type=args_info.path_type,
492498
phantom_length_samples=args_info.phantom_length_samples,
493499
phantom_width=args_info.phantom_width,
500+
max_phantom_length=args_info.max_phantom_length,
494501
detector_distance=args_info.detector_distance,
495502
number_of_detectors=args_info.number_of_detectors,
496503
initial_energy=args_info.initial_energy,

test/pctapplicationtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_pairprotons_application(
4949
def test_weplfit_application(tmp_path):
5050
output = tmp_path / "weplfit"
5151
pct.pctweplfit(
52-
f"-o {output} --path-type phantom_length -d 220 -e 200 --seed 1234 -v"
52+
f"-o {output} --path-type phantom_length -d 220 -e 200 -l 220 --seed 1234 -v"
5353
)
5454

5555
with open(output / "tof_to_wepl_fit_deg3.json", encoding="utf-8") as f:

0 commit comments

Comments
 (0)