map3d User's Guide




Version 6.3


Last update: May 19, 2005


Authors: Rob MacLeod (macleod@cvrti.utah.edu),
Bryan Worthen (worthen@sci.utah.edu), and
J.R. Blackham (blackham@sci.utah.edu)



Scientific and Computing Institute (SCI)
www.sci.utah.edu


Center for Bioelectric Field Modeling, Simulation and Visualization www.sci.utah.edu/ncrr


Nora Eccles Harrison
Cardiovascular Research and Training Institute (CVRTI)
www.cvrti.utah.edu


the University of Utah


Support for this project came from:


The NIH National Center for Research Resources (NCRR) and the The Nora Eccles Treadwell Foundation


Contents


1 What's New?

In this section, we highlight the latest additions to map3d in the (vain?) hope that people will read at least this much of the manual and be able to quickly make use of the latest and greatest that the program offers.

1.1 Version 6.3: May, 2005

This is the fourth version of the ``new'' map3d with a GTK-based GUI. We are getting very very very close to the complete functionality of the old GL based version and have gone well beyond it in some features, especially the user interface. This is a ``dot'' release but is not a minor release for it contains some important new features and the usual set of bug fixes.

Some of the specific additions that you should notice over previous versions include:

Open Source:
map3d is now open source! See Section 3.7 and Section 2.1.1.
Jet Color map:
map3d3d() has seen the light and added the Matlab Jet color map as the default color map.
Fiducial display:
Some improvements over the fiducial display and control. (LINK) See fid dialog, display, Section 6.3.4.
Geometry in landmark form:
Per the recommendation of a user, we have incorporated the landmark file format into an actual geometry See Section 6.1.5.
Bug fixes:
not that the previous version had any bugs, but we found a few(!) things to fix.


1.2 In the works (``vapourware'')

A small sampler of things that are in the works:

g

2 Introduction

This document describes the function and usage of versionversion of the program map3d, a scientific visualization application originally developed at the Nora Eccles Harrison Cardiovascular Research and Training (CVRTI) and now under continued development and maintenance at the Scientific Computing and Imaging Institute (SCI) at the University of Utah. The original purpose of the program was to interactively view scalar fields of electric potentials from measurements and simulations in cardiac electrophysiology. Its present utility is much broader but continues to focus on viewing three-dimensional distributions of scalar values associated with an underlying geometry consisting of node points joined into surface or volume meshes.

map3d has been the topic of some papers [1,2,3,4] and a technical report [5] and we'd love it if you would reference at least one of them (perhaps [3] or [4] are the easiest ones to get copies of) as well as this manual when you publish results using it. There have been many many more papers that use map3d and the list keeps growing.[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]

One of the big changes in version 6.3 is that we are now completely open source. People can download not only the executable but also the complete source code for the program. Please note that we do not have a good way yet to incorporate changes people outside our little group make to the program. If you do wish to change and then contribute back, please let us know as soon as possible and we can try and coordinate as best we can. Of obvious interest is when someone ports map3d to another platform--please let us know about this and we can add it to the list and release it with the rest.

2.1 Acknowledgments

The history of map3d goes back to 1990 and the first few hundred lines of code were the product of a few hours work by Mike Matheson, an inspired visualization specialist, now with SGI in Salt Lake City. This was my introduction to GL and C and this program became my personal sand box to play in. Along the way, Phil Ershler made valuable contributions in figuring out the magic of Formslib for some user interface controls and developing with me graphicsio, the geometry and data file library that supports map3d. Ted Dustman has recently taken up maintenance and extensions of graphicsio and remains my main man when I need programming lessons.

This is one in a series of ``new'' versions of map3d, the series (labeled 5.x or above) that marks the move from GL to OpenGL library and thus to becoming truly portable. In fact, we call the old one map3dGL now to indicate its links to SGI's original GL library. We seem permanently stuck in the middle of this big conversion project, moving support to OpenGL and adding lots of power as we convert functionality. The reason for the version 6.x, was the move to gtk as the GUI library with which we create all the dialog and display elements of the program. This move has allowed us to extend dramatically the set of dialog boxes map3d offers and this newest version 6.3 contains many examples.

There are some people who have been instrumental in the process and deserve special mention. Chris Moulding is a graphics programmer and general software whiz who surveyed my sand box architecture, pulled together the essential walls, created new ways to make rooms, and still left lots of the sand box around so we could continue to play. From version 5.2 onward, Bryan Worthen replaced Chris and really has found the spirit of map3d. Bryan has become the main driving force behind the actual work of coding and fixing. He strayed off to some other project for a while, but never lost his love for map3d; we are really pleased that he has returned to pick up the torch again. Most recently, J.R. Blackham has joined the team while still an undergraduate in Computer Science at Utah. Jeroen Stinstra is my super-postdoc, helpful in more ways than I knew I even needed and full of inventive ideas. He has created the support for MATLAB that we use in map3d (and the SCIRun project) and is best bug-catcher I know.

The largest thanks must go to the users of map3d, who provided the real inspiration and identified the needs and opportunities of such a program. Among the most supportive and helpful are Bruno Taccardi, Bonnie Punske, and Bob Lux, all colleagues of mine at the CVRTI. Dana Brooks and his students from Northeastern University are also regular users who have provided many suggestions and great enthusiasm. Also invaluable in the constant improvement of the program are my post docs, Jeroen Stinstra, and graduate student Quan Ni, Rich Kuenzler, Bulent Yilmaz, Bruce Hopenfeld, Shibaji Shome, Lucas Lorenzo, Andrew Shafer, and Zoar Englemann. They give me new energy every day and remind me why I am a professor. Notable new additions to the family are Randy Thomas from Universite d'Evry Val d'Essonne in Evry, France. The great thing about Randy is that he used map3d to visualize concentrations of ions in his simulation of the nephron! Also, Ed Ciaccio from Columbia University has become a big user and even takes it to his classes.

The first user and long-time collaborator and friend was Chris Johnson and this new version of map3d is possible because of the success he and I have had in creating the SCI Institute and specifically the NIH/NCRR Center for Geometric Modeling, Simulation, and Visualization in Bioelectric Field Problems (www.sci.utah.edu/ncrr).

We gratefully acknowledge the financial support that has come from the NIH, National Center for Research Resources (NCRR) the Nora Eccles Treadwell Foundation, and the University of Utah, which provides us with space and materials to create this sand box. The Nora Eccles Treadwell Foundation has also provided support for the development of map3d and the huge pile of data we have used it to analyze.


Rob MacLeod, May 19, 2005.


2.1.1 Open Source License

The terms of the license agreement under which we release map3d are simple and as follows:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  2. Use of this software in preparing any publication material must be cited as follows:



    R.S. MacLeod and C.R. Johnson. Map3d: Interactive scientific visualization for bioengineering data. In IEEE Engineering in Medicine and Biology Society 15th Annual International Conference, pages 30-31, IEEE Press, 1993.



THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2.1.2 Libraries used by map3d

map3d incorporates the functionality of several external libraries. They are:

We use GTK and GtkGLExt to interface with the window manager to give us windows with OpenGL capability, as well as giving us widgets we need for interactive control. We use PNG and JpegLib to be able to save .png and .jpg images of map3d. All four of these libraries are covered by the GNU LGPL, which is included in the distribution of map3d.

As of version 6.3, we also release internal libraries under the same license as above for the rest of map3d.

3 Installation

3.1 System requirements

map3d is written in standard C/C++ and uses the OpenGL and GTK+ libraries, both choices made to ensure broad portability of the program.

All platforms:
OpenGL now comes standard on most systems. Instructions on how to install GTK+ are described in detail below based on which platform you are installing. described below
Requirements for all systems.
OpenGL libraries (GL and GLU) version 1.1 + 1
OpenGL/window interface library (GLX)  
GTK+ libraries and dependencies version 2.0+

Linux (i386):
map3d requires the OpenGL library, which is available as the mesa library at www.mesa3d.org for any Linux platform. For better performance, graphics cards from companies such as nVidia (www.nvidia.com) usually provide OpenGL libraries.
Requirements
Operating System kernel 2.2.x
Architecture i386 (+ maybe PPC)
Applications Binary Interface libc2.1
Recommendations
Window system XFree86 version 4.0 +
Hardware 3D graphics card (nVidia, 3dfx, ati)
  128 MB main memory

Windows:

Requirements
Operating System W2K/NT4.0/9x
Architecture i386
Applications Binary Interface win32
Recommendations
Hardware 3D graphics card (nVidia, 3dfx, ati)
  128 MB main memory

Mac OS X:

Requirements
Operating System Mac OS 10.3(Panther)
Architecture PPC
Recommendations
Hardware 3D graphics card (nVidia, 3dfx, ati)
  256 MB main memory

