Skip to content

Commit

Permalink
for phase prediction also return pi_time min and max
Browse files Browse the repository at this point in the history
  • Loading branch information
wasserth committed Mar 18, 2024
1 parent e205e98 commit bd9e293
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion totalsegmentator/bin/totalseg_get_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
from totalsegmentator.statistics import get_basic_statistics


"""
Additional requirements for this script:
xgboost
"""

def pi_time_to_phase(pi_time: float) -> str:
"""
Convert the pi time to a phase and get a probability for the value.
Expand Down Expand Up @@ -78,7 +83,8 @@ def get_ct_contrast_phase(ct_img: nib.Nifti1Image):
print(f"mean: {pi_time} [{preds.min():.1f}-{preds.max():.1f}]")
phase, probability = pi_time_to_phase(pi_time)

return {"pi_time": pi_time, "phase": phase, "probability": probability}
return {"pi_time": pi_time, "phase": phase, "probability": probability,
"pi_time_min": preds.min(), "pi_time_max": preds.max()}


def main():
Expand Down
2 changes: 1 addition & 1 deletion totalsegmentator/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def totalsegmentator(input: Union[str, Path, Nifti1Image], output: Union[str, Pa

crop_path = output if crop_path is None else crop_path

if isinstance(input, Nifti1Image) or input.suffix == '.nii' or input.suffixes == ['.nii', '.gz']:
if isinstance(input, Nifti1Image) or input.suffix == ".nii" or input.suffixes == [".nii", ".gz"]:
img_type = "nifti"
else:
img_type = "dicom"
Expand Down

0 comments on commit bd9e293

Please sign in to comment.