Improve TotalSegmentator pre-segmentation speed

Interesting to see that Jakob has implemented a “roi_subset” option in the latest version of the TotalSegmentator program, which allows for generating only the organs/structures that you would want to see or save.


python TotalSegmentator -i “C:\input.nii.gz” -o “C:\segmentation” --roi_subset lung_upper_lobe_right lung_middle_lobe_right lung_lower_lobe_right

from the command line and it works great, reducing the time needed to save the structures from 34 s (104 segmentations) to 6.6 s (3 segmentations).

1 Like

I’ve asked him to implement this feature because because fast pre-segmentation saving took 1.5 minutes on my computer, because all structures were saved. He implemented it within a day!

We now just need to update the Slicer extension to use this new parameter. @rbumm it would be nice if you could give it a try. It could be implemented by changing the requiresPreSegmentation property in the tasks descriptions from a Boolean flag to a list of segment names that are required and pass that to the pre-segmentation.

1 Like

Sure, I will give it a try.

--roi-subset can actually be set and has benefits during any TotalSegmentation and would not only be useful for tasks in which requirePreSegmentation is True. Should we better add it as another, independent self.tasks entry in the extension class logic?

The next question is how we would implement the selection of organs/structures in the TotalSegmentator extension UI. Maybe a ListWidget with MultiSelect?

Will be up for testing on TotelSegmentator extension GitHub in some minutes (new branch).

I don’t think we need (and therefore we probably shouldn’t) add GUI for segment selection, because we know exactly what segments are needed from the pre-segmentation step; and for the full segmentation we don’t need segment selection (as it would complicate the GUI and in most cases it would slow down segment saving, because loading a few segments one-by-one takes longer than loading 100 segments all at once).

Let’s continue the discussion in the comment section of your pull request:

Agreed, but let me just my response from GitHub

Thank you for your comments. I think implementing this in the GUI would be helpful because many users would just focus on 3-5 organs/structures of interest when using TS. Ideally, you would want to be able to save your selection of choice (f.e. liver only) for future use. It is very helpful to have the roi_subset option in the logic when I call the logic from Lung CT Segmenter, because it saves nearly a minute of saving time (I could just ask for lobes and airways).

here to enable a good discussion.

1 Like