uemg: uterine emg simulator. - formation, recherche, … ·  · 2012-10-03uemg: uterine emg...

4
uEMG: Uterine EMG simulator. J Laforet 1 , C Marque 1 , 1 UMR 6600, University of Technology Compiegne, France; Abstract The uterine electrical activity can be realistically modeled by representing the principal ionic dynam- ics at the cell level, the propagation of electric activ- ity at the tissue level and to the skin surface. A simplified model based on the physiology was already presented [3]. We were able to simu- late 0-dimension to 2.5-dimension grids of muscle cells. We developed a parallel integration based on shared memory by using python standard libraries to improve the computational effectiveness of the simulations. We present here the implementation of the multi- scale model as a stand-alone simulation software, packaged following the Python standards. Keywords Simulation, Electro-physiological signals, uterus Introduction The sequence of contraction and relaxation of the my- ometrium results from the electrical activity associated to the generation and propagation of cellular action poten- tial bursts. The uterine electrical activity can be measured noninvasively on the abdomen by standard electrodes and it is referred to as electrohysterogram (EHG) [1]. At the myometrial level, the cellular action poten- tial generation and propagation have been previously modeled as function of a large number of electro- physiological parameters related to ionic dynamic [2]. This model is physiology-based and has been demon- strated to be representative of the main ionic mechanisms responsible for the genesis and evolution of the uterine electrical activity [2]. However, this model is computa- tionally demanding and therefore unsuitable for a direct integration in a multi-scale approach. In view of this challenging objective, we have defined a new simplified physiology-based model of the electrical activity generation at the cell level and of the electrical propagation at tissue level, based on the full model de- scribed in [3]. Unfortunately, even the simplified model is still com- putationally demanding for large amount of cells. To step closer to obtain full organ simulations in a decent time, we realized a parallel implementation of the models inte- gration. This can help us reduce the computation time by a factor up to 25. Software architecture We implemented both Red6 and Red3 models using Python (version 2.7) in an object oriented approach. The code will be published under an open-source license once we exit the current close alpha stage. Its required depen- dences are only common Python modules beside the stan- dard library (Numpy and Scipy). It can be executed under Mac-OS X , Windows, and GNU/Linux systems. In this section we describe the main modules of the simulator package. Cell_mdl This module contains the cell/tissue model classes. First, we defined a generic cell model class from which Red6 and Red3 classes inherit. It enables us to define all common elements in the models only once, in the par- ent class. At the tissue level, the cells are arranged into a Cartesian grid. This tissue model can be 0D (a single cell), 1D (a cable-like line of cells), 2D (a flat surface), or 2.5D (a flat surface with non-null thickness). The grid is represented directly by a N-dimensional state array where each element represent a cell which is electrically cou- pled with its direct neighbors (2, 4 or 6 depending on the dimensions). For 2D and 2.5D tissue model, in order to simulate a simple model of cylindrical geometry, the border in one of the dimensions of the model may be considered as the neighbor of the opposite border. Int_mdl This module provides the integrators to compute the models from the previous module. We implemented two methods to compute the models. The first method is the serial integration, which computes the model by using only one process. This is the usual way to integrate such models, but it is ineffective on modern multi-core CPUs as only one of the cores is used. For a huge number of cells or for a long simulation duration, the computa- tion time will rise to an unacceptable level. To improve the performance of the model (in term of computational time), parallel computing can be used. The idea is to di- vide the size of the tissue model into several processes which are running in parallel so that the global execution decreases. A different process computes each part of the tissue model and for each time step, the processes share their

Upload: lyquynh

Post on 28-May-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

uEMG: Uterine EMG simulator.

J Laforet1, C Marque1,

1UMR 6600, University of Technology Compiegne, France;

Abstract

The uterine electrical activity can be realisticallymodeled by representing the principal ionic dynam-ics at the cell level, the propagation of electric activ-ity at the tissue level and to the skin surface.

