# Read position from txt file

**URL:** https://discourse.slicer.org/t/read-position-from-txt-file/2930
**Category:** Development
**Created:** [May 25, 2018, 11:51am UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930 "2018-05-25T11:51:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![val.dil](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@val.dil](https://discourse.slicer.org/u/val.dil)
#### Post date: [May 25, 2018, 11:51am UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930/1 "2018-05-25T11:51:47Z")

</div>

Hello everybody,  
I want to develop a system that read a position from a file in real time, through OpenIGTlink, and send it to the Slicer.  
The file has to be read at the same time that it is modified. I found a node “vtkMRMLStorableNode::GetModifiedSinceRead()” that do this, but it works in real time and with openigtlink?  
Do you think that it’s better and easier to implement a thread for the writing-reading-sending process?  
Thanks for your helping.

---

<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: [May 25, 2018, 12:45pm UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930/2 "2018-05-25T12:45:09Z")

</div>

[PlusServer application](http://perk-software.cs.queensu.ca/plus/doc/nightly/user/ApplicationPlusServer.html) in [Plus toolkit](http://www.plustoolkit.org) can already read positions and orientations (and images) from [text files](http://perk-software.cs.queensu.ca/plus/doc/nightly/user/FileSequenceFile.html) and send them to Slicer through OpenIGTLink. No need to develop any new software for this. PlusServer can also connect to real hardware (tracking system, sensors, imaging devices, etc).

---

<div class="post-metadata">

### Author: ![val.dil](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@val.dil](https://discourse.slicer.org/u/val.dil)
#### Post date: [May 25, 2018, 2:01pm UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930/3 "2018-05-25T14:01:05Z")

</div>

I don’t think that i can use PlusServer app, because my device is not compatible with it.

---

<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: [May 25, 2018, 4:14pm UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930/4 "2018-05-25T16:14:45Z")

</div>

What device do you have? You can either add support for your device (more learning, less coding), or implement a PlusServer clone that can communicate with your device and send OpenIGTLink messages to Slicer.

---

<div class="post-metadata">

### Author: ![val.dil](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@val.dil](https://discourse.slicer.org/u/val.dil)
#### Post date: [May 26, 2018, 4:29pm UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930/5 "2018-05-26T16:29:49Z")

</div>

Actually, I already develop a c++ code that acquire the position from the device and save it on a file, so i just want to find an optimal way to transfer this position on 3Dslicer. Do you think that i should implement a thread?  
However, as a second way, your suggestion is very interesting. Can you please give me more information about that?  
Thanks for your helping.

---

<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: [May 26, 2018, 6:22pm UTC](https://discourse.slicer.org/t/read-position-from-txt-file/2930/6 "2018-05-26T18:22:24Z")

</div>

Follow examples in OpenIGTLink library for creating a simple server or client that sends tracking data. Slicer can connect to that using OpenIGTLinkIF module and takes care of multithreading and real-time scene updates.
