Three Dimensional Surface Interpolation of Scalar Data

Rob MacLeod

June 8, 2000

Subsections

Introduction

This document describes the interpolation programs that are available at the CVRTI for general production use, at least the ones maintained by Rob MacLeod (macleod@cvrti/utah/edu). As the programs grow, so will this document. Most of the text will be aimed at the user and other, more technical, sections will be noted as such. For questions see Rob MacLeod (macleod@cvrti/utah/edu) for more information.

Interp3d

Background

interp3d is a program that uses the Laplacian smoothing method of interpolation to replace bad leads or even interpolate between different lead systems. The technique is described in detail in [1] and was tested for at least tank surface data here at the CVRTI [2]. We can summarize it briefly according to a minimization principle. If we imagine the nodes of a surface separated into good and bad nodes, then all the values at all the bad nodes are adjusted so that the global estimate of the second order surface spatial gradient (the Laplacian) is minimized. While there is not theoretical proof, practice so far has shown the approach to be very robust and not to insert spurious extrema or other unexpected values.

Usage

The interp3d program is written in Fortran and has a relatively simple interface to the user, at least for the most common interpolation task of replacing bad leads. Other uses are possible, including interpolation from one set of nodes to a different one that is a superset of the first. The best example of this would be taking the 117-lead Dalhousie BSPM data and interpolating to the 352-node torso geometry used for display and modeling with this data [2]. For the present discussion, we will focus on the simple use of interp3d, where we have a single geometry and simple wish to replace bad leads.

Geometry files

Any interpolation scheme requires geometric information about the location of node points relative to each other. In interp3d this is provided as part of the program and only the geometries known by the program are available for interpolation. Adding new geometries is fairly simple so just contact Rob MacLeod (macleod@cvrti/utah/edu) if you have one that is not part of the current version of interp3d.

Data files

Potentials for interp3d must always be in the CVRTI graphicsio file format, specifically the .data or .tsdf formats. There are many program that make, display, and edit .data/.tsdf files so if this is new territory for you, contact Rob MacLeod (macleod@cvrti/utah/edu) for more information. The difference between the .data and the .tsdf formats is that .data files can contain more than one time series while a .tsdf always contains a single time series.

The important feature of the .data/.tsdf files that interp3d reads is the ``bad leads information''. The .data/.tsdf file format has an internal list of leads for each time series that are considered ``bad'' and this list is what drives interp3d. However, interp3d does allow setting of additional bad leads at run time, so there are options. Normally, it is best to set up the .data/.tsdf file with a valid bad leads list and then interp3d can run more quickly with less user intervention. To set up the bad leads list, use the makedata program and utilize the bad leads options. Note that in makedata one can set bad leads that are valid for all time series in the .data/.tsdf file and then additional bad leads for each time series.

The input of interp3d is a CVRTI .data/.tsdf file but so is the output; no program is permitted to overwrite .data/.tsdf files. Hence, interpolated files are at least as large as the original input files, and are often in a different format to the input files. This arises because a .data or .tsdf file may or may not contain the actual numbers that make up the main data stream. A .data file may actually contain only a list of .pak or .raw files that is used to seek the actual potential data only at run time. A .tsdf file can also contain a pointer to a single .pak/.raw file. One result is that such .data files/.tsdf are very small and rely on access to a disk volume (often the CD-ROM) for most of their information. The bad leads list does, in contrast, always reside in the .data file--it is not part of the .pak or .raw file format.

A common situation is to have an optical disk or CD-ROM full of .pak files; they must be made available by mounting the optical disk on the Vax in order for the interp3d program to run. 1 The .data file reads the potentials from the .pak files, but the bad leads list from the .data file and combines the two inside interp3d. The resulting output file, however, is always a fully self-contained .data file, with all potential values. This means that the output .data file may be very large and should be moved to optical disk as soon as possible. Once constructed, the interpolated .data file becomes the input source for all subsequent programs that examine or analyze potentials.

Running the interp3d program

There is only one possible (optional) command line argument for interp3d and that is the name of the .data/.tsdf file that is the input of the program.

        interp3d infilename.data
Everything else occurs via interactive dialog with the user at run time. Below is a typical run of interp3d with examples of the types of program questions that arise, and appropriate answers. Comments are marked with << in the right hand side of the listing. Note that each run will produce slight variations in this output depending on the options selected.

