Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated gamma analysis during inference #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
83 changes: 56 additions & 27 deletions src/let/cmd_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
from argparse import ArgumentParser
from argparse import ArgumentParser, ArgumentTypeError

def parse_list_of_tuples(input_str):
"""
Parse a representation of a list of tuples.
"""

try:
parts = input_str.split(",")
assert len(parts) == 4, "Parameter has to have four parts separated by ','"

input_modality, loc_or_glob, dd, dta = parts
assert input_modality in ["wedenberg", "bahn", "constant", "dose*LET", "LET"], f"First part '{input_modality}' not valid. Choose one of 'wedenberg', 'bahn', 'constant', 'LET' or 'dose*LET'"
assert loc_or_glob in ["local", "global"], f"Second part '{loc_or_glob}' not valid. Choose 'local' or 'global'"

dd = float(dd)
dta = float(dta)

except Exception as e:
print(e)

raise ArgumentTypeError("Parameter must be <rbe_method>,<local/global>,<dose_difference>,<distance_to_agreement>")

return input_modality, loc_or_glob, dd, dta


def add_dataset_args(parser):
Expand Down Expand Up @@ -81,6 +104,14 @@ def add_dataset_args(parser):
default=False,
help="CT values will not be normalised to unit range after windowing."
)
group.add_argument(
"--physical_dose",
action="store_true",
default=False,
help="Specify that doses that are read are physical doses."
"Otherwise assume they are clinically RBE weighted doses "
"with factor 1.1 multiplied to the physical dose."
)

return parser

Expand Down Expand Up @@ -210,31 +241,37 @@ def add_inference_args(parser):
)

group.add_argument(
"--no_gamma",
default=False,
action="store_true"
"--execute_metric_computation",
action="store_true",
help="Flag to enable the calculation of classic metrics (DW,VW,percentiles,...). Argument should be set to perform computations."
)

group.add_argument(
"--gamma_dose_criteria",
type=float,
default=[2., 5., 10.],
help="(Local) dose difference criteria in % of the gamma analysis.",
nargs='+'
"--no_gamma",
action="store_true",
help="Flag to disable the gamma analysis. Argument should be set to not perform analysis."
)
group.add_argument(
"--gamma_distance_criteria",
type=float,
default=[2.],
help="Distance to agreement criteria in mm of the gamma analysis.",
nargs='+'

parser.add_argument(
'--gamma_configuration',
type=parse_list_of_tuples,
nargs="+",
default="[]",
help=(
"A pythonic string respresentation of a list of tuples for gamma configuration."
"Each tuple should have 4 elements: "
"input_modality (str), gamma_type (str: 'local' or 'global'), "
"dose_difference (float, in %), distance_to_agreement (float, in voxel size). "
"Example: wedenberg,local,3.,3. wedenberg,local,2.,2."
)
)

group.add_argument(
"--gamma_n_dose_bins",
type=int,
default=5,
help="Number of dose ranges to be evaluated in the gamma analysis."
"--use_gamma_multithreading",
action="store_true",
help="Flag to enable multithreading for gamma analysis. Argument should be set to use multithreading."
)

group.add_argument(
"--output_dir",
type=str,
Expand Down Expand Up @@ -317,14 +354,6 @@ def add_ntcp_args(parser):
" this defines the constant by which to multiply"
" the dose to obtain an RBE weighted dose."
)
group.add_argument(
"--physical_dose",
action="store_true",
default=False,
help="Specify that doses that are read are physical doses."
"Otherwise assume they are clinically RBE weighted doses "
"with factor 1.1 multiplied to the physical dose."
)
group.add_argument(
"--output_dir",
type=str,
Expand Down
7 changes: 6 additions & 1 deletion src/let/ntcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def __init__(self,
alphabeta=2., # only used with 'wedenberg' mode
rbe_constant=1.1 # only used with 'constant' mode
):
assert let_to_rbe_conversion in ["wedenberg", "bahn", "constant"]
assert let_to_rbe_conversion in ["wedenberg", "bahn", "constant", "dose*LET"]
self.let_to_rbe_conversion = let_to_rbe_conversion
self.alphabeta = alphabeta
self.rbe_constant = rbe_constant
Expand Down Expand Up @@ -385,6 +385,11 @@ def __call__(self,

print(f"Using 'rbe_constant' {self.rbe_constant}.")
rbe = self.rbe_constant * np.ones_like(let)

elif self.let_to_rbe_conversion == "dose*LET":

rbe = let

else:
raise ValueError(
f"let_to_rbe_conversion {self.let_to_rbe_conversion} "
Expand Down
Loading