# How can I transfer my custom ultrasound data from python to 3Dslicer through IGT

**URL:** https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336
**Category:** Support
**Tags:** python
**Created:** [January 19, 2023, 1:53am UTC](https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336 "2023-01-19T01:53:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![LV52](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LV52](https://discourse.slicer.org/u/LV52)
#### Post date: [January 19, 2023, 1:53am UTC](https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336/1 "2023-01-19T01:53:34Z")

</div>

Hi, everyone.

I am conducting an academic research and want to use 3DSlicer to reconstruct the ultrasound image from 2D to 3D.

I only have offline ultrasound images (both DICOM and .png) and 6-DOF coordinate for each ultrasound image, and I do not have the ultrasound devices and positioning equipment such as OptiTrack which is recommended in the IGT tutorial. But I found an [IGT Python implementation](https://github.com/lassoan/pyigtl) from Lassoan. This Python code has two functions **pyigtl.PositionMessage** and **pyigtl.ImageMessage** , which is match with my offline ultrasound data.

Now, the question is how to connect the Python to 3DSlicer through IGT to realize the 3D reconstruction of ultrasonic images? I’ve seen some slicerIGT tutorials in [slicerigt.org](http://slicerigt.org) and it seems like to fetch data from outside you have to use plus server and prepare a configuration file (.xml) for that.

I am now confused with how to write this configuration file right , any good idea?

In addition to preparing the correct .XML file, what other operations do I need to do to finally connect and transmit data correctly from Python to Slicer?

Furthermore, if I transmit the ultrasonic data correctly to the Slicer, whether the remaining steps of 3D ultrasonic reconstruction are the same as this [video](https://www.youtube.com/watch?v=2vXeJxYFou4), whitch can be implemented by calling Plus Remote, and the Volume Reconstruction module?

Very appreciate！

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [March 1, 2023, 4:47am UTC](https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336/2 "2023-03-01T04:47:05Z")

</div>

I would recommend to create an ultrasound sequence file (igs.mha or igs.nrrd), which contains the coordinate system for each ultrasound image and the all the images. You can load these files into Slicer and use the Volume reconstructor module to paste the frames into a 3D volume.

The specification of the file format is available [here](http://perk-software.cs.queensu.ca/plus/doc/nightly/user/FileSequenceFile.html). You can find many examples [here](https://github.com/PlusToolkit/PlusLibData/tree/master/TestImages).

---

<div class="post-metadata">

### Author: ![LV52](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LV52](https://discourse.slicer.org/u/LV52)
#### Post date: [March 1, 2023, 8:54am UTC](https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336/3 "2023-03-01T08:54:11Z")

</div>

OK，thanks! I wiil try it.  
I have read some documentation of SlicerIGT and OpenIGTLink before, but not getting anywhere.

The IGT Python implementation , I used **pyigtl.ImageMessage** successfully, but **pyigtl.PositionMessage** failed.

In **pyigtl.ImageMessage** , I can see the moving circle image in the 3Dslicer, which has a device\_name of “Image”. But in **pyigtl.PositionMessage** , I see nothing in the 3Dslicer, also the device\_name of “Position” is not show.

The documentation of plus toolkit which I have not read yet.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [March 1, 2023, 12:08pm UTC](https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336/4 "2023-03-01T12:08:37Z")

</div>

If you want to reconstruct already recorded data then it is simpler to create a .igs.nrrd file. Streaming to Slicer via openigtlink is needed if you want to reconstruct live data.

---

<div class="post-metadata">

### Author: ![LV52](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LV52](https://discourse.slicer.org/u/LV52)
#### Post date: [March 2, 2023, 8:13am UTC](https://discourse.slicer.org/t/how-can-i-transfer-my-custom-ultrasound-data-from-python-to-3dslicer-through-igt/27336/5 "2023-03-02T08:13:23Z")

</div>

The tutorials you gave me yesterday seems like create the .mha file through plus toolkit. The tutorials are mostly based on c++, which I am not familiar with.  
If I take my ultrasound images and 3D location data to create a .nrrd file, is there a way to do it in python?
