Example i44: Computing Dipole Parameters from a Magnetic and Potential field

Computes dipole parameters using both precomputed magnetic and potential fields as the residual function. The electric electrodes have been "positioned" by projecting the magnetic sensors onto the torso surface.


The comfile run by this example is as follows:


$OPTIM_MAGN=0;
$OPTIM_POTL=0;
$OPTIM_BOTH=1;

$TSTART="1.0";
$TEND="3.1";
$TSTEP=1;
# only works for 1 because of CALC_SAMPLE_FROM_TIME/GETDIPOLE 
# differences in UPOPTI/MAGSOL
$FREQ=1;


$EXPORT=1;
$DIPOLE=1;

$OUT="output";
$FORMAT="binary";

$MAGOFFSET=20000;
$POTOFFSET=30000;

if(!defined $example) 
{  
    $example='.' ;
    $OUT="output";
} else{
    $OUT=".";
}

fem def para;r;$example/torso_dipole
fem def coor 3,1;
fem def base;r;$example/bicubic_bilinear;

fem def node;r;$example/skin;
fem def elem;r;$example/skin_lin;


if($EXPORT)
{
    fem export node;$OUT/torso as torso;
    fem export elem;$OUT/skin  as skin;
}


#
# Group nodes
#
fem group node 29      as FIXEDNODE;
fem group node 1,290   as SURFENDS;
fem group node 2..289  as SURFNORM;
$COMPNODES="1..290"

fem def equa;r;$example/laplace_nr1 reg all;
fem def mate;r;$example/mate_nr1    reg all;
fem def init;r;$example/noflux_nr1  reg all;
fem def sour;r;$example/dipole_guess reg $DIPOLE;
fem def solv;r;$example/static_nr1 reg all;

#
# Read in recorded/known solutions
#
fem read matr;$example/mfi nss 1      # magnetic fields at sensors
fem read matr;$example/phi             # potential fields at electrodes

Additional testing commands:


if($OPTIM_MAGN)
{
  fem def sour;r;$example/dipole_guess reg $DIPOLE;
  $FREQ=1 

  list time
  for ($TIME=$TSTART;$TIME<$TEND;$TIME+=$TSTEP)
  {
    print "\n\n\n\n"
    print "*****************************************\n"
    print "Current Time in Optimisation Loop = $TIME\n"
    print "*****************************************\n"

    fem def opti;r;$example/opti_mag reg $DIPOLE time $TIME
    optimise time $TIME reg $DIPOLE
    fem eva resid wrt magnetic list 1 tstart $TIME tend $TIME freq $FREQ
    print "\n\n"
    list time
    fem li source
    print "End Optimisation Loop = $TIME\n"
    print "*****************************************\n\n\n\n"
  } 
}

if($OPTIM_POTL)
{
  fem def sour;r;$example/dipole_guess reg $DIPOLE;

  list time
  #for $TIME ($TSTART..$TEND)
  for ($TIME=$TSTART;$TIME<$TEND;$TIME+=$TSTEP)
  {
    print "\n\n\n\n"
    print "*****************************************\n"
    print "Current Time in Optimisation Loop = $TIME\n"
    print "*****************************************\n"

    fem def opti;r;$example/opti_pot reg $DIPOLE time $TIME
    optimise time $TIME reg $DIPOLE
    fem eva resid wrt magnetic list 1 tstart $TIME tend $TIME freq $FREQ
    print "\n\n"
    list time
    fem li source
    print "End Optimisation Loop = $TIME\n"
    print "*****************************************\n\n\n\n"
  } 
}


if($OPTIM_BOTH)
{
  fem def sour;r;$example/dipole_guess reg $DIPOLE;

  list time
  #for ($TIME=$TSTART;$TIME<=$TEND;$TIME+=$TSTEP)
  #for $TIME ($TSTART..$TEND)
  for ($TIME=$TSTART;$TIME<$TEND;$TIME+=$TSTEP)
  {
    print "\n\n\n\n"
    print "*****************************************\n"
    print "Current Time in Optimisation Loop = $TIME\n"
    print "*****************************************\n"

    fem def opti;r;$example/opti_both reg $DIPOLE time $TIME
    optimise time $TIME reg $DIPOLE
    fem eva res wrt magnetic list 1 tstart $TIME tend $TIME freq $FREQ
    print "\n\n"
    list time
    fem li source
    print "End Optimisation Loop = $TIME\n"
    print "*****************************************\n\n\n\n"
  }
}


Files used by this example are:

Name                     Modified     Size

example_i44.com 15-Jan-2003 1.2k bicubic_bilinear.ipbase 09-Dec-2002 7.8k dipole_guess.ipsour 09-Jan-2003 1.2k electrodes_mag.ipdata 09-Dec-2002 522 laplace_nr1.ipequa 26-May-2003 1.3k mate_nr1.ipmate 09-Dec-2002 859 mfi.ipmatr 18-Jan-2011 3.0k noflux_nr1.ipinit 09-Dec-2002 575 opti_both.ipopti 18-Jan-2011 1.6k opti_mag.ipopti 09-Dec-2002 1.5k opti_pot.ipopti 09-Dec-2002 1.5k phi.ipmatr 09-Dec-2002 1.1k skin.ipnode 09-Dec-2002 258k skin_lin.ipelem 09-Dec-2002 118k static_nr1.ipsolv 13-Apr-2007 1.2k surface.ipdata 16-Jan-2003 1.1k surface.ipxi 16-Jan-2003 610 test_output.com 09-Dec-2002 2.0k torso_dipole.ippara 21-Feb-2003 5.9k

Download the entire example:

Name                      Modified     Size

examples_i_i4_i44.tar.gz 19-Jan-2011 76k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:21:09 201642
cm-debugSuccessSat Mar 5 02:33:20 2016409
mips-irix
cmSuccessSun Aug 19 04:56:49 2007215
cm-debugSuccessWed Aug 8 05:16:37 20071612
cm-debug-clear-mallocSuccessSat Aug 11 05:23:22 20071655
cm-debug-clear-malloc7SuccessMon Aug 6 05:47:07 20071625
cm64SuccessSun Aug 19 05:16:33 2007242
cm64-debugSuccessFri Aug 3 04:35:52 20071868
cm64-debug-clear-mallocSuccessThu Apr 1 12:54:22 2004735
rs6000-aix
cmSuccessWed Mar 4 01:17:28 200917
cm-debugSuccessMon Mar 2 02:05:04 2009395
cm64SuccessWed Mar 4 01:18:12 200918
cm64-debugSuccessTue Mar 3 02:07:11 2009408
x86_64-linux
cmSuccessSun Mar 6 00:02:17 201623
cm-debugSuccessSat Mar 5 00:10:31 2016167

Testing status by file:


Html last generated: Sun Mar 6 05:51:39 2016

Input last modified: Tue Jan 18 19:14:12 2011


CMISS Help / Examples / i / i4 / i44