Example i61: Normal Slow Wave Electrical Activity on a Stomach Slice

This example simulates normal slow wave activity from a slice of the visible human stomach. The dominant pacemaker region is located in the corpus region. This simulation runs for approximately 50 seconds and produces 2 slow waves. There is a dominant frequency of 2.9 cpm at the corpus and 2.1 cpm at the antrum.

Potential solutions on the stomach slice for at 4 time steps each 3 seconds appart are shown below:


The comfile run by this example is as follows:

# Stomach slice 

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


$EXPORT=1;
$HISTORY=1;
$HISTFILE="$OUT/stomach";


fem define para;r;$example/min;
fem define coor 3,1
fem define node;r;$example/stomach_slice
fem define base;r;$example/refinedstomach  
fem define elem;r;$example/stomach_slice


# This is from Martin's transform.com (VHToComp)
#
# Translate the centre of the model to the origin before the rotation
fem change node translate by -288.0,-202.66667,0.0;

# Make sure we do the 180 degree rotation before the 2nd translation
fem change node rotate by 180 by 0,0,0 axis 0,0,1;

# By eye I think the final translation should be
fem change node translate by 0.0,-160.0,540.0;


fem define fibr;r;$example/stomach_slice
fem define elem;r;$example/stomach_slice fibre
fem define grid;r;$example/stomach_slice
fem update grid geometry


if($EXPORT)
{
   fem export node;"$OUT/stomach" as stomach;
   fem export elem;"$OUT/stomach" as stomach;
}


fem group grid external as BOUNDARY;
fem group grid element 33,34,25,26,9,10,17,18,1,2 as FUNDUS


# Group the different layers
fem group grid element 33..40 as LM;
fem group grid element 25..32 as ICC_MY;
fem group grid element 9..16 as CM1; 
fem group grid element 17..24 as ICC_SEP; 
fem group grid element 1..8 as CM2; 


# Group the faces to allow connection
fem group grid face xi3 low element 33..40 as ICC1;
fem group grid face xi3 low element 25..32 as ICC2; 
fem group grid face xi3 low element 9..16 as ICC3;
fem group grid face xi3 low element 17..24 as ICC4; 


fem update grid conn grid ICC1 direction 3;
fem update grid conn grid ICC2 direction -3;
fem update grid conn grid ICC3 direction 3;
fem update grid conn grid ICC4 direction -3;

fem define equa;r;$example/refinedstomach class 1,2;
fem define cell;r;$example/refinedstomach class 1,2;
fem define mate;r;$example/epsilon_control_curves/generated class 1,2 cell
fem define mate;r;$example/sigma_control_curves/generated class 1,2


fem define init;r;$example/refinedstomach class 1,2
fem define solv;r;$example/refinedstomach class 1
fem define solv;r;$example/refinedstomach2 class 2


if ($HISTORY)
{
   # Open a history file.
   fem open history;$HISTFILE write variables yqs niqlist 1 binary;
}


# Solve.

#$STEP_TOTAL=6000;
$STEP_TOTAL=1000;
foreach $STEP ( 0..$STEP_TOTAL ) 
{
   $TIME = $STEP/20;

   if ($STEP == 0)
   {
      fem solve to 0 class 1,2
   }

   else 
   {
      fem update grid stimulus grid ICC_MY,ICC_SEP up_potential diffusion 0.03 direction 3;
      fem solve restart to $TIME class 1,2;
   }


   if ($EXPORT)
   {
       if ( ($STEP%20 == 0) & ($TIME <= 300) )
       {
         $FILENAME=sprintf("field%05d",$TIME);
         print "*** Exporting at Time $TIME and Step $STEP of ${STEP_TOTAL}\n";      
         fem export elem;"$OUT/$FILENAME" field as stomach;
         system( "gzip -f \"$OUT/$FILENAME.exelem\" &" );

         print "*** Calculating dipole sources\n";
         fem def source;c grid one_dipole grregion 1 grclass 1 time $TIME;
      }
   }


   if ($HISTORY)
   {
      if ($STEP%20 == 0) 
      {
         # Write history information.
         fem write history time $TIME variables yqs niqlist 1 class 1,2 hist all binary;
      }
   }
}


#
# Write out the dipole source
#
fem define sour;w;dipole grid grregion 1 grclass 1;
fem export sour;$OUT/dipole_all as dipole;