A simplified model based on the physiology wasalready presented [3]. We were able to simu-late 0-dimension to 2.5-dimension grids of musclecells. We developed a parallel integration based onshared memory by using python standard librariesto improve the computational effectiveness of thesimulations.

We present here the implementation of the multi-scale model as a stand-alone simulation software,packaged following the Python standards.

Keywords Simulation, Electro-physiological signals,uterus

Introduction

The sequence of contraction and relaxation of the my-ometrium results from the electrical activity associated tothe generation and propagation of cellular action poten-tial bursts. The uterine electrical activity can be measurednoninvasively on the abdomen by standard electrodes andit is referred to as electrohysterogram (EHG) [1].

At the myometrial level, the cellular action poten-tial generation and propagation have been previouslymodeled as function of a large number of electro-physiological parameters related to ionic dynamic [2].This model is physiology-based and has been demon-strated to be representative of the main ionic mechanismsresponsible for the genesis and evolution of the uterineelectrical activity [2]. However, this model is computa-tionally demanding and therefore unsuitable for a directintegration in a multi-scale approach.

In view of this challenging objective, we have defined anew simplified physiology-based model of the electricalactivity generation at the cell level and of the electricalpropagation at tissue level, based on the full model de-scribed in [3].

Unfortunately, even the simplified model is still com-putationally demanding for large amount of cells. To stepcloser to obtain full organ simulations in a decent time,we realized a parallel implementation of the models inte-gration. This can help us reduce the computation time bya factor up to 25.

Software architecture

We implemented both Red6 and Red3 models usingPython (version 2.7) in an object oriented approach. Thecode will be published under an open-source license oncewe exit the current close alpha stage. Its required depen-dences are only common Python modules beside the stan-dard library (Numpy and Scipy). It can be executed underMac-OS X , Windows, and GNU/Linux systems.

In this section we describe the main modules of thesimulator package.

Cell_mdl

This module contains the cell/tissue model classes.First, we defined a generic cell model class from whichRed6 and Red3 classes inherit. It enables us to define allcommon elements in the models only once, in the par-ent class. At the tissue level, the cells are arranged intoa Cartesian grid. This tissue model can be 0D (a singlecell), 1D (a cable-like line of cells), 2D (a flat surface), or2.5D (a flat surface with non-null thickness). The grid isrepresented directly by a N-dimensional state array whereeach element represent a cell which is electrically cou-pled with its direct neighbors (2, 4 or 6 depending on thedimensions).

For 2D and 2.5D tissue model, in order to simulate asimple model of cylindrical geometry, the border in oneof the dimensions of the model may be considered as theneighbor of the opposite border.

Int_mdl

This module provides the integrators to compute themodels from the previous module. We implemented twomethods to compute the models. The first method is theserial integration, which computes the model by usingonly one process. This is the usual way to integrate suchmodels, but it is ineffective on modern multi-core CPUsas only one of the cores is used. For a huge numberof cells or for a long simulation duration, the computa-tion time will rise to an unacceptable level. To improvethe performance of the model (in term of computationaltime), parallel computing can be used. The idea is to di-vide the size of the tissue model into several processeswhich are running in parallel so that the global executiondecreases.

A different process computes each part of the tissuemodel and for each time step, the processes share their

results. For this study, we developed an integration modelbased on shared memory.

VC_mdl

This module implements the propagation of signals to-wards the skin surface. We adopt the model proposedin [4], which allows to model the surface EHG in thespatial frequency domain as the product of an electricalsource, the myometrial activity, and an analytical expres-sion representing the transfer function of the volume con-ductor.

The implementation follows the same pattern as cellmodels. The main difference between the specialisedclasses is that VC1D takes a 1D model as input (cablelike) whereas VC2D takes a 2D model.

Elec_model

The Elec_model modules is still under developpement.It’s goal is to provide a simple model of electrode grids toconvert the surface data provided by the simulations intoEHG like signals.

The actual version takes the weighted sum of the sig-nals under and arround the electrodes. The weights aredefined by a 2D gaussian fonctions centered on each elec-trode of the grid.