SGI:
map3d runs on virtually any SGI that will support Irix version 6.5+. We have tested it on Indigo2, O2, Octane, and Origin workstations running various flavors of Irix 6.5. If you need a version for a different SGI configuration, please let us know (map3d@sci.utah.edu)
Requirements
Operating System Irix 6.5+
Architecture mips3 or mips4 (maybe mips2)
Applications Binary Interface n32 or 64
Recommendations
Hardware Texture mapping hardware
  128 MB main memory

3.2 General Installation

Unfortunately, with our move to GTK+ for window support, it is not as easy as past versions, which required just the download of an executable. We hope (in vain, perhaps) to be able to do that again in the future, but for now we will attempt to make installation as easy as we can. Simplified instructions will be in a README file which comes with each package, and are also listed below:

To download the software, use this URL www.sci.utah.edu/software/map3d.html, and click on the ``Download'' button. You'll need to sign into the SCI archive. For each of the installation instructions below, you can grab those file from this page.

To test the installation, use the test files that accompany this distribution. Each has some script files included that show how to call and execute map3d.


3.3 Linux Installation Instructions

The Linux installation is relatively straightforward. You'll need to download map3d's dependencies, then download map3d itself.

3.3.1 Linux Dependencies

There are two phases to this part. First we need to get GTK+ and its dependencies. The easiest way to do this is from your distribution's installation CDs, or you can download the RPMs at www.rpmfind.net.

To get the dependencies from your distribution, run the Package Manager (Add/Remove Applications, configure-packages or something of that sort). Search for gtk, and install gtk2 (if you can't find that directly, then installing the gnome environment will take care of it).

To get the dependencies from the internet, navigate your favorite browser to http://www.rpmfind.net, and search for gtk-2.0. Try to find one that matches your distribution (redhat, mandrake, etc.). We directly support development for gtk2-2.2.1 and gtk2-2.0.6, so if you can find one of these that would be encouraged.

The next part is to download gtkglext, the library that supports OpenGL for GTK widgets. As of this release, this is not standard in most distributions. If your GTK version is 2.0.6 or 2.2.1 (you can find out by looking at gtkversion.h which will be where you installed gtk (normally /usr/include/gtk-2.0/gtk/gtkversion.h), and look for GTK_MAJOR_VERSION, GTK_MINOR_VERSION, and GTK_MICRO_VERSION. There will be numbers on the same lines as each of these, and if you put them together it will be something like 2.2.1). If you are using one of these versions download gtkglext-linux-2.2.1.tar.gz or gtkglext-linux-2.0.6.tar.gz from the map3d download page and follow these instructions:

    cd <download directory>
    gunzip gtkglext-linux-<version>.tar.gz
    tar xf gtkglext-linux-<version>.tar
    cp libgtkglext-x11-1.0.so.0 /usr/local/lib
    cp libgdkglext-x11-1.0.so.0 /usr/local/lib

You can copy them to some directory other than /usr/local/lib if you wish.

If this doesn't work, you will need to download the gtkglext source and compile it yourself (don't worry--if your gtk is properly set up, this will be very easy). Download the sources from Source Forge http://sourceforge.net/projects/gtkglext and follow these instructions:

    cd <download directory>
    gunzip gtkglext-1.0.6.tar.gz
    tar xf gtkglext-1.0.6.tar
    cd gtkglext-1.0.6
    configure
    make
    make install

If you don't want these to end up in /usr/local/lib, you need to

    configure --prefix=<dir>
where dir is where to put the libraries.

3.3.2 Linux Executable

Download the map3d-6.2-linux.tar.gz file from the map3d() download page and unzip it to a directory of your choice. We will call that RUN-DIR. This is the directory from which you will run map3d.

To run map3d, you will need to make sure that all the libraries are in your LD_LIBRARY_PATH environment variable. For this we will assume that your gtk libraries are in /usr/lib and your gtkglext libraries are in /usr/local/lib. Do the following: tcsh users:

   setenv LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
or
bash users:
 
    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

you might want to put this line in your .cshrc or .profile file to avoid having to run this multiple times.


3.4 Windows Installation Instructions

The Windows installation is relatively straightforward. You'll need to download map3d's dependencies, then download map3d itself.

3.4.1 Windows Dependencies

Download the map3d-win-environment.zip file from the map3d download page and unzip (using winzip, native windows xp zip file browser, or another windows zip program) it into a location of your choice - we will call that INSTALL-DIR. It will create a directory called INSTALL-DIR\map3d.

