forked from openigtlink/MatlabIGTL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
149 lines (101 loc) · 4.38 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
--------------------------------------------------------------------------------
Matlab OpenIGTLink Interface
Junichi Tokuda
http://wiki.na-mic.org/Wiki/index.php/OpenIGTLink/Matlab
--------------------------------------------------------------------------------
Please refer the web page for up-to-date information.
+----------------------------+
| Contents |
| |
| 1. Introduction |
| 2. Build/Install |
| 3. How does it work? |
| |
+----------------------------+
================
1. Introduction
================
The objective of this project is to provide OpenIGTLink interface for Matlab /
Octave to support research and development in image guided therapy (IGT).
Matlab and Octave are widely used for prototyping image and signal processing
algorithms. They also offers many powerful function set to handle matrix and
coordinate data, which is useful to test and analyze coordinate data exported
from tracking and robotic devices. The OpenIGTLink interface for Matlab / Octave
allows importing and exporting several types of data that can be handled in
the OpenIGTLink protocol in Matlab / Octave environment. It provides a rapid
prototyping environment, which many researchers and engineers are already
familiar with.
This project is a generalization of Slicer Matlab Pipeline project in the 2007
NA-MIC Project Week.
=================
2. Build/Install
=================
2.1 Install the OpenIGTLink Library
The instruction can be found at
http://wiki.na-mic.org/Wiki/index.php/OpenIGTLink/Library
2.2 Get the Matlab OpenIGTLink interface source code
The OpenIGTLink/Matlab interface is in the initial stage of development.
The source code is available from NA-MIC SandBox repository at:
http://svn.na-mic.org/NAMICSandBox/trunk/BRPTools/MatlabIGTL
2.3 Build MEX files
You need to have a MEX compiler or octave to the build MEX binaries. To build
the binaries, you may need to edit the Makefile.
First substitute the path to the OpenIGTLink Library source and binary
directories installed in your system:
### OpenIGTLink Library
IGTLSRC= /projects/igtdev/tokuda/igtl/OpenIGTLink
IGTLBLD= /projects/igtdev/tokuda/igtl/OpenIGTLink-build
If you use Maltab, specify the full path to the MEX compiler. You don't need to
have any options to the MEX compiler.
MEX = /local/os-exact/pkg/Matlab71-64/bin/mex
MEXOPT =
If you use Octave, specify the full path to the mkoctfile program and "--mex"
option.
MEX = /Applications/Octave.app/Contents/Resources/bin/mkoctfile
MEXOPT = --mex
Now it's ready to build your MEX file. Run make. If the MEX files are
successfully built, you could find:
igtlclose.mex<arc-name>
igtlopen.mex<arc-name>
igtlsend.mex<arc-name>
Note that <arc-name> is the architecture name of your system.
=====================
3. How does it work?
=====================
The OpenIGTLink Matlab interface is implemented as a set of MEX Files, which
are C/C++ source codes called from Matlab. Those MEX files simply receives data
from Matlab, connect to OpenIGTLink receiver, serialize the data in appropriate
format using the OpenIGTLink Library, and send it to the receiver.
The usage of the interface is quite simple. The following example Matlab code
is sending trancking data to the receiver waiting at port #18944 in the
localhost.
%%% affine transform matrix
M = [1.0, 0.0, 0.0, 0.0;
0.0,-1.0, 0.0, 0.0;
0.0, 0.0, 1.0, 0.0;
0.0, 0.0, 0.0, 1.0];
IMGDATA.Type = 'TRANSFORM';
IMGDATA.Name = 'MatlabTrans';
IMGDATA.Trans = M;
sd = igtlopen('localhost', 18944);
r = igtlsend(sd, IMGDATA);
igtlclose(sd);
For tracking data transfer:
%%% read image data
fid = fopen('igtlTestImage1.raw', 'r');
I = fread(fid, [256 256], 'uint8')';
fclose(fid);
%%% affine transform matrix
M = [1.0, 0.0, 0.0, 0.0;
0.0,-1.0, 0.0, 0.0;
0.0, 0.0, 1.0, 0.0;
0.0, 0.0, 0.0, 1.0];
IMGDATA.Type = 'IMAGE';
IMGDATA.Name = 'MatlabImage';
IMGDATA.Image = I;
IMGDATA.Trans = M;
%%% send the image data through OpenIGTLink connection
sd = igtlopen('localhost', 18944);
r = igtlsend(sd, IMGDATA);
igtlclose(sd);