interp3d subset1.data    << The program is stored in ~macleod/bin/interp3d
                         << Note the optional specification of the input file.
 Welcome to Interp3D, a program to produce 
 interpolated potentials 

 What type of interpolation are you doing?   << Use the b option for
  Simple bad leads fixing ........... "b"    << fixing bad leads.
  Interpolation between lead sets ... "i"
   [def= b] ? 

 Choose the type of electrode set for interpolation  << If additional geometry
    cvrti_torso (192 leads) .............. " 2"      << types are needed, see
    192 lead tank leadset from Andy 2 .... " 4"      << Rob.
    merged andy3 leads (370 leads) ....... " 5"
    epicardial (64 lead sock) ............ " 6"
    epicardial (242 lead sock) ........... " 7"
    epicardial (490 lead sock) ........... " 8"
   [def= 6]  ?  8
                                          << This next value is set according
                                          << to where the pak files sit.
                                          << It is the value of
                                          << MAP3D_DATAPATH, as set by 
                                          << odisk or by the export command.
    
 Pak/Raw file path read from MAP3D_DATAPATH as /vax/odisk5/bt13nov96pack/
 Should we use this value  (return/n) ?       

 We have a single data file: .//subset1.data

 For file subset1.data                << In bad lead mode, ``n'' is the usual
 Select channels file                 << choice here.  The channels information
 Tank: 64 lead sock .......... s      << comes from the .geom file 
 Tank: 192 lead tank ......... t      << automatically
 Socks: 490 lead sock ........ 4
 Enter a filename ............ f
 No channels at all .......... n
  [def = n ] ? 
 No channels used

 For file subset1.data                     << Pick which part of the 
 How do you want to select frames for      << beat to interpolate,
   Take all frames ..................."a"  << according to standard fiducials.
   Take P-T frames only .............."p"
   Take Q-T frames only .............."q"
   Take QRS frames only .............."r"
   or select interactively ..........."i"
   [def= a ] ? 
 Frame select is    1

 Select the series numbers for the data file subset1.data
 We have a file of type   0 with    5 sets of data

 Choose the the list of series from this file  << Enter the list of time
                                               << series for this file.
 Enter a series number, or -1 to select all   5 of the rest of them
 Enter "q" to quit entering [def=  1 ] ? -1    << This option chooses all
                                               << time series.
 (setupdatafilelist.f)
 Results of the setup are:         << For your information only
 File #  1 is subset1.data
 With channels in 
 There are   5 series:
        1   2   3   4   5

=== Start of file loop file #  1    << The loop through multiple data file
                                    << should there be more than one.

 No channels in the geometry file so we assume defaults  << Information only

=== Start of series loop #  1       << The loop through multiple time series
                                    << in this file.
 Reading file subset1.data
 at series   1

(opendatafile.f)                    << Information
 Open data file ./subset1.data
 has no main header text

 (getinputdata.f)                   << Information
 For the data file subset1.data
 In directory ./
 With header text
     
 We have a file of type  0 with  5 sets of data

 Datafilepath set to/vax/odisk5/bt13nov96pack/   << Information

 (getintputdata.f)                               << Information 
 The data file is open in series   1
 Seriesheader = BT13Nov96           atdr@360
 The fiducial time frames are:
   Q-time:     128
   S-time:     192
   T-time:     349
  Max frames:  555
  #leads:      512
   P-onset:      0
   P-offset:     0
   R-peak:       0
   T-peak:       0

 (getintputdata.f)                                        << Information
 Reading the data in from the file now...

