Example i42: Computing Dipole Parameters from a Magnetic field

Computes dipole parameters using a precomputed magnetic field (from example i41). The dipole parameters used to generate the magnetic field was located at (97, -130, 47) with varying orientations.


The comfile run by this example is as follows:


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

$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;


#
# Data points
#
#
# Electrodes
#
fem def data;r;$example/electrodes_mag field num_field 3;
fem exp data;$OUT/electrodes_mag as electrodes_mag offset $MAGOFFSET;
fem def xi;c close;


#
# 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_i42.com 09-Dec-2002 1.3k bicubic_bilinear.ipbase 09-Dec-2002 7.8k dipole_guess.ipsour 18-Jan-2011 1.3k 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 09-Dec-2002 1.5k opti_mag.ipopti 18-Jan-2011 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 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_i42.tar.gz 19-Jan-2011 75k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:15:58 201622
cm-debugSuccessSat Mar 5 02:26:31 2016343
mips-irix
cmSuccessSun Aug 19 05:12:29 2007228
cm-debugSuccessWed Aug 15 05:44:28 20071832
cm-debug-clear-mallocSuccessSat Jul 28 06:08:28 20071909
cm-debug-clear-malloc7SuccessMon Aug 13 05:28:11 20071925
cm64SuccessSun Aug 19 05:38:02 2007255
cm64-debugSuccessFri Aug 10 04:21:22 20072200
cm64-debug-clear-mallocSuccessThu Apr 1 12:49:56 2004836
rs6000-aix
cmSuccessWed Mar 4 01:18:09 200918
cm-debugSuccessMon Mar 2 02:09:55 2009463
cm64SuccessWed Mar 4 01:19:00 200920
cm64-debugSuccessTue Mar 3 02:09:03 2009488
x86_64-linux
cmSuccessSun Mar 6 00:01:51 201612
cm-debugSuccessSat Mar 5 00:07:46 201692

Testing status by file:


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

Input last modified: Tue Jan 18 19:15:21 2011


CMISS Help / Examples / i / i4 / i42