Sunday, May 17, 2009

Tempo Manaul - Hacking

To understand Tempo source, the hacking manual is really important.!!!!!

This section is intended as short road-map though TEMPO
source code files. TEMPO code is pretty much populated with
comments, and, as with any other open source project, source code is
ultimate reference. Also, Doxygen format is used for
commenting TEMPO classes interfaces, so Doxygen
tool could be employed along with tempo.cfg
Doxygen configuration file in TEMPO distribution
root directory to generate documentation for these interfaces in
various formats.



Source code files are grouped in src subdirectory of
TEMPO distribution. Subdirectory data contains files
with face and scalp models, as well as file with electrode names and
positions and sample EDF file. Subdirectory
manual contain help files (what you are reading now) in
HTML format. Subdirectory resources contains
artwork (icon files). Subdirectory tmp is where compilation
artifacts are stored (note however that executable is generated in
TEMPO distribution root directory. File tempo.pro is
Qt project file
. Other files in TEMPO
distribution root directory are rather standard files for any open
source project.



TEMPO is written in C++ programming language,
using OpenGL library for 3D graphics and Qt
toolkit for graphical user interface. Thus, familiarity with these
technologies is necessary in order to be able to understand source
code.



When examining src subdirectory, one should start with
vector.*, color.*, bounding_box.*,
vertex.*, material.* and triangle.* files.
These files contain definition of simple data structures to be used
for constructing geometry model.



One should proceed with object.* files then. These files
contain definition of data structure and accompanying operations for
geometry model. Two operations related to this data structure are
especially important: creating model from given data file and
rendering model using OpenGL routines. Input format for
object geometry is simple ASCII format; input file
contains arrays of vertices, normals, materials and triangles. Each
array is preceded by number designating array length. Array elements
are groups of numbers corresponding to fields of data structures
mentioned above.
Subdirectory data of TEMPO
distribution contains files face.mo and scalp.mo
with face and scalp models in above format. OpenGL code
rendering object model is (as emphasized in comments) for simplicity
left without any optimization (nevertheless, this code works pretty
fast even on software-only OpenGL implementations).



Files scene.* contain definition of data structure and
accompanying operations for scene object. Scene object contains
instances of face and scalp objects.
Visualization created by
TEMPO is pretty generic in the sense that this code could be
utilized for any kind of visualization where some parts of scene are
color coded from some interpolated values and other parts of scene
rendered as is. Thus, instead of "face" and
"scalp", terms "not mapped" and "mapped"
are utilized through TEMPO code. Also, term
"sensor" is utilized later instead of term
"electrode".
It would be actually very easy to utilize
TEMPO rendering code to create visualization of say
interpolated statical load across the bridge given measured loads in
some points; but that is unrelated story.



Geometry related parts of TEMPO code are completed with
quaternion.* and rotation.* files. These files
contain definition of rotation data structures and corresponding
operations. Quaternions are used to calculate cumulative scene
rotation after user interaction with mouse.



Files exception.* contain definition of exceptions that
could be thrown from TEMPO for error handling purposes.



Signal processing related parts of TEMPO code begin with
fft.* files. These files contain implementation of
FFT procedure, together with caching of auxiliary data
for faster execution.



Files sensors.* contain data structure definition for
electrodes ("sensors" in TEMPO terminology, as
above explained) names and positions. These information are read from
file in simple ASCII format: first line of file contains
number of electrodes, and then follows lines with electrode
information where length of electrode name is given first, then
electrode name between quotation marks and finally electrode positions
(in same coordinate system as face and scalp models are given).
Subdirectory data of TEMPO distribution contains
file 10_10.ms with corresponding information for electrode
arrangement according to 10-10 and 10-20
international standards.



Reading of input EDF file and calculating
EEG scores is distributed between input.* and
signal.* files.
Former files contain definition of data
structure and operations to read EDF file header and to
calculate array of EEG score values given needed set of
samples on each electrode. Later files contain definition of data
structure representing individual EEG channel and
operations to read corresponding signal header from EDF
file and provide set of signal samples of given length at given
position in EDF file (this operation is used by above
mentioned function from input.cpp file calculating array of
EEG score values). Important to note is that function
from input.cpp file reading EDF header is also
looking at signal headers and comparing signal names to names known to
above discussed sensors object (an instance of this object is passed
to this function). Thus, signal objects are created only for channels
from EDF file whose names corresponds to names of
electrodes known to TEMPO.



Mapping of score values to colors is encapsulated in interpolation
object, defined in interpolation.* files. Weight coefficients
for each scalp vertex according to vertex distance from set of nearest
electrodes are calculated during initialization of this object and
used later to actually perform interpolation. Mapping of values to
color pallette is also defined here.



Two simple Qt widgets are defined in
gradient_widget.* and visualization_widget.* files
respectively. First widget is drawing color legend and is later
instantiated in legend frame of TEMPO main window. Second
widget is actually showing OpenGL rendering and is later
instanced in left half of TEMPO main window.



Set of files info_widget.*, score_widget.*,
legend_widget.* and time_widget.* contain code for
creating graphical user interface and handling appropriate events for
corresponding frames on right half of TEMPO main window. This
code is bulky, but is rather simple actually.



Files main_widget.* contain code for TEMPO
application main widget, that is uniting highest level components of
above together. Files manual_widget.* contain implementation
of simple browser for TEMPO help files.



Finally, main.cpp is file containing program
main() function

No comments:

Post a Comment

Google+