(sortdata.f)                                              << Information
  start and end frames are      1 and    555     
  nleadsinfile is    512 and nchannels is    490

 (setupbadeleads.f)
 There are 12 bad leads in the input data file

 List of bad leads: 
      8     26     27     45    143    163    132    333    372    434
    436    469
 Want to add more to the list (y/return) ?    << Answer yes here if you
                                              << wish to add to the list.
 (setbadleads.f)                << Information
 There are 490 leads in all
 Of these 478 are good and  12 bad
 Bad leads are now:
    8   26   27   45  143
  163  132  333  372  434
  436  469

 There is no leadlinks file for leadtype  8 and geomtype 14   << Information
 So we will assume leads and geometry are the same  

 Going to the subroutine that performs the interpolation     << Information
 File #  1 Series #    1
 with the leadtype set to       8
 and the geometry type set to     14
 solve_mode is set to              1
 solve_type is set to              3
 with the following files:
 geomfname =   /u/macleod/torso/geom/socks/sock490/490sock
 nbourfile = /u/macleod/torso/geom/socks/sock490/490sock.nbours
 leadfile =  
 storefile=  p2_3200_77_32-interp
 Read    490 nodes of data from the file

 (readnbours.f)                                       << Information
 Finished reading neighbour links for    490 points
 From file /u/macleod/torso/geom/socks/sock490/490sock.nbours

 (interp3dsub.f)                                           << This make take
 Now set up the   555 right hand sides for the solver...   << several minutes.

 (interp3dsub.f)  << Information
 GO solve the system  490 by   12 system
  with  555 right hand sides now...

 (la_lsq_solver.f)   << Information
 Going to LAPACK SGELS solver with  490 rows and    12 columns of matrix...
 Leading dimension of matrix is    700

 (la_lsq_solver.f)                        << This part is very fast usually.
 Back from solving the matrix 
 Time for solution was      1 seconds

 Optimal size of work array would be   17772.   << Ignore this.
 we have is currently set at   560000

 (interp3dsub.f)    << Information
 Soluton ready -- now load the solutions arrays...

 (manageoutdata.f)   << Information
 Since this is the first time through, set qdefaults to false

 Enter the name of the output directory name file to work with 
 [Default: ./ ]  ?          << Enter the output directory if it is not
                            << the one you were in when you started 
                            << the program.
 (manageoutdata.f) outfilename = _interp is assumed to be a suffix
 Append it to infilename = subset1.data

 (checkdfilename.f)
 dirname =                                                                                 
 filename = _interp                                                                         
 cextension =           

(checkdfilename.f)               << Information
 Changing file extension so filename is _interp
 Enter the name of the output .data file to work with 
 [Default: subset1_interp.data ]  ?        << Enter the output filename.

 The file ./subset1_interp.data exists                << Dialog that
 To enter new value ......................... "n"     << happens only when
 To exit here and leave things untouched .... "e"     << the output file
 or to clobber the old version ........... . return  ?<< already exists.
 File: ./subset1_interp.data deleted                  << NEVER overwrite
 (manageoutdata.f)                                    << the input file!!!!
 Try and create file ./subset1_interp.data

 Created a new .data file called    << Information
     subset1_interp.data
 in directory 
     ./
 Header text is :    << Information
  -- interpolated  and extracted with interp3d

 (manageoutdata.f)   << Information
 Write the output .data file series with
 series # =     1
 nmaps    =   555
 nleads   =    490
 series sheadertext = 
  BT13Nov96           atdr@360
 ...Done!

 Do you want to accept defaults from this point on      << Useful option when
 At least until a new filename is needed (y/return) ? y << no more adjustment
                                                        << of bad leads is
 Defaults set true at end of loop #  1                  << necessary.


=== Start of series loop #  2    << Here we start the second loop
 qdefaults = T

This same loop runs for each time series until finally.

 Defaults are still true at end of loop #  5   << This run had 5 times series

 To go again with new input .......... "n"     << Chance to do another file.
 or just exit here ................. return   ?

The result of this run is a file called subset1_interp.data that contains the original good leads and the repaired bad leads. It is ready for use by all other programs that read .data files.

Bibliography

1
T.F. Oostendorp, A. van Oosterom, and G.J. Huiskamp.
Interpolation on a triangulated 3D surface.
J. Comp. Physics, 80:331-343, 1989.

2
R.S. MacLeod, R.L. Lux, and B. Taccardi.
Translation of body surface maps between different electrode configurations using a three-dimensional interpolation scheme.
In P.W. MacFarlane, editor, Electrocardiology '93: Proceedings of the International Congress on Electrocardiology, XXth Annual Meeting, pages 179-182. World Scientific, Singapore, 1993.

About this document ...

Interpolation of Data Files

This document was generated using the LaTeX2HTML translator Version 98.1p1 release (March 2nd, 1998)

Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer Based Learning Unit, University of Leeds.

The command line arguments were:
latex2html -split 3 -no_white -link 3 -no_navigation interp.

The translation was initiated by Rob MacLeod on 2000-06-08




Rob MacLeod
2000-06-08