if ($HISTORY)
{
   # Close the history file.
   fem close history binary;


   # Export electrode for the LM layer to unemap.
   $SIGNALFILE="$OUT/LM";
   $COMPPTS="61210,62970,64710,66450,68190,69930,71670,73410";
   fem evaluate electrodes;$SIGNALFILE history $HISTFILE from grid yqs iy 1 electrodes $COMPPTS binary;
   fem def export;r;$example/signal;
   fem export sign;$SIGNALFILE signal $SIGNALFILE electrodes;


   # Export electrode for the ICC_MY layer to unemap.
   $SIGNALFILE="$OUT/ICC_MY";
   $COMPPTS="51290,52470,53630,54790,55950,57110,58270,59430";
   fem evaluate electrodes;$SIGNALFILE history $HISTFILE from grid yqs iy 1 electrodes $COMPPTS binary;
   fem def export;r;$example/signal;
   fem export sign;$SIGNALFILE signal $SIGNALFILE electrodes;


   # Export electrode for the CM1 layer to unemap.
   $SIGNALFILE="$OUT/CM1";
   $COMPPTS="25130,28050,30950,33850,36750,39650,42550,45450";
   fem evaluate electrodes;$SIGNALFILE history $HISTFILE from grid yqs iy 1 electrodes $COMPPTS binary;
   fem def export;r;$example/signal;
   fem export sign;$SIGNALFILE signal $SIGNALFILE electrodes;


   # Export electrode for the ICC_SEP layer to unemap.
   $SIGNALFILE="$OUT/ICC_SEP";
   $COMPPTS="46630,47210,47790,48370,48950,49530,50110,50690";
   fem evaluate electrodes;$SIGNALFILE history $HISTFILE from grid yqs iy 1 electrodes $COMPPTS binary;
   fem def export;r;$example/signal;
   fem export sign;$SIGNALFILE signal $SIGNALFILE electrodes;


   # Export electrode for the CM2 layer to unemap.
   $SIGNALFILE="$OUT/CM2";
   $COMPPTS="1830,4750,7650,10550,13450,16350,19250,22150";
   fem evaluate electrodes;$SIGNALFILE history $HISTFILE from grid yqs iy 1 electrodes $COMPPTS binary;
   fem def export;r;$example/signal;
   fem export sign;$SIGNALFILE signal $SIGNALFILE electrodes;


   system(" rm $HISTFILE.binhis ");
}


Additional testing commands:


#
# Convert signal files to ascii format for testing
#
fem convert sign from bin infile CM1 outfile CM1;
fem convert sign from bin infile CM2 outfile CM2;
fem convert sign from bin infile ICC_MY outfile ICC_MY;
fem convert sign from bin infile ICC_SEP outfile ICC_SEP;
fem convert sign from bin infile LM outfile LM;


Files used by this example are:

Name                     Modified     Size

example_i61.com 27-Mar-2008 5.2k ICCcmiss_new.cml 11-Mar-2008 8.9k draw.com 09-Apr-2008 2.8k epsilon_control_curves/ 12-Mar-2008 - field.exelem 11-Mar-2008 1.4M grid.exelem 11-Mar-2008 1.0M min.ippara 27-Mar-2008 5.9k refinedstomach.ipbase 11-Mar-2008 8.3k refinedstomach.ipcell 11-Mar-2008 3.5k refinedstomach.ipequa 11-Mar-2008 1.5k refinedstomach.ipinit 11-Mar-2008 768 refinedstomach.ipnode 11-Mar-2008 382k refinedstomach.ipsolv 11-Mar-2008 2.2k refinedstomach2.ipsolv 11-Mar-2008 2.4k sigma_control_curves/ 12-Mar-2008 - signal.ipexpo 11-Mar-2008 712 stomach.exelem 11-Mar-2008 65k stomach.exnode 11-Mar-2008 56k stomach_slice.ipelem 11-Mar-2008 16k stomach_slice.ipelfb 11-Mar-2008 8.3k stomach_slice.ipfibr 11-Mar-2008 55k stomach_slice.ipgrid 11-Mar-2008 2.3k stomach_slice.ipnode 11-Mar-2008 95k test_output.com 11-Mar-2008 319

Download the entire example:

Name                      Modified     Size

examples_i_i6_i61.tar.gz 16-Apr-2008 909k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:50:54 2016225
cm-debugSuccessSat Mar 5 03:56:52 20161062
rs6000-aix
cmSuccessWed Mar 4 01:54:30 2009431
cm-debugSuccessMon Mar 2 03:39:11 20093789
cm64SuccessWed Mar 4 01:56:05 2009446
cm64-debugSuccessTue Mar 3 04:17:16 20093827
x86_64-linux
cmSuccessSun Mar 6 00:06:11 2016125
cm-debugSuccessSat Mar 5 00:19:47 2016621

Testing status by file:


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

Input last modified: Tue Apr 15 09:40:29 2008


CMISS Help / Examples / i / i6 / i61