LifeV
StimulusPacingProtocol.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3  *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23  *******************************************************************************
24  */
25 //@HEADER
26 /*!
27  @file
28  @brief Class for applying cardiac stimulus at a single point according to a pacing protocol
29 
30  @date 02-2014
31  @author Simone Palamara <palamara.simone@gmail.com>
32 
33  @last update 02-2014
34  */
35 
36 #include <lifev/electrophysiology/stimulus/StimulusPacingProtocol.hpp>
37 
38 namespace LifeV
39 {
40 
41 // ===================================================
42 //! Constructors
43 // ===================================================
45  M_radius ( 0 ),
46  M_stimulusAmplitude ( 0 ),
47  M_pacingSite_X ( 0 ),
48  M_pacingSite_Y ( 0 ),
49  M_pacingSite_Z ( 0 ),
50  M_numberStimulus ( 0 ),
51  M_nbStimMax (-1)
52 {
53 }
54 
55 // ===================================================
56 //! Methods
57 // ===================================================
58 
59 
61 {
62 
63  if ( M_pacingProtocol == "FCL" )
64  {
65  return fixedCycleLength ( t );
66  }
67 
68  else if ( M_pacingProtocol == "FCL-ExtraSt" )
69  {
71  }
72 
73  else if ( M_pacingProtocol == "S1S2" )
74  {
75  return standardS1S2Protocol ( t );
76  }
77 
78  else if ( M_pacingProtocol == "DynPro" )
79  {
80  return dynamicProtocol ( t );
81  }
82 
83  else
84  {
85  return fixedCycleLength ( t );
86  }
87 
88 
89 }
90 
91 
93 {
94  Real current = 0;
95  if ( M_numberStimulus < M_nbStimMax || M_nbStimMax == -1 )
96  {
98  {
99  current = M_stimulusAmplitude;
101  {
102  std::cout << "\nUpdating the stimulus interval";
105  }
106  }
107  else
108  {
109  current = 0;
110  }
111  }
112  else
113  {
114  current = 0;
115  }
116  return current;
117 }
118 
120 {
121  Real current = 0;
122  if ( M_numberStimulus < M_nbStimMax || M_nbStimMax == -1 )
123  {
125  {
126  current = M_stimulusAmplitude;
127 
129  {
131  {
134  }
135  else
136  {
137  if ( M_pacingProtocolType == "S1-S2" )
138  {
140  M_numberStimulus = 0;
141  }
142  else if ( M_pacingProtocolType == "S1-S2-S3" )
143  {
144  if ( M_numberStimulus == M_repeatSt )
145  {
148  }
149  else
150  {
152  M_numberStimulus = 0;
153  }
154  }
155  else if ( M_pacingProtocolType == "S1-S2-S3-S4" )
156  {
157  if ( M_numberStimulus == M_repeatSt )
158  {
161  }
162  else if ( M_numberStimulus == M_repeatSt + 1 )
163  {
166  }
167  else
168  {
170  M_numberStimulus = 0;
171  }
172  }
173  else
174  {
176  }
177  }
178  }
179  }
180  }
181 
182  return current;
183 }
184 
186 {
187  Real current = 0;
188  if ( t < M_nbStimMax * M_stimulusInterval )
189  {
191  {
192  current = M_stimulusAmplitude;
193 
195  {
197 
198  if ( t > ( M_nbStimMax - 1 ) * M_stimulusInterval && t < M_nbStimMax * M_stimulusInterval )
199  {
200  M_numberStimulus = 0;
201  }
202  else
203  {
205  }
206  }
207  }
208  }
209  else
210  {
211  if ( M_stIntS1S2 >= M_stIntS1S2Min )
212  {
214  {
215  current = M_stimulusAmplitude;
216 
218  {
220 
222  {
224  }
225 
226  else if ( M_numberStimulus == M_repeatSt )
227  {
229  }
230 
231  else if ( M_numberStimulus == M_repeatSt + 1 )
232  {
234  M_numberStimulus = 0;
235 
236  if ( M_stIntS1S2 > 100 )
237  {
238  M_stIntS1S2 = M_stIntS1S2 - 100;
239  }
240 
241  else if ( M_stIntS1S2 <= 100 && M_stIntS1S2 > 30 )
242  {
243  M_stIntS1S2 = M_stIntS1S2 - 5;
244  }
245 
246  else if ( M_stIntS1S2 <= 30 && M_stIntS1S2 > 20 )
247  {
248  M_stIntS1S2 = M_stIntS1S2 - 1;
249  }
250 
251  else if ( M_stIntS1S2 <= 20 )
252  {
253  M_stIntS1S2 = M_stIntS1S2 - 5;
254  }
255  }
256  }
257  }
258  }
259  }
260  return current;
261 }
262 
264 {
265  Real current = 0;
267  {
269  {
270  current = M_stimulusAmplitude;
271 
273  {
276  }
277  }
278  else
279  {
280  current = 0;
281  }
282 
283  if ( t > M_tShortS1S1 )
284  {
285  if ( M_stimulusInterval > 1000 )
286  {
289  }
290  else if ( M_stimulusInterval <= 1000 && M_stimulusInterval > 300 )
291  {
294  }
295  else if ( M_stimulusInterval <= 300 && M_stimulusInterval > 200 )
296  {
299  }
300  else if ( M_stimulusInterval <= 200 )
301  {
304  }
305  }
306  }
307  else
308  {
309  current = 0;
310  }
311  return current;
312 }
313 
314 Real StimulusPacingProtocol::appliedCurrent ( const Real& t, const Real& x, const Real& y, const Real& z, const ID& /*i*/ )
315 {
316 
317  Real current = 0.0;
318  const Real volumeOfBall = (4. / 3.) * M_PI * M_radius * M_radius * M_radius;
319  Real distance = std::sqrt ( (x - M_pacingSite_X) * (x - M_pacingSite_X) + (y - M_pacingSite_Y) * (y - M_pacingSite_Y) + (z - M_pacingSite_Z) * (z - M_pacingSite_Z) );
320  if (distance <= M_radius )
321  {
322  current += pacingProtocolChoice ( t ) / volumeOfBall;
323  }
324  return current;
325 
326 }
327 
329 {
330  std::cout << "\n\n\t\tPacing protocol Informations\n\n";
331 
332  std::cout << "\n\t\tList of parameters:\n\n";
333 
334  std::cout << "Istim: " << M_stimulusAmplitude << std::endl;
335  std::cout << "StimDuration: " << M_stimulusDuration << std::endl;
336  std::cout << "1st stimuli time: " << M_startingTimeStimulus << std::endl;
337  std::cout << "Pacing protocol: " << M_pacingProtocol << std::endl;
338  std::cout << "Pacing site: " << M_pacingSite_X << " " << M_pacingSite_Y << " " << M_pacingSite_Z << std::endl;
339  std::cout << "Radius stimulus: " << M_radius << std::endl;
340  if ( M_pacingProtocol == "FCL" )
341  {
342  std::cout << "S1-S1 interval: " << M_stimulusInterval << std::endl;
343  std::cout << "NbStimuliMax: " << M_nbStimMax << std::endl;
344  }
345  else if ( M_pacingProtocol == "FCL-ExtraSt" )
346  {
347  std::cout << "Pacing protocol type: " << M_pacingProtocolType << std::endl;
348  std::cout << "S1-S1 interval: " << M_stimulusInterval << std::endl;
349  std::cout << "NbStimuliMax: " << M_nbStimMax << std::endl;
350  std::cout << "Repeat S1 stimuli: " << M_repeatSt << std::endl;
351 
352  if ( M_pacingProtocolType == "S1-S2" )
353  {
354  std::cout << "S1-S2 interval: " << M_stIntS1S2 << std::endl;
355  }
356  else if ( M_pacingProtocolType == "S1-S2-S3" )
357  {
358  std::cout << "S1-S2 interval: " << M_stIntS1S2 << std::endl;
359  std::cout << "S2-S3 interval: " << M_stIntS2S3 << std::endl;
360  }
361  else if ( M_pacingProtocolType == "S1-S2-S3-S4" )
362  {
363  std::cout << "S1-S2 interval: " << M_stIntS1S2 << std::endl;
364  std::cout << "S2-S3 interval: " << M_stIntS2S3 << std::endl;
365  std::cout << "S3-S4 interval: " << M_stIntS3S4 << std::endl;
366  }
367 
368  }
369  else if ( M_pacingProtocol == "S1S2Pro" )
370  {
371  std::cout << "S1-S1 interval: " << M_stimulusInterval << std::endl;
372  std::cout << "NbStimuliMax for stabilisation: " << M_nbStimMax << std::endl;
373  std::cout << "First S1-S2 interval: " << M_stIntS1S2 << std::endl;
374  std::cout << "Minimum S1-S2 interval: " << M_stIntS1S2Min << std::endl;
375  std::cout << "Repeat S1 stimuli: " << M_repeatSt << std::endl;
376  }
377  else if ( M_pacingProtocol == "DynPro" )
378  {
379  std::cout << "First S1-S1 interval: " << M_stimulusInterval << std::endl;
380  std::cout << "Minimum S1-S1 interval: " << M_minimumStimulusInterval << std::endl;
381  std::cout << "First time S1-S1 interval decrease: " << M_tShortS1S1 << std::endl;
382  }
383  else
384  {
385  std::cout << "S1-S1 interval: " << M_stimulusInterval << std::endl;
386  std::cout << "NbStimuliMax: " << M_nbStimMax << std::endl;
387  }
388  std::cout << "\n\t\t End of Pacing protocol Informations\n\n\n";
389 }
390 
391 }
Real fixedCycleLengthwExtraStim(const Real &t)
#define M_PI
Definition: winmath.h:20
void updateInverseJacobian(const UInt &iQuadPt)
Real pacingProtocolChoice(const Real &t)
Methods.
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Real appliedCurrent(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
double Real
Generic real data.
Definition: LifeV.hpp:175
StimulusPacingProtocol()
Empty Constructor.