Add INSTALL-DIR\map3d\lib to your path. To do this, open the Control Panel, select System, and click on the `Advanced' tab on the top of the screen. Click on the Environment Variables button. You should see a variable called Path or PATH in the System Variables section. Click on it, and select Edit. Go to the end of the line, add a semi-colon (;) and type INSTALL-DIR\map3d\lib.

3.4.2 Windows Executable

There is an executable of map3d in the environment directory. We have also placed an executable here to facilitate future downloads, so you only have to download the environment once. If you wish, download the map3d-6.2-windows.zip file from the map3d download page and unzip it to a directory of your choice. We will call that RUN-DIR. This is the directory from which you will run map3d.


3.5 Mac OS X Installation Instructions

The Mac OS X installation is relatively straightforward. You'll need to download map3d's dependencies, then download map3d itself.

3.5.1 Mac OS X Dependencies

Map3d requires the gtk+2 and gtkglext libraries. You can easily install these libraries using fink.

If you do not currently have fink installed on your system you will need to go to http://fink.sourceforge.net and follow the instructions on how to install it and the gtk+2 and gtkglext libraries.

3.5.2 Mac OS X Executable

Download the map3d-6.2-mac.tar.gz file from the map3d download page and unzip it to a directory of your choice. We will call that RUN-DIR. This is the directory from which you will run map3d.


3.6 SGI Installation Instructions

The SGI installation is relatively straightforward. You'll need to download map3d's dependencies, then download map3d itself.

3.6.1 SGI Dependencies

There are two phases to this part. First we need to get GTK+ and its dependencies. The easiest way to do this is for SGI is to run a browser with root access and go to SGI's freeware site at http://freeware.sgi.com. On that page near the bottom there should be a link to a prereq calculator. Click on that link, and in the Freeware Product box, select fw_gtk2+ (make sure you don't select fw_gtk+). Submit the query. You should see a list similar to this:
  fw_atk [relnotes] [prereqs] [install] 
  fw_expat [relnotes] [prereqs] [install] 
  fw_freetype2 [relnotes] [prereqs] [install] 
  fw_gettext [relnotes] [prereqs] [install] 
  fw_glib2 [relnotes] [prereqs] [install] 
  fw_libjpeg [relnotes] [prereqs] [install]
  fw_libpng [relnotes] [prereqs] [install]
  fw_libz [relnotes] [prereqs] [install]
  fw_pango [relnotes] [prereqs] [install]
  fw_tiff [relnotes] [prereqs] [install]
To install them, click on the install link one by one (and follow the instructions in the dialog boxes).

IMPORTANT - when you install libz - it will mention something about a security library being removed. When you install libz, allow it to do this. On the subsequent libraries, it will mention that the security package conflicts with libz, on these packages, have it continue without installing the security package.

Install them in the order:

    gettext
    expat
    freetype2
    atk
    glib2
    pango
    libjpeg
    libtiff
    libz
    libpng

After you've done all of these, click on the alphabetical link, and click on the install buton that corresponds to libgtk2+-2.0.6.

If for some reason, the prereq calculator isn't there or isn't working, go to the alphabetical index and install the above in the order specified.

The next part is to download gtkglext, the library that supports OpenGL for GTK widgets. If your GTK version is 2.0.6 (you can find out by looking at gtkversion.h which will be where you installed gtk (normally /usr/freeware/include/gtk-2.0/gtk/gtkversion.h), and look for GTK_MAJOR_VERSION, GTK_MINOR_VERSION, and GTK_MICRO_VERSION. There will be numbers on the same lines as each of these, and if you put them together it will be something like 2.0.6). If you are using this version download gtkglext-sgi.tar.gz from the map3d download page http://www.sci.utah.edu/software/map3d.html and follow these instructions:

    cd <download directory>
    gunzip gtkglext-sgi.tar.gz
    tar xf gtkglext-sgi.tar
    cp libgtkglext-x11-1.0.so.0 /usr/local/lib
    cp libgdkglext-x11-1.0.so.0 /usr/local/lib

You can copy them to some directory other than /usr/local/lib if you wish.

If this doesn't work, you will need to download the gtkglext source and compile it yourself (don't worry--if your gtk is properly set up, this will be very easy). Download the sources from Source Forge http://sourceforge.net/projects/gtkglext and follow these instructions:

    cd <download directory>
    gunzip gtkglext-1.0.6.tar.gz
    tar xf gtkglext-1.0.6.tar
    cd gtkglext-1.0.6
    configure
    make
    make install

If you don't want these to end up in /usr/local/lib, you need to

configure --prefix=<dir>

where dir is where you want to put the libraries (The libraries will be in dir/lib).

3.6.2 SGI Executable

Download the map3d-6.2-irix.tar.gz file from the map3d download page and unzip it to a directory of your choice. We will call that RUN-DIR. This is the directory from which you will run map3d.

To run map3d, you will need to make sure that all the libraries are in your LD_LIBRARY_PATH environment variable. For this we will assume that your gtk libraries are in /usr/freeware/lib32 and your gtkglext libraries are in /usr/local/lib. Do the following:

    tcsh users:
    setenv LD_LIBRARY_PATH /usr/freeware/lib32:/usr/local/lib:$LD_LIBRARY_PATH
or bash users:
    export LD_LIBRARY_PATH=/usr/freeware/lib32:/usr/local/lib:$LD_LIBRARY_PATH
you might want to put this line in your .cshrc or .profile file to avoid having to run this multiple times.


3.7 Installing from source

We have tried to make installing map3d from source as simple as possible. There are four steps:

  1. Download the source
  2. Download and install map3d's external dependencies
  3. Setup the make configuration
  4. Compile

3.7.1 Download Source Code

You can get the map3d source code from the map3d download page at http://www.sci.utah.edu/software/map3d.html. Login and work your way to the map3d version 6.3 download page, and download map3d-source.tar.gz.

3.7.2 Install Dependencies

You will need to install map3d's dependencies: gtk+, gtkglext, etc. To do this, please refer to Section 3.4, Section 3.6, Section 3.3, or Section 3.5.

If you are running on a different system, you will probably need to download and install these on your own; please refer to GTK website and GtkGLExt website.

3.7.3 Configuring map3d

map3d in addition to GTK+, map3d has other dependencies that have been developed in conjunction with map3d, which were designed to be used with and independently of map3d. The make system shipped with map3d was designed to allow users to compile these libraries independently of map3d if they so choose. However, most users will not use these libraries for any other purpose except for running map3d.

You should not have to change much in order to get map3d to compile. MatlabIO (one of map3d's dependents) needs to know where ZLIB is (required, and should be installed after completing the previous section), and map3d needs to know where gtk is. The included files show samples of how this is to be done, and following are specific details.

3.7.3.1 MS Visual Studio users

To configure MatlabIO, open Visual Studio, load map3dtop/map3d.sln, right-click on the MatlabIO project, and select properties. Under Configuration properties, click C/C++, select General, and add the directory where zlib.h is.

To configure map3d, right-click on the map3d project, and select properties. Under Configuration properties, click C/C++, select General, and add the directory where all the gtk-based header files are (if you installed the map3d-environment from the website, they should all be in the same place). I.e., \local\map3d-environment\include. Each directory should be semi-colon delimited.

While still under map3d property pages, select Linker, and under General, add the directory where the libraries are; i.e., \local\map3d-environment\lib.

3.7.3.2 Mac, Linux, and SGI users

To configure both MatlabIO and map3d, it is only necessary to modify map3dtop/Makefile.incl.

To configure MatlabIO, change ZLIB_INC to the directory that contains zlib.h Also change ZLIB_LIB to the directory that contains the zlib library.

To configure map3d, edit map3dtop/map3d/Makefile and change GTKTOP, GTKLIB, GTKGL_INC, and GTKGL_LIB to appropriate values. If gtk.h is in /usr/local/include/gtk-2.0/gtk, and libgtk-x11-2.0.so (or .dylib for mac users) is in /usr/local/lib, then

GTK_INC=/usr/local/include
GTK_LIB=/usr/local/lib
Similarly, GTKGL_INC and GTKGL_LIB need to be set. to include the dir that contains gtkgl.h and libgtkgl-x11-1.0.so (or .dylib) respectively. (-I goes in front of the include directory, and -L goes in front of the lib directory, respectively.)

3.7.4 Compiling map3d

Compiling map3d now should be as simple as entering the map3dtop directory and running
make

Remember for map3d to run, you should probably add map3d to your path. If, when you run map3d see errors like ``Cannot load library gtk-2.0.dll'' or ``Cannot map so libgtk-2.0.so'', then you need to add the gtk libraries to your runtime path. To do this on windows, follow the directions on the windows install page, otherwise, set the LD_LIBRARY_PATH. To do this, do the following: tcsh users:

   setenv LD_LIBRARY_PATH GTK_LIB:$LD_LIBRARY_PATH
or bash users:
 
    export LD_LIBRARY_PATH=GTK_LIB:$LD_LIBRARY_PATH

Substitute the values that GTK_LIB is set to in the Makefile.incl. You might want to put this line in your .cshrc or .profile file to avoid having to run this multiple times.

3.7.4.1 Contact

If there are problems, feel free to contact map3d@sci.utah.edu

3.8 Documentation

This document should have reached you either as a pdf file or via the map3d web site. If you would like more copies or the latest version, go to the same web site and look for the links under Documentation:

www.sci.utah.edu/software/map3d.html

3.9 Bug reporting

We want to hear your response to using map3d and especially to learn about any bugs you may find. They may be features, rather than bugs, but if so, we will be happy to hear your impressions.

To submit a bug report please send email to map3d@sci.utah.edu or point your browser at software.sci.utah.edu/bugzilla (you will need to register your e-mail address) with the following information:

  1. Type and version of the operating system and hardware you are using.
  2. Version of map3d.
  3. Description of the bug/feature you encountered.
  4. Suggestions for fixing the bug or altering the program behavior.

3.10 How to reach us

We have established an email address for map3d, map3d@sci.utah.edu, and web pages within the website www.sci.utah.edu/ncrr dedicated to map3d. There is also a majordomo mailing list for map3d users called map3d-users@sci.utah.edu. To subscribe to this list, send email to majordomo@sci.utah.edu with the following in the message body

      subscribe map3d-users

Please let us know how you use map3d and how we can make it better for your purposes. We can only develop this program with continued support and the best way to achieve this is to show that others use the program and find it helpful.


4 Usage

This version of map3d provides two ways to load files. The first is via the command line, which is described in this section. The second is via the files window (see Section 8.5.1). You can also launch map3d with some command line options and then modify the associated settings using interactive menus and the files window.

This is a subset of map3d's usage:

 
  map3d  -b -nw -nv
         -f geomfilename 
           -w
           -as xmin xmax ymin ymax 
           -al xmin xmax ymin ymax
           -at xmin xmax ymin ymax 
           -t time-signal-number 
           -c mesh colour
           -p scalar data (potentials) filename 
             -s num1 num2 
             -i increment 
             -ph maxpotval 
             -pl minpotval 
             -cs contour-spacing 
             -ps scaling_value 
             -ch channels-filename 
             -sl surfnum
             -ff fidfile
           -lm landmarks-filename
           -ll leadlinks-filename
           -lh

map3d also has other parameters it accepts that are designed for the use of a .map3drc or script file, and those parameters will be shown in table 20.


4.1 Typical usage examples

Here are some typical examples of using map3d:

This version of map3d provides an interactive means of specifying geometry numbers from a .geom file or time instants from a time series data file (see Section 8.5.1).


4.2 Global Parameters

The following general parameters affect the entire display:

-b
= open each individual window without borders placed within a master window that still has the usual borders. To move or resize individual windows, hold the Alt (meta) key and use the left and middle mouse buttons, respectively. Most of these can be anywhere on the command line. Also, if you use -b without any other arguments, map3d will allow you to select the files interactively and add them to this master window.

-v
= show current version of the program. If this is the only argument, the program will exit.

-nw
= for multiple surfaces (i.e., more than one set of points and triangles), place each surface data in a new window. By default, map3d opens a single window for all surfaces.

-slw 0
= do not show any legend windows at startup.

-fs interval
= Sets the run-time interval between frames as accessed by the arrow keys. Note that this is independent of the -i option below, which subsamples the data as it is being read in. This feature can be changed via the menus at runtime.

-nv
= to NOT check validity of geometry files. This can have a large impact on startup performance if map3d needs to load large geometries.

-c colour
= colour value to use on all surfaces for which there is no specific colour specification. This option must be set before any surfaces are read, since the same option sets the colors for individual surfaces. See the mesh-specific -c colour below for colour examples.

-bg colour
= colour value to use as background of all windows for which there is no specific colour specification. This option must be set before any surfaces are read, since the same option sets the colors for individual windows.

-fg colour
= colour value to use as text colour for all windows for which there is no specific colour specification. This option must be set before any surfaces are read, since the same option sets the colors for individual windows.

-if basefilename
= base filename for any image files that are generated in this run of the program.

-dp datafile_pathname
= directs the search for data files accessed to another directory. Using an alternate pathname, you can override the original directory specification for the files and get them from, say, an optical disk. This value can also be set with an environmental variable called MAP3D_DATAPATH, which you can set at any time before executing map3d. With this option, map3d looks in datapath/filename.


4.3 Geometry specifications

The basis for display in map3d is one or more geometry descriptions, which are usually in the form of surfaces, but can also be a set of line segments or tetrahedra; hence we can picture each set of nodes and connectivities as a ``meta-surface'', which we generally refer to as a ``surface''. For each such surface, map3d needs the set of node locations in three-dimensional space and usually some connectivity information that defines the (meta) surface. The geometries must exist in discrete form and be stored in files that map3d can read (see Section 6.1.3 for details of the file formats). There is no provision at present for analytically defined geometries.

To tell map3d where to look for this geometry information, each occurrence of -f in the command line indicates that beginning of a new surface. All parameters (except for global options) that follow before the next occurrence of -f refer to the current surface.

-f geometry-file
= filename of the geometry file(s) containing points and connectivity information. Legal formats for the file specification are:
  1. nodes (.pts) file will read and display only the nodes from the geometry; no display of the potentials is possible with just this information;

  2. triangles/tetrahedra (.fac/.tetra) file will read both the connectivities and the nodes (provided both exist and share the same root filename);

  3. binary geometry (.geom) file contains both nodes and connectivity information and may also contain channel mapping. At present, multi-surface geometry files must include a specific indication of the desired surface (@surfnum); otherwise, map3d reads all surfaces in the file.
  4. binary matlab geometry (.mat) file contains both nodes and connectivity information and may also contain channel mapping. If there are multiple surfaces in the matlab file, the same restrictions apply as in the .geom files.
Note: by specifying a root filename without any extension, map3d will look for all valid geometry files and try and construct the most comprehensive set. (It will do the same for data files as well.) Where there are multiple, potentially conflicting files with the same root, e.g., file.pts and file.geom, map3d will select binary over text files. See Section 6.2 for more details on the rules for specifying and reading geometry files.

-w
= place this and subsequent surfaces in a new window. This option will do nothing if the -nw option is set or if this is the first surface

-fg colour
= desired colour for the screen information of a particular window, if this will be specified as a red, green, and blue value triplet ranging from 0 to 255. Some examples are:
255 0 0 red
0 255 0 green
0 0 255 blue
255 255 0 yellow
255 0 255 magenta
0 255 255 cyan
255 255 255 white

-bg colour
= desired colour for the background of a particular window, specified as a red, green, and blue value triplet. See the -fg option for examples.

-c colour
= desired colour for the mesh of a particular surface, specified as a red, green, and blue value triplet. See the -fg option for examples.

-as xmin xmax ymin ymax
= set the absolute location in pixels of the surface window most recently defined. We assume an origin in the lower left corner of the screen and the typical full screen of an SGI workstation with a 19-inch monitor has 1280 by 1024 pixels. This option is useful for setting consistent layout of windows, especially when there are multiple surfaces, each in its own window.

-al xmin xmax ymin ymax
= set the absolute location in pixels of the surface window most recently defined's colormap legend window. There will be one of these windows per surface only if a valid data file is associated with it.

-slw 0
= do not show the legend window for this surface.

-lh
= Set the most recently defined surface's colormap legend window to have a horizontal instead of vertical layout.

-lm landmark_filename
= read from the file landmark_filename a set of coronary arteries, or any other landmark information stored as a series of points, with a radius associated with each. See section 6.5 below for details.

-ll leadlinks-filename
= file in leadlinks format containing a list of the node locations that correspond to a subset of the leads, e.g., the lead locations on the torso surface that correspond to the standard ECG leads. The point of identifying such leads is to display them with their own markings, either as spheres or with the lead number (typically not the same as the node number). For more information, see the menu options in Section 8.2.3 that determine the form of the display markings and Section 6.4 for more information on leadlinks files.


4.4 Scalar Data parameters

To display scalar data values on the geometry, we must specify the source of the data and how to link them to the geometry. As with the geometry, all arguments specified between two occurrences of -f in the command line refer to the currently valid surface. Within pairs of -f options, there can be only a single instance of any of the following options:

-p potfilename
= filename for the potential and current data files. The legal file types for scalar data are:
  1. Pot files (.pot) (see Section 6.3.1 are text-based files which contain one file per time instance.

  2. Time-series data files (.tsdf) are binary files where all time instants are stored in one file.

  3. matlab files (.mat) are also stored in binary format. Matlab files can also contain multiple time series.

  4. Time-series container files (.tsdfc), contain references to at least one .tsdf file, along with other information about the time series. See Section 6.3.2 for more information.

The -s option determines how many frames to load. In the case of pot files, this controls which pot files to open (If -s is omitted, it will only open the pot file specified). For binary files, the -s option specifies the start and end frame numbers to be read from the file. With no -s option, map3d will read in all time instants from the file. Note also that if you omit the extension, as with geometry files, it will try to match a .pot, .tsdf, .mat, or .tsdfc extension for you.

For files with multiple time series (matlab or tsdf containers), you may specify the time series by the command line with the ``@'' suffix appended to the filename followed by the time series index within the file.

eg., -p file.mat@1 reads the first time series and eg., -p file.tsdfc@2 reads the second time series.

-s num1 num2
= range of frame numbers to read. If we are reading data from .pot or .grad files, map3d appends each of the numbers between num1 and num2 to the value of potfilename to make complete pot filenames. However, you must run map3d with the full pot filename (one of the pot files in the series).
eg., -p good-map001.pot -s 1 3 expands to:
good-map001.pot good-map002.pot good-map003.pot
If we are reading from a time series (.tsdf) data file, map3d will read frames num1 to num2 from the file.

-i increment
= difference between each frame number. With the last few versions, this would still read in all the frames, but this version acts more like the versions prior to that, and subsamples the data.

-ph maxpotval
= maximum data value in ``user'' scaling mode. This sets one option for setting the range used in scaling the data value to colours and contours. You can select other ranges from the menu and can select this one again with Scaling->Range->Command-line specified range.

-pl minpotval
= minimum data value in ``user'' scaling mode.

-cs contour-spacing
= spacing between contours set by the user. This provides a menu option for selecting contours by setting a constant spacing rather than deriving the spacing from the desired number of contours and the range of data values. Note that the spacing will not always be a the command-line set value - map3d will divide the range by the specified value and set the number of contours as that number, and then determine the contour values by using that number of contours with the currently- selected scaling function. You can select other numbers of contours from the menu and can select this again with Contours->Number of Contours->Command-line spacing

-ps scaleval
= scaling value by which map3d multiplies each potential value as it reads from the file(s). This option tries to make use of any unit information available in a time series data file and alters the unit value available to map3d for display. The resulting scaling of the data is permanent for the current instance of map3d.

-ch channels-filename
= file in channels format containing an entry for each node in the geometry which points to the associated location in the data array. The value of this pointer is also the number that is written next to node locations when channel numbers are displayed. See section 6.4 for more information on the channels file format.

-lm landmarks-filename
= file in landmarks format containing a set of landmark segments, divided into categories. Each category has a word depicting the landmark type. Each lines within the categories contains three points (x,y,z) and an associated radius, which may have a different effect based on the type of landmark. See section 6.1.5.

-ff fidfile
= Ascii file containing fiducial information. Information may be specified for each node for an arbitrary set of fiducial data. See section 6.3.4.

-sl surfnum
= surface number to which the scaling for this surface is to be slaved. The idea here is to have surfaces locked in the way they scale and display the data; in this way, one can compare colors across surfaces to determine relative values of the local scalar data.

-t timesignal-lead-number
= number of the node to be used for the display of a time signal in its own window. The number refers to either a node number in the geometry or, if a leadlinks file is present, the lead number. This command is optionally used in conjunction with the -at command, to specify a node and place its window accordingly. If the -at option is not present, map3d will choose a default window location. Multiple invocations of this option are possible for each surface, providing the option to open several windows per surface. At any time during the operation of the map3d the user can select a new node via the pick mode menu item and have the time signal from that node displayed (see Section 8.6 for details).

-at xmin xmax ymin ymax
= set the absolute location in pixels of a time signal window associated with the current surface. As with the -as option, the origin is in the lower left corner of the screen and the full screen resolution of an SGI screen with 19-inch monitor typically supports 1280 by 1024 pixels. This command is optionally used in conjunction with the -t command, to specify a node and place its window accordingly. If the -t option is not present, map3d will choose a default node (the first node in the geometry). Multiple invocations of this option are possible for each surface, providing the option to open several windows per surface.


5 Script Files

Using script files to control map3d has numerous advantages, for example:

  1. complex layouts and specifications can be created and then held for later reuse,
  2. execution of the program reduces to a single word that starts the script,
  3. scripts are shell programs and can include logic and computation steps that automate the execution of the program; the user can even interact with the script and control one script to execute many different actions.

5.1 What are script files?

A script files are simple programs written in the language of the Unix shell. There are actually several languages, one for each type of shell, and the user is free to select. At the CVRTI we have decided to use the Bourne shell for script programming (and the Korn shell for interactive use) and so all scripts will assume the associate language conventions. The shell script language is much simpler to use and learn than a complete, general purpose language such as C or Fortran, but is very well suited to executing Unix commands; in fact, the script files consist mostly of lists of commands as you might enter them at the Unix prompt. Even more simply, a script file can consist of nothing more than the list of commands you would need to type to execute the same task from the system prompt.

5.2 How to make script files

Script files are simple text files and so are usually created with an editor such as emacs. You can, however, also generate a script file from a program, or even another script. But all script files can be read and edited by emacs and this is the way most are composed.

To learn about the full range of possibilities in script files requires some study of a book such as ``Unix Shell Programming'' by Kochan and Wood but the skills needed to make map3d script files are much more modest; any book on Unix will contain enough information for this. The instructions and examples below may be enough for many users.

Here are some rules and tips that apply to script files:

5.2.0.1 Use a new line for each command

This is not a requirement but makes for simpler files that are easier to read and edit. If the command is longer than one line, then use a continuation character ``
'', e.g.,backslash
         map3d -f geomfilename.fac \
               -p potfilename.tsdf \
              -cl channelsfilename

Make sure that there are no characters (even blank spaces) after the continuation character!!! This has to be the most frequent error when the script file fails to run or stops abruptly.

5.2.0.2 Make script files executable

Script files can be executed by typing . scriptfile but the simplest thing is to make then executable files so that they work simply by typing their names. To do this, use the chmod command as follows:
         chmod 755 script_filename

5.2.0.3 Use the .sh extension for scripts

This convention makes it easy to recognize shell scripts as such, but also invokes some editor help when you edit the file in emacs. The mode will switch to shell (much like Fortran or C mode when editing programs with .f and .c extensions) and has some automatic tabbing and layout tools that can be helpful.

5.2.0.4 Variables in scripts

The shell script is a language and like any computer language there are variables. To define a variable, simply use it and equate it to a value, e.g.,
         varname=2
         varname="some text"
         varname=a_name

Do not leave any spaces around the ``='' sign or the command will fail and set the variable to an empty string.

Once defined, the variables can be used elsewhere in the script as follows:

         geomdir=/u/macleod/torso/geom
         geomfile=datorso.fac
         datafile=dipole.tsdf
         map3d -f ${geomdir}/${geomfile} -p $datafile

The curly braces are required when the variable name is concatenated with other text of variable names but is optional otherwise. To concatenate text and variables you simply write them together (e.g., geomdir/geomfile.pts concatenates the two variables with a ``/'' and the extension ``.pts''.

5.2.0.5 Environment variables in scripts

All the environment variables are available and can be set in the script. For example:

         mydir=${HOME}
sets the variable $mydir equal to the user's home directory. Likewise,
         MAP3D_DATAPATH=/scratch/bt2feb93/
         export MAP3D_DATAPATH
defines and ``exports'' the environment variable used by map3d to find .pak files.

5.3 Examples

Below are some sample scripts, from simple, to fairly complex:

5.3.0.1 Set the geometry, data, and window size and location

         map3d -f ${HOME}/torso/geom/dal/daltorso.fac \
               -as 100 500 300 700 \
               -p ${HOME}/maprodxn/andy3/10feb95/data/cooling.tsdf \
               -s 1 1000

5.3.0.2 map3d-tank1.sh, included with this distribution

       MAP3D=../map3d
       GEOM=../geom/tank
       DATA=../data/tank

       $MAP3D -nw -f ${GEOM}/25feb97_sock.fac \
               -p ${DATA}/cool1-atdr_new.tsdf@1 -s 1 1000 \
               -ch ${GEOM}/sock128.channels \
               -f ${GEOM}/25feb97_sock_closed.geom \
               -p ${DATA}/cool1-atdr_new.tsdf@2 -s 1 1000\
               -ch ${GEOM}/sock128.channels

5.3.0.3 map3d-tank2.sh, included with this distribution

       MAP3D=../map3d
       GEOM=../geom/tank
       DATA=../data/tank

       $MAP3D -nw  -f ${GEOM}/25feb97_sock.fac \
               -as 200 600 400 800 \
               -p ${DATA}/cool1-atdr_new.tsdf@1 -s 1 476 \
               -at 200 600 200 420 -t 9\
               -ch ${GEOM}/sock128.channels \
               -f ${GEOM}/25feb97_sock_closed.geom \
               -as 590 990 400 800 \
               -p ${DATA}/cool1-atdr_new.tsdf@2 -s 1 476 \
               -at 590 990 200 420 -t 126 \
               -ch ${GEOM}/sock128.channels

5.3.0.4 map3d-torso1.sh, included with this distribution

       MAP3D=../map3d
       GEOM=../geom/torso
       DATA=../data/torso

       $MAP3D -f ${GEOM}/daltorso.geom -p ${DATA}/dipole2.tsdf -s 1 6

5.3.0.5 map3d-torso2.sh, included with this distribution

       MAP3D=../map3d
       GEOM=../geom/torso
       DATA=../data/torso

       $MAP3D -f ${GEOM}/daltorsoepi.geom@1 \
               -p ${DATA}/p2_3200_77_torso.tsdf -s 1 200 \
               -f ${GEOM}/daltorsoepi.geom@2 \
               -p ${DATA}/p2_3200_77_epi.tsdf -s 1 200

5.3.0.6 Set some environment variables, then layout the whole display

       #!/bin/sh
       # A script for the spmag 1996 article
       #
       ######################################################################
       map3d=/usr/local/bin/map3d
       map3d=${ROBHOME}/gl/map3d/map3d.sh
       MAP3D_DATAPATH=/scratch/bt26mar91pack/
       export MAP3D_DATAPATH
       echo "MAP3D_DATAPATH = $MAP3D_DATAPATH"
       basedir=/u/macleod/maprodxn/plaque/26mar91
       $map3d -b -nw \
               -f $basedir/geom/525sock.geom \
               -as 150 475 611 935 \
               -at 150 475 485 610 -t 237 \
               -p $basedir/data/pace-center.tsdf@1 \
               -s 65 380 \
               -f $basedir/geom/525sock.geom \
               -as 476 800 611 935 \
               -at 476 800 485 610 -t 237 \
               -p $basedir/data/pace-center.tsdf@1 \
               -s 65 380 \
               -f $basedir/geom/525sock.geom \
               -as 150 475 176 500 \
               -at 150 475 50 175 -t 237 \
               -p $basedir/data/pace-center.tsdf@1 \
               -s 65 380 \
               -f $basedir/geom/525sock.geom \
               -as  476 800 176 500 \
               -at  476 800 50 175 -t 237 \
               -p $basedir/data/pace-center.tsdf@1 \
               -s 65 380

6 Input files

In this section, we describe the contents and formats of all the input files that map3d uses to get geometry, data, and much more.


6.1 Geometry input files

The input of geometric data for map3d occurs via files and we support three different formats at present. The simplest (and oldest) is a set of ASCII files that contain the points or nodes of the geometry--stored in a file with the extension .pts--and the connectivities that described polygonal links between nodes--stored as line segments (.seg files), triangles (.fac files), and tetrahedra (.tetra files). To satisfy a need for more comprehensive and compact storage of geometry information, we have developed a binary file format and created the graphicsio library to manage these files. Finally, in recognition of the ubiquity of MATLAB, as of version 6.1, there is support for reading .mat files, which have an internal structure that included node and connectivity information. Below, we describe each of these files and how map3d uses them.

6.1.1 Points (.pts) file

The characteristics of a .pts file are as follows:

  1. ASCII file, no special characters permitted;
  2. Each line contains one triplet, ordered as x, y, and z values; one or more spaces between values, which are assumed to be real, floating point numbers;
  3. Each line may also optionally contain a group number as a fourth element (although at present, map3d does not use this group information);
  4. the order of points in the file is the implicit order of the nodes in the geometry; connectivities are based on this ordering.

6.1.2 Triangle (.fac) files

The characteristics of a .fac file are as follows:

  1. ASCII file, no special characters permitted;
  2. Each line contains a triplet of integer values pointing to the nodes of the geometry. Node numbers begin at 1 not 0!;
  3. The order of triangle vertices (nodes) is not strictly controlled, however, it is recommended that order reflect a common convention in graphics--a counterclockwise sequence of vertices when viewed from the outside of the triangle;
  4. Each line may contain an optional fourth values which is the group number for the triangle (not used by map3d);
  5. Order of triangles in the file is not meaningful except for internal bookkeeping; user will notice ordering only when a triangle is picked for interrogation.


6.1.3 Binary (.geom) geometry files

At the CVRTI we have developed a binary file system for efficient storage of complex geometry and associated attributes, a part of what we call the graphicsio library. Extensive documentation of this format is available from Rob MacLeod (macleod@cvrti.utah.edu) (www.cvrti.utah.edu/~macleod/docs).

Briefly, each graphicsio geometry file contains one or more sets of node locations and, optionally, connectivities for polygonal elements composed from those nodes. It is possible in graphicsio files to associate scalar, vector, and tensor values to nodes or elements, the most relevant example of which are channel pointers, stored as a set of scalar values associated with the nodes of the geometry. Each graphicsio geometry file can contain any number of sets of geometries, each with different nodes and connectivities. A typical example for map3d would be a single .geom file that contains information from multiple surfaces that we might want to display together.

map3d is capable of reading surface geometry from either single surfaces or from all surfaces contained in a multi-surface geometry file. Command line arguments controls the selection, as we describe in the next section.


6.1.4 MATLAB geometry file support

map3d can read .mat files generated by MATLAB as long as they are organized according to the following guidelines:

  1. Each separate surface is either a structure (See the MATLAB documentation for structures ). To include multiple surfaces requires an array of structures.
  2. Within a surface structure, the following fields contain the geometry:

To prepare a structured .mat file is very simple, for example using the following commands:

     >> geom.pts = ptsarray;
     >> geom.fac = facarray;
     >> geom.channels = 100:164
     >> save mygeom.mat geom
where ptsarray is a 3 x N array defined to contain the node locations, facarray is a 3 x M array of triangle connectivities, and mygeom.mat is the name of the resulting .mat file. The channels information indicates that there are 64 nodes in the geometry and they expect to get time signals from channels 100-164 of a data file. (See Section 6.4 for more information on channels.


6.1.5 Landmark geometry file support

map3d can also read geometry from a landmark file (See Section 6.5 below), where you specify a series of connected points and radii. map3d will automatically connect and triangulate them, and will also associate scalar data with them. Note that currently there is no channels support for landmark geometry.


6.2 Command line control of geometry files

In map3d the -f option determines in which files the geometry is to be found. Starting from the filename that follows -f, which may or may not include a file extension, the program looks for all possible candidate geometry files and queries the user for resolution of any ambiguities. Thus, with the arguments map3d -f myfile, map3d3d looks for myfile.geom, myfile.mat, myfile.pts, myfile.fac, etc, and tries to resolve things so that a valid geometry description is found. It is possible to direct this process by typing the geometry filename with an extension according to the following rules:

Extension Effect
none look for files with the extensions .pts, .fac, .tetra, and .geom and if an incompatible set are present (e.g., both .pts and .geom), ask user which to take
.pts take only the .pts file and ignore any connectivity or .geom file
.fac take .pts and .fac and ignore any .geom files present.
.geom take the graphicsio geometry file and ignore any others present.
.mat take the MATLAB file and ignore any others present.

A further way to read geometry into map3d is to use the geometry filename that can be optionally contained within the time series file (see Section 6.3) that contains the potentials. This requires that the .tsdf file be created with the geometry filename included; adding this after the fact is difficult. Note that even if a geometry filename is found in the .tsdf file, it can be overridden by the geometry file name specified in the argument list of map3d.


6.3 Scalar data files

There are two ways of storing scalar values (typically electric potential in our applications) so that map3d can recognize and read them. One is a simple ASCII file and the other a binary format developed at the CVRTI.


6.3.1 .pot files

One way to package the scalar data values that are assigned to the points in the geometry is the .pot file. In the default condition, the scalar values in the .pot files are ordered in the same way as the node points in the geometry file with simple one-to-one assignment. With a channels file, it is possible to remap this assignment, as described in Section 6.4).

The rules for .pot files are:

  1. Each line of the files contains one scalar data value, assumed to be a real number in single precision floating point format.
  2. The order of the values within the file must either agree with that of the associated set of nodes or a channels file must be supplied to redirect the links between potential value and nodes.
  3. Each .pot file must end with a blank line.
  4. A single .pot file can contain only the data values associated with a single surface at a single instant in time. To represent a sequence of time steps (frames) requires a sequence of files, typically with filenames ending in a three-digit series, e.g., mapdata001.pot, mapdata002.pot, mapdata003.pot, .... Section 4.4 explains how to specify such a series of .pot files to map3d and Section 4.1 shows examples.
  5. The extension .pot must be used.


6.3.2 CVRTI data (.tsdf and .tsdfc) format files

One efficient and flexible way to store scalar values is by means of the time-series data file format developed at the CVRTI, also as part of the graphicsio library. Each time series data file (.tsdf files) holds an entire sequence, or time series of scalar data in a single file, along with some information about the contents, type, units, and global (i.e., that apply to all channels) temporal fiducials from the time series. For more details on this file format see www.cvrti.utah.edu/~macleod/docs/graphicsio.

Here are some concepts of the time series data file structure that are relevant to the different modes of operation described in this manual.

Links to geometry
The links between the channels of data in the .tsdf file and the nodes of the surface[s] over which they are displayed is established via channel array information, which is available stored as associated scalars to the nodes in the geometry file (see Section 6.1) or in explicit channels files (see Section 6.4).
Frames
By frames of data, we mean instants in the data stream representing single moments in time. For each frame, there is a set of values that for a spatial distribution or map and map3d needs to know what subset of frames are to be included in the display. To explicitly specify frame numbers, use the -s and -i options described in Section 4. As an example, the command line
        map3d -w -f geomfile.geom@1 -p datafile.tsdf -s 10 130 -i 2
specifies that surface 1 from the geometry file geomfile.geom should be used to display frames 10 to 130, taking every second frame, from run 2 of the time series data file datafile.tsdf.


6.3.2.1 Time series container files (tsdfc):

There is an extension to the graphicsio library that defines a container file format for a set of time series data (.tsdf) files, and can contain parameters extracted from the associated time series. These files are actually small databases and we use a modified (patched actually) version of the GNU Database Library (GDBL) to manage them.

Examples of programs and libraries that provide support for .tsdfc files include Everett, a program by Ted Dustman for initial processing of mapping data, Matmap, a set of MATLAB uilities by Jeroen Stinstra with a similar functionality, and tsdflib (as yet undocumented), a library created by Ted Dustman, Rob MacLeod, Jenny Simpons, and Jeroen Stinstra that provides C-language access to container files.

For more information on container files, see the documentation for the graphicsio library at www.cvrti.utah.edu/~macleod/docs/graphicsio/.


6.3.3 MATLAB data file support

You can also store and read scalar values in .mat files, as a structure with a single field called ``.potvals'', that contains a N x M array, where N is the number of data channels and M is the number of time instants. There are additional fields in the structure that mimic the information available in the graphicsio .tsdf file so--the complete list is as follows:

There will be more of these as we develop the format further so stay tuned.

The commands to make a suitable .mat file are very easy in MATLAB, for example, to load 128 channels of time signals with unit of millivolt from an array sockinfo in MATLAB to a file called mysockdata.mat

    >> sockdata.potvals   = sockinfo(1:128,:);
    >> sockdata.unit = 'mV'
    >> save mysockdata.mat sockdata


6.3.4 Fiducial (ascii) files

A fiducial can be input currently in two ways: via a .tsdfc file, where the potential and fiducial values are stored together, or via a .fids file, a simple ASCII file containing the values for each node.

The characteristics of a .fids file are as follows:

  1. ASCII file
  2. must have the following at the top of the file, on each line:
    1. number of time series, e.g., 1 (map3d only allows 1)
    2. series number (space) pak number
    3. number of nodes (space) list of fiducial types
  3. each successive line contains the node number followed by a list of fiducial values, one corresponding to each type specified on the line with the node numbers

Example: 1 1 -1 256 activation recovery 1 8 212 2 16 225 3 9 214 ... 255 39 248 256 25 237


6.4 Channels and leadlinks

6.4.1 Description of leadlinks and channels information

Channels and leadlinks files, and the arrays they contain, are identical in structure, but they have important functional differences. A run of map3d may require both, either, or neither of these, depending on the structure of the data files and geometries. The basic function of both channels and leadlinks information is to offer linkages between nodes in the geometry and the data that is to be associated with those nodes. The first file type, the channels file, links the nodes in the geometry to specific time signals in a data file; without channel mapping, the only possible assumption is that each node i in the geometry corresponds to the same time signal i in the data file. Any other linkage of geometry and data channel requires there to be channel information, typically either from a separate .channels file or stored with the binary .geom file as an associated scalar value for each node.

Leadlinks are purely for visualization and describe the connection between ``leads'', a measurement concept, with ``nodes'', a geometric location in space. In electrocardiography, for example, a lead is the algebraic difference between two measured potentials, one of which is the reference; ``unipolar'' leads have a reference composed of the sum of the limb electrode potentials. It is often useful to mark the locations of these leads on the geometry, which often contains many more nodes than there are leads. The most frequent use to date has been to mark the locations of the standard precordial ECG leads within the context of high resolution body surface mapping that uses from 32-192 electrodes. Another common application is to mark subsets of a geometry that correspond to measurement sites (values at the remaining nodes are typically the product of interpolation). In summary, leadlinks allow map3d to mark specific nodes that may have special meaning to the observer.

Figure 1 shows an example of lead and channels information and their effect on map3d. See the figure caption for details.

Figure 1: Example of the indirection possible in map3d through the use of leadlinks channels, and channellinks. Lead number 4 points, via the leadlinks array to node number 22. This, in turn, points via the channels array to location 92 in the multiplexed data buffer, which causes the values at time signal 92 to be loaded into location 22 in the internal data array (and displayed by map3d). In a separate, channellinks array, shown below the leadlinks array, the entry in lead 4 says that that lead should actually be labeled `` V1''.
\begin{figure}\centerline{\epsfig{file=figures/map3d-indirection.epsf,height=4in}}
\end{figure}

map3d handles this information in the following manner:

channels
The channels information links nodes in the geometry to individual channels or time series in the data file. For example, the data values associated with node k in the geometry are located in the data location specified by the channel array value channels(k). If channels(k) < 0, then there is no valid data for node k.

Note that map3d uses the channels arrays when loading scalar data into the internal storage arrays! Hence, the action of the channel mapping is not reversible. Should geometry nodes and data channels match one-to-one, there is no need for a channels array. It is also possible to define via a channels array the situation in which a single data channel belongs to two (or more) nodes in the geometry. The most frequent example of this occurs when three-dimensional geometries are ``unwrapped'' into surfaces in which what was a single edge is split and thus present at both ends of the surface.

leadlinks
The leadlinks information is primarily used to identify and mark measurement lead specific within the geometry. The typical use is to select a subset of the nodes to identify the measurement sites--values at other sites might be interpolated or otherwise computed. Leadlinks also provide a means to renumber the labels on the nodes of the geometry in order to, for example, reproduce the numbering scheme used in an experimental setup.

In the leadlinks array each entry refers, by its location in the array, to a particular lead #; the value at that location in the array gives the number of the node in the geometry file to be associated with this lead. For example if lead 4 has a leadlinks entry of 22 ( leadlinks(4) = 22), then map3d will display node 22 in the geometry as ``4'', not ``22'' whenever node marking with leads is selected).

channellinks
There is an extension of the basic scheme which includes a further level of redirection for giving the leads explicit text labels. Channel links are stored as a array of strings, one for each node of the geometry. The channellinks file is organized similarly to a leadlinks file, with each line containing information for one node. However, each line consists of two values, 1) the number of the associated channel and 2) the text string to be used as the label when map3d marks the nodes with channel numbers.

Hence we have the situation of a node number K in the geometry displaying time signals from channel L in the scalar data, but labeled with string ``XXX''.

6.4.2 Source of leadlink and channel information

The sources of channels, leadlinks, and channellinks information are files, or parts of files, as outlined in the following paragraphs.

6.4.2.1 In .geom files

Information for the channels array is stored as an associated scalar with the information in the standard .geom files. At present, there is no leadlinks array stored in the .geom file but this could change in the future.

6.4.2.2 In .mat geometry files

MATLAB geometry files can also contain an channels array is stored as a .channels field in the structure. See Section 6.1.4 for more details.

6.4.2.3 In .leadlinks files

A .leadlinks file is an ASCII file, the first record of which contains a line nnn leads, where nnn is the number of leads to be described in the file (and also one less than the total number of lines in the file). Each following record contains two integer values:

  1. the first number is the number of the lead, as it should appear in any labeling of the associated node.
  2. the second entry in each row is the value of the associated node number in the geometry.
For example, the file for a surface which reads:
    32 Leads
    1   1   
    2   42  
    4   31  
    7   65  
    .   .   
    .   .   
    .   .   
    32  11     <---- 32nd entry in the file, at line 33 of the file.
indicates that there are 32 leads to be linked (the geometry can, often does, contain more than 32 nodes), and that lead #1 is called lead ``1'' and is node 1 in the geometry file. Lead #2 is at node 42, lead #3 is called ``4'' and is found at node 31. Likewise, lead #4 is called ``7'', and is located at node 65, and so on, up to lead #32, called ``32'', at node 11.

Nodes listed in a leadlinks file that is passed to map3d with the -ll option can be marked in a number of ways, described more fully in Table 9 in Section 8.2.3.

6.4.2.4 In .channels files

A channels file is an ASCII file, the first record of which contain a line nnn nodes, where nnn is the number of nodes to be described in the file (and also one less than the total number of lines in the file). There is one line in the file for each node of the geometry to which we wish to associate scalar data. Each following record contains two integer values:

  1. the first number is simply a running counter that indicates the node number with which to associated the second value in the row.
  2. The second value in each row is the channel number for that node; a negative number signifies a node to which there is no data associated.
For example, the file for a surface which reads:
    352 Nodes
    1    123
    2    632
    .    .
    .    .
    22   -1
    23   432
    .    .
    .    .
    352  12
indicates that there are 352 leads to be linked, and that the data value for the first node is located at location 123 of the data file. For node 2, the data value is to be found at location 632, and so on. Node 22 does not have any scalar data associated with it.

6.4.3 Display of lead/channel information

To see how map3d can display the node and lead information, see Sections 7.7 and 8.


6.5 Landmark files

Landmark files contain information for visual cues or landmarks that map3d can draw over the surfaces in order to aid and orient the viewer. Initial use was primarily for coronary arteries, but the idea has expanded to incorporate a number of different orientation landmarks. The original coronary artery class of landmarks requires only that each can be described as a series of connected points, with a radius defined for each point. The coronary landmark is then displayed as a faceted ``pipe'' linearly connecting the points at the centre, with a radius, also linearly interpolated between points, determining the size of the pipe. The landmark file can contain numerous, individual segments of such pipe-work, each of which is drawn separately.

Other classes of landmarks are described below, but all of them can be described in a file with the following general format:

Line number Contents Comments
1 nsegs number of landmark segments in the file
2 1 type nsegpts seglabel segment number (1), type, number of points, label_number
3 X, Y, Z, radius point location and radius of point 1
4 X, Y, Z, radius point location and radius of point 2
. . .
. . .
nsegpts + 2 X, Y, Z, radius point location and radius of last point in segment 1
. 2 type nsegpts seglabel segment number (2), segment type, number of points, and label
. X, Y, Z, radius point location and radius of point 1
. X, Y, Z, radius point location and radius of point 2
. . .
. . .
. X, Y, Z, radius point location and radius of last point in segment 2
. . .
. . .
. . .
. . .

The landmark types defined to date are the following:

Name Graph. object Description
Artery faceted pipe a coronary artery/vein segment
Occlusion coloured sphere an experimental occlusion that could be open and closed
Closure coloured sphere a permanent occlusion that cannot be opened
Stimulus coloured sphere a stimulus site
Lead coloured sphere a particular electrode or lead location
Plane rectangular parallolopiped a visible (but not functional) cutting plane through the geometry (Note: do not confuse this with the cutting planes that map3d provides for slicing through the geometry).
Rod lines rod inserted into needle track to digitize needle electrode locations.
PaceNeedle sphere location of a pacing needle entry point
Cath faceted pipe location of catheter in a vessel
Fiber arrow local fiber direction indicator
RecNeedle sphere location of recording needle entry point
Cannula tube coronary vessel cannulus

Specifying snare, closure, and stimulus requires a single point in the landmarks file, and the resulting sphere is coloured according to a set of values defined in the drawsurflmarks.c routine. At present, the values used are:

Occlusion cyan
Closure blue
Stimulus yellow

and they are not (yet) adjustable by the user.

To specify a plane landmark requires three ``points''

Point X,Y,Z Radius
1 First point of plane Radius of the plane
2 Second point of plane Thickness of the plane
3 Third point of plane not used
The plane is drawn as a polygon with the number of sides controlled by a program variable.

6.5.0.1 Filename conventions:

The standard extension of a landmark file is .lmarks and the filename is specified by the -lm parameter for each surface.

6.5.0.2 Control of landmark display:

for details of how to control the display of landmarks, see Section 8.7.


7 Display features

This section describes the displays that map3d generates and what they mean; for specific information on how to control map3d and the displays, see Section 8.


7.1 Multiple surfaces

The idea of map3d has always been to display multiple sets of data on multiple surfaces; the limitation has been how much flexibility to include in a single invocation of the program. This version of map3d, as opposed to previous versions, can now handle multiple windows each with multiple surfaces. Surfaces can be moved between windows (see Section 8.5.1) When map3d displays multiple surfaces, each can exist in its own full window with its own border and window title bar, or, map3d can build a single main window with multiple sub-windows inside the main window. The user can reposition and resize each of these sub-windows using the Alt(Meta) key and the left and middle mouse buttons respectively. To create this layout of main window and frameless sub-windows, use the -b (borderless windows) option when launching map3d as described in Section 4.3.

7.2 Surface display

The basic forms of display of the surfaces are


7.3 Mesh Rendering

Often the purpose of map3d is to render a geometry consisting of nodes and connectivities and there are several basic modes of rendering this information.

Points:
display just the nodes of the geometry as dots or marked with spheres.
Connectivities:
display the connectivity information for the mesh as lines joining the nodes.
Elements:
treat each polygon in the mesh as an element and render it in a way that shows its surface; for triangles, simple render each triangle surface; for tetrahedra there is no specific rendering in this version of map3d.
Elements and connectivities:
map3d also supports a hybrid mode of rendering that shows outward facing triangles (using the convention of counterclockwise ordering) as elements but backwards facing triangles as connectivities.

map3d also has the ability to render all elements with a lighting model. This is especially useful for displaying the elements of the mesh. Additional controls to note are depth cueing, which can reveal the depth relationships between elements of the mesh.


7.4 Surface Data Display

The main use of map3d is to display scalar data associated with geometry and there are numerous options and controls to facilitate this. The two basic ways of conveying scalar value information are as shaded surfaces and contour lines and map3d supports each separately, as well as in combination. For surface shading, there are several basic rendering modes:

Flat:
each triangle received a single color that depends on the mean value of the scalar value over that triangle.
Gouraud:
the colour of each triangle values linearly with the value at each of the vertices. The current version uses texture mapping to achieve more desirable results, but if your hardware does not support texture mapping, you can toggle it with the g-key.
Banded:
the regions between contour lines have a constant color, even if the contour lines are not visible.
Contours:
this can be a separate rendering mode, or combined with any of the three modes above. Contours are lines that trace iso-values over the surface of the geometry.


7.4.1 Data scaling

There is a wide variety of options available for mapping scalar values to colour and contour levels. One can picture the process as based on four facets:

Extrema:
the extrema of the data and the selected colour maps determine the basic parameters of how value maps to color. map3d maintains a detailed list of data extrema organized both by time signal, time instant and by surface. Thus it is possible to determine extrema based on just the most local of conditions--a particular frame and surface--or by more global conditions--the full range of frames or the full set of surfaces.
Scaling function:
the mapping between value and color occurs according to some mathematical function, the simplest of which is linear. The scaling function uses the selected extrema and describes a complete mapping between value and color.
Mapping:
by scale mapping, we mean how the translation from value to color treats positive and negative values. We may choose to map uniformly between the extrema or to apply different extrema or functions to the positive and negative values.
Color maps:
the color displayed for a particular scalar value depends on the actual range of colors and their order in the color map.

map3d can adjust all four facets of the scaling to create a wide range of displays. We chose to limit some of these options, however, in an effort to create reproducible displays that reflect standard within the field. Of course, we chose our field, electrocardiography, as the basis, a fact for which we make no apologies and simply encourage others to make similar choices for their own field and implement map3d accordingly. Subsequent versions of map3d will support this flexibility.

Below are the specific choices that map3d offers to control data scaling and display

Scale range
map3d supports several selections of range over which to look for extrema. In local range, only the data presently visible are scanned for extrema--this is the default. In the full global range, all the data in the entire dataset are used, even those not presently visible on the display. In between these cases, one can have global in time and local in space, i.e., we scale each surface separately but use all time values for that surface. Or one can select local in time and global in space, in which map3d scans all surfaces for the data extrema, but for each time instant separately The user scaling scope uses the current user-selected values for maximum and minimum for the scaling (see -pl and -ph input parameters in Section 4). The user can also select group scaling, where he assigns surfaces to groups and the range is based on the group min/max (either local in time or global). Groups are assigned by the menu. The user can also do slave scaling, where he assigns one surface (slave) to another's (master) range. The slave surfaces are currently only set through the command line, by placing a -sl num (where num is the surface number of the master) after declaring the slave surface. See Section 8.2.3 and Section 'refsec:scalarparams for details.

Scale function
The scale model describes the way in which scalar data are mapped to colours (or contours). The present choice is linear, but the next version of map3d will include: linear model, which simply maps the data to a range of colours in a completely linear fashion, i.e., colour = K$ \phi$; the logarithmic model, which highlights the lower level data values at the cost of poorer resolution at the higher levels i.e., colour = A log($ \phi$) + B; and the exponential model, which does the opposite, compressing the smaller levels and expanding the higher ones to span a wider colour range, i.e., colour = AeB$\scriptstyle \phi$.

The two schemes with fixed numbers of contours, log/7-levels and log/13-levels both map the upper decade ( $ \phi_{{max}}^{}$ to $ \phi_{{max}}^{}$/10.) of the potential data range into a fixed set of logarithmically spaced values. These values are composed of a mantissa from the standard E6 (1.0, 1.5, 2.2, 3.3, 4.7, 6.8, and 10.) and E12 (1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2, and 10.) number series, and an exponent such that the largest mantissa falls into the range 1.0 to 10. Hence as long as the extrema is known, it is possible to read absolute values from the individual contour lines.

Scale Mapping
There are several different ways to manage the way positive and negative data are treated in the scaling transformations in map3d. The current version supports the simplest, or true mapping, in which the data are used as they are with no consideration of positive or negative values--the color map spreads evenly across the range of the extrema. Subsequent versions will support the symmetric scale mapping, which sets the positive and negative extrema symmetrically--the larger (in the absolute value sense) determines both maximum and minimum data values. Also to appear in the net version is the separate scale mapping, in which the positive and negative extrema are treated completely separately--`half' the colours (and contours) are used for the positive values, half for the negative values. This is equivalent to producing maps with the same number of contours for both positive and negative values, even when the positive data have a different absolute maximum value than the negative data.

