# Assistance with Ultrasound Segmentation File Format (.h5)

**URL:** <https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243>\
**Category:** Support\
**Tags:** segmentation, ultrasound, aigt\
**Created:** [November 18, 2024, 1:38pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243 "2024-11-18T13:38:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MReza](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@MReza](https://discourse.slicer.org/u/MReza)\
**Post date:** [November 18, 2024, 1:38pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/1 "2024-11-18T13:38:38Z")

</div>

Dear all,  
I am currently working on automatic segmentation in ultrasound imaging using the instructions provided on the AIGT GitHub repository.  
I have successfully trained my own model by following all the steps outlined there. As a result, I obtained several files, all named unet-DiceCE.  
However, I need the final segmentation model in .h5 format to use it for ultrasound segmentation with 3D Slicer. Could anyone advise on how to convert these files or generate the required .h5 format?  
Dear Dr. @ungi , since you are actively involved in research on this topic, I would greatly appreciate your guidance.  
Thank you very much

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [November 18, 2024, 4:50pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/2 "2024-11-18T16:50:52Z")

</div>

Hi, if you are using this training script:  
[aigt/UltrasoundSegmentation/train.py at master · SlicerIGT/aigt](https://github.com/SlicerIGT/aigt/blob/master/UltrasoundSegmentation/train.py)  
then the models are saved in traced format, so you don’t need the source code that defines the model. You could change the lines where the traced model is saved to save in any format you like. But I’m not sure why would you want to do that.

---

<div class="post-metadata">

**Author:** ![MReza](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@MReza](https://discourse.slicer.org/u/MReza)\
**Post date:** [November 18, 2024, 5:13pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/3 "2024-11-18T17:13:32Z")

</div>

Thank you for answering my question.  
Since the file format used for segmentation UNet (the extension in 3D Slicer) is .h5, I want to convert the final model to .h5.  
Do you mean this is not necessary?

---

<div class="post-metadata">

**Author:** ![MReza](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@MReza](https://discourse.slicer.org/u/MReza)\
**Post date:** [November 18, 2024, 7:08pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/4 "2024-11-18T19:08:35Z")

</div>

I think I can imagine what is happening based on the final results of this model. From what I learned in your PowerPoint file (U38-live AIrec), the file needs to be in .h5 format to be imported into the SegmentationUNet extension. However, I noticed there are new extensions in your Git repository, such as `torch_live_ultrasound` or ‘torch sequence segmentation’. Should the final “model\_traced\_bes.pt” be used with this extension directly?

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [November 18, 2024, 8:02pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/5 "2024-11-18T20:02:46Z")

</div>

Oh, unfortunately that tutorial is outdated. It still works, but that is not how I would do things now.

For real-time applications, you will get best performance if you stream the ultrasound data directly to a segmentation script in a separate python environment. Then, that script streams the segmentations to Slicer. Here is an example for such a script: [aigt/UltrasoundSegmentation/Inference/ScanConversionInference.py at master · SlicerIGT/aigt](https://github.com/SlicerIGT/aigt/blob/master/UltrasoundSegmentation/Inference/ScanConversionInference.py)

And this example script expects traced models, so you don’t need to change the way models are saved.

---

<div class="post-metadata">

**Author:** ![MReza](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@MReza](https://discourse.slicer.org/u/MReza)\
**Post date:** [November 18, 2024, 8:36pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/6 "2024-11-18T20:36:58Z")

</div>

Ah, I see—this likely means the ultrasound extension is outdated. May I ask what steps I should follow if I want to run the auto-segmentation using a recorded sequence in 3d slicer?

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [November 19, 2024, 12:04am UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/7 "2024-11-19T00:04:03Z")

</div>

For that, you may use the Torch Sequence Segmentation module:  
[aigt/SlicerExtension/LiveUltrasoundAi/TorchSequenceSegmentation at master · SlicerIGT/aigt](https://github.com/SlicerIGT/aigt/tree/master/SlicerExtension/LiveUltrasoundAi/TorchSequenceSegmentation)

---

<div class="post-metadata">

**Author:** ![MReza](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@MReza](https://discourse.slicer.org/u/MReza)\
**Post date:** [November 19, 2024, 4:22pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/8 "2024-11-19T16:22:47Z")

</div>

First of all, thank you for the guidance so far.  
However, I have encountered some problems using Torch Sequence Segmentation. With the settings configured as shown in the video, I selected my model, which is named **model\_traced\_best**. But when I choose 3D Volume Reconstruction and start, not only does nothing happen, but the image also freezes on the current slide. While the view updates based on transformations in the 3D view, the displayed image remains unchanged.

Moreover, the generated prediction file doesn’t actually contain any predictions.  
Is there anything specific I should pay attention to while using this extension?

I am attaching a video here to demonstrate what is happening.  
it shows before and after starting the torch segmentation.

---

<div class="post-metadata">

**Author:** ![max\_05ge](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@max\_05ge](https://discourse.slicer.org/u/max_05ge)\
**Post date:** [October 11, 2025, 8:37pm UTC](https://discourse.slicer.org/t/assistance-with-ultrasound-segmentation-file-format-h5/40243/9 "2025-10-11T20:37:26Z")

</div>

Hello,

Have you found a solution to your problem?

I also want to perform segmentation of recorded ultrasound images.
