wasserth / TotalSegmentator

Tool for robust segmentation of >100 important anatomical structures in CT and MR images
Apache License 2.0
1.51k stars 250 forks source link

python API roi_subset? #301

Closed wadzhwl1 closed 6 months ago

wadzhwl1 commented 6 months ago

Dear Author, Thanks for the excellent work! Beginner's question: When using the Python API, if I don't set roi_subset, I can get normal ROI files but all 117 items, elif I set roi_subset=["propagate"], I will get an abnormal ROI file "propagate. ni. gz" with all zeros, how can i fix it?

TotalSegment version=2.1.0 Thank you!

from totalsegmentator.python_api import totalsegmentator

if __name__ == "__main__":
    input_path = r"D:\se1\n1\ct"
    output_path = r"D:\se1\n1\ROI"
    totalsegmentator(input_path, output_path)  # ok but all 117 ROI files
    totalsegmentator(input_path, output_path, roi_subset=["prostate"])  # 1file "prostate.nii.gz", but ROI unavailable, all zero
wasserth commented 6 months ago

When setting roi_subset, TotalSegmentator will first run a very low resolution model to find the area of interest, then crop to this area and then run the high res model. If the low res model was not able to find the prostate at all, then this can result in a empty final segmentation. Especially for small organs this can be a problem. You can try running with "--roi_subset_robust prostate" instead of roi_subset. This uses a bit better model to find the area of interest. This will be slower but more robust.

wadzhwl1 commented 6 months ago

Thanks for reply. I understand the issue now.

I am trying to run with "totalsegmentator(input_path, output_path, roi_subset_robust=["prostate"]) " but "RuntimeError: Could not find a dataset with the ID 297." emmmm

wasserth commented 6 months ago

This is strange. Can you try again with the newest version of TotalSegmentator?

wadzhwl1 commented 6 months ago

ok, Thanks. current v2.1.0, issue remains. I'll try again later.