Colour Map
There are four different colour maps presently implemented with every chance of more to come. The user can select which colour map to use. The choices currently implemented are:
Jet map
(default) The Jet map is the same as the one used in Matlab. Colours range from dark blue (for negative extrema) through greens (near zero) to dark red (positive extrema). Jet utilizes a minimal set of similar color, particularly of greens and yellows, a complaint of the Rainbow map.

Rainbow map
Colours range in rainbow fashion from blue (for negative extrema) through greens (near zero) to red (positive extrema).

Red (+) to Green (-)
Largest negative value is coloured bright green, dark grays are for the region near zero, and positive values appear red.

Black (+) to White(-)
Grey shades from black for small values to white for large ones.

Note that for each color map, the direction of the mapping to value can be inverted, e.g., in the default directions, blue indicates small or negative values and red indicates large or positive values. Inverted, this map uses red for small values and blue for large values.

Contour spacing
the contour values are a function of the data and the user selection of scale range, model, and mapping (see following items). Fundamentally, the user selects between contour spacing based on the number of contours selected or based on fixed spacing between contours. The actual result depends, in turn, on the range of data values and the desired mapping between value and colour.


7.4.2 Scalar data reference

Related to scaling is the reference channel used for the displayed scalar data. By default, we assume that scalar values already have the right reference and we do nothing to change that. The user can, however, select a new reference and then subtract that reference from all signals in the surface. This is done by selecting the ``Reference lead - single value'' or ``Reference lead - mean value'' from the Picking menu (See Section 8.6). There are at present two types of references that map3d supports:

Mean as reference:
Selecting the mean as reference causes map3d to subtract the average value over each surface for each instant in time from the scalar data on that surface. Selecting the ``Reference lead - mean value'' from the Picking menu