Create a script to use TotalSegmentator from script for 2 small tasks

Hi,
I have a small project and being pretty new to programming, I’m having difficulties finding the right code to call some option.

Let me describe what I’m trying to do and the steps. I also have an other question not absolutely related to this subject, but if some of you want to help, always appreciated.

I need to segment the Femur, patela, fibulla and tibia of a CT scan. The best option I found was TotalSegmentator. To do so, I do a first segmentation with total to get the femur (as it’s separated from the appendicular bone licenced bones segmented). I run it on normal (not fast to get the best quality). I then have a segmentation of multiple bones with the femur.

I then return to TotalSegmentator, select “Appendicular bones” for the segmentation of tibia, patella and fibulla and run it on normal without forgetting the “Create new segmentation on Apply” option. This creates a new segmentation with all the bones with the three of interest.

I then want to move the bones I want in the second segmentation and the ones to delete in the first.

So in step, my scripts need to do these :

  1. Segmentation task → total
  2. Apply
  3. select normal mode
  4. wait for segmentation to finish
  5. segmentation task → appendicular …
  6. Segmentation → Create new segmentation on Apply
  7. Apply
  8. wait for segmentation to finish
  9. move the desired segmentation to second group and move unwanted in first group

To give you an idea of my level of programming, here’s what I got so far
slicer.util.selectModule(“TotalSegmentator”)

All help is welcomed!