Other modules

TS_Tools This module will provide the collection of sig-nal processing methods dedicated to uEMG. It willenable to perform all signal processing operationwithin Python, using the same environment as thesimulation.

Makemovie Librabry used by the makemovie.pyscript which creates videos from surface simulationresults.

shmarray Shared memory arrays module, written byDavid Baddeley. It is used by the parallel compu-tations and has been included for ease of installation(distributed under BSD license).

Simulating uEMG signals

This section presents the use of our software to simu-late uterine electrical activity. It assumes uEMG, Pythonand the required library are installed on the system. Allexample instructions are to be typed in the python inter-pretor.

The first step is to import uEMG module into the inter-pretor. It will then import all required modules automati-cally. This is realised typing the following instruction:

i m p o r t uemg

Then we define variables holding the simulation pa-rameters. Nx and Ny are the dimension of the tissuemodel (in number of cells) and tmax is the duration ofthe signals (in milliseconds).

Nx , Ny = 100 , 100tmax = 10 000

Now we can call uemg to create the tissue model, usingthe previously defined variables. mdl_r will be our tissuemodel, it has been created using the cell_mdl.Red3 class,so its uterine cell model will be Red3. As we want a flat2D surface we specify that Nz (the thickness) is null andthat the model is not cylindrical.

mdl_r = uemg . c e l l _ m d l . Red3 ( Nx=Nx ,Ny=Ny , Nz=0 , c y l = F a l s e )

To Modify any parameter on the cell/tissue model, wesimply change the value of the member from the mdl_r

object. If changing one parameter has effect on anotherone, this effect will be automatically applied. Here wejust change the dimensions of the cells along X and Y.These dimensions are in µm.

mdl_r . hx = 0 . 0 6mdl_r . hy = 0 . 0 6

To obtain information on an object you can use theprint command. For cell/tissue models, it will output thetype and dimensions:

p r i n t ( mdl_r )

The next step is to choose the integration method wewill use to compute the simulation at tissue level. We cre-ate int_mp a parallel integrator using shared memory andworking over all the available cores. To limit the numberof cores used, it is possible to specify a number as secondargument of the mdl_int.IntParaMP class initializer, thefirst one is always the cell/tissue model to work on.

in t_mp = uemg . m d l _ i n t . In tParaMP ( mdl_r )

To run the simulation we call the method compute(. . . )

of the int_mp object. Its arguments are the duration ofsimulated signals, and the electrical stimulation area de-fined by its coordinates [xmin, xmax, ymin, ymax] (innumber of cells).

in t_mp . compute ( tmax , [ 1 , 100 , 1 , 4 ] )

This computation will take between a few seconds andseveral hours depending on the model dimension and theCPU used. On an average desktop workstation, the ex-ample given in this section should take a few minutes torun.

It is then possible to save the data at uterine level forlater use:

in t_mp . save ( ’ t e s t ’ )

This will generate binary files holding the time and sig-nals vectors (the signal for each cell is saved, it can takeup to a few Gb for big models). It also save a text file con-taining the description of the simulation: type of modeland integration, parameters value. . .

To obtain surface EMG we will filter the electrical sig-nals generated at the myometrium level through a vol-ume conductor. We then create such an object using thevc_mdl.VC2D class, as our data are 2D.

VC = uemg . vc_mdl . VC2D( mdl_r ,in t_mp . t , in t_mp .Vm. T )

Then we apply the volume conductor to the data:

VC. compute ( in t_mp . t , in t_mp .Vm. T )

We obtain surface data at the skin level.To get the final EMG signal we setup an electrode grid

model:

EG = uemg . e l e c _ m d l . g r i d ( t = in t_mp . t ,V=VC. P h i S u r f a c e . T , Nsig =2 ,D e l t a =3 , Eray = 0 . 7 )

This will sum the signals that are detected by each elec-trode. Here we set a 2 by 2 matrix of electrodes. Wefinally computes these 4 signals and the EG object cannow display the simulated EMG signals, using the meth-ods apply(. . . ) and show(. . . ):

EG . a p p l y ( )EG . show ( )

Results

In this section we’ll first present the signals obtainedby following the previously detailed instructions. We alsopresent some simulations results to demonstrate the abil-ities of the software.

Figure 1: Representation of the electrical potential at theuterine level as obtain by following the tutorial. Electricalpotential amplitude is color-coded.

Figure 1 shows a snapshot of the video ani-mation that can be obtain by running the script

uemg_makemovie.py on the simulated data saved inthe tutorial. This simulation is a simple, unphysiologi-cal, test-case in which waves of action potential propa-gate along one direction.

Figure 2: Spatial electrode summation functions. Sumweights are color-coded.

Figure 2 is the representation of all the weight func-tions used to simulate the recording of all the cells’ po-tential by an electrode grid. Each electrode signal is ob-tain by the weighted sum of the cells signals, with thecells underneath the electrode having the highest weightand far cells almost zero.

Figure 3: Simulated mono-polar EHG signals for the 4electrodes of the grid.

Finally, figure 3 shows the simulated EHG signals ob-tained after both the volume conductor filtering and thesummation by the simple electrode model.

Figure 4 shows another example of uterine leveldata. It is also a snapshot from a video produced byuemg_makemovie.py. However the data used arerepresenting a 2D surface shaped as a cylinder. In thisexample muscle thickness is still null.

Figure 5 has been obtain in the same was as figure 4,but here data are representing a 2.5D muscle surface (flatbut with non-null thickness). To grasp what is happeninginside the muscle thickness we use cut-planes. Their po-sition is guessed from the stimulation area, or maximal

Figure 4: Representation of a 2D simulation (cylindricalgeometry) using mayavi library. Electrical potential am-plitude is color-coded.

Figure 5: Representation of a 2.5D simulation usingmayavi library. Electrical potential amplitude is color-coded.

amplitude of the potential.All these visualization routines are included into

uEMG, and are based on common Python libraries suchas matplotlib and Mayavi.

Conclusion

In this paper we present an early version of the soft-ware written to perform the simulation of uterine EMGsignals. This multi-scale model of uterine electrical ac-tivity is unique.

The models we have developed have been imple-mented as a Python package. It includes the com-plete modeling chain and the helper scripts and functionsneeded.

We can simulate the electro-physiological signals atthe uterine level, for each muscle cell, or at the skin sur-face as they are recorded by monopolar electrodes.

The software itself has been given special attention. Itfollows an object oriented approach and takes advantageof Python possibilities in terms of automatic documenta-tion, parallelization and multi-platform execution.

Some work is still needed to validate each stage beforereleasing a public version. Some further improvementscould include a graphical interface to simplify the execu-tion of simulation.

References

[1] D. Devedeux, C. Marque, S. Mansour, G. Germain,and J. Duchêne. Uterine electromyography: a criti-cal review. Am. J. Obstet. Gynecol., 169:1636–1653,1993.

[2] Sandy Rihana, Jeremy Terrien, Guy Germain, andCatherine Marque. Mathematical modeling of elec-trical activity of uterine muscle cells. Medical and

Biological Engineering and Computing, 47:665–675,2009. 10.1007/s11517-009-0433-4.

[3] Jeremy Laforet, Chiara Rabotti, Jeremy Terrien,Massimo Mischi, and Catherine Marque. Towarda multiscale model of the uterine electrical activ-ity. IEEE Transactions on Bio-Medical Engineer-

ing, 58(12):3487–3490, December 2011. PMID:21968708.

[4] C. Rabotti, M. Mischi, L. Beulen, S.G. Oei, andJ.W.M. Bergmans. Modeling and identification ofthe electrohysterographic volume conductor by high-density electrodes. IEEE Trans. Biomed. Eng.,57:519–527, 2010.

A Software organization

This appendix presents the class diagram of the soft-ware in the figure 6.

Figure 6: Class diagram of the uEMG Python package.