First time here? Checkout the FAQ!
x
0 votes
by (340 points)

I am trying to modify the simple carputils example to generate a healthy heart simulation with custom mesh structures. When it comes to stimulating an external mesh, I have found many posts in the forum that are referring to this issue, although some are discontinued. The most relevant one I found is this. I strongly presume the reference in the final comment is this in which the solution found by DUNBUJODA is unclear. Then solution proposed is linked to this in which, perhaps, question is diverging from the original question. Also, I have to link this question as well for the completeness of the issue.

After going through all above I am very confused about how to stimulate an external mesh. Any clarification with an example would be appreciated. I will report my trial and errors in the comments as I progress about this issue.

Thanks.

by (570 points)
Could provide more detailed description of your problem?

Do you have your own mesh or are you trying to generate one?

Sharing your code and/or error output on where you are stuck would be useful.
by (340 points)
Yes, here is a detailed description of the issue.

I am doing following modifications to the simple example (https://opencarp.org/documentation/examples/02_ep_tissue/00_simple) run.py code:

1. Rather than generating the mesh in the code, I am loading an external mesh by adding the following line:

meshname = 'ellipsoid'

Note: The mesh ellipsoid is the structure given in the example folder by meshalyzer. I am including all *.pts, *.Ion, *.elem files.

2. Since the stimulation code 'stim = mesh.block_bc_opencarp(geom, 'stim', 0, 'x', T' only works with block meshes (referring to: https://opencarp.org/q2a/902/how-to-get-geometry-from-existing-mesh?show=913#c913) I am trying to change it using stim class. Changing it as:

stim = ['-num_stim', 1,
            '-stimulus[0].stimtype', 0,
            '-stimulus[0].strength', 120.0,
            '-stimulus[0].duration', 2.0,
            '-stimulus[0].start', 0,
            '-stimulus[0].x0', 2100,
            '-stimulus[0].xd', 32000,
            '-stimulus[0].y0', 2100,
            '-stimulus[0].yd', 310,
            '-stimulus[0].z0', 2100,
            '-stimulus[0].zd', 4200,
            '-stimulus[0].npls', 1,
            '-stimulus[0].ctr_def',1,
            '-stim[0].elec.dump_vtx_file',0,
            '-stim[0].elec.geom_type',5,
            '-stim[0].elec.geomID', 0,
            '-stim[0].elec.p0[0]', 1,
            '-stim[0].elec.p0[1]', 1,
            '-stim[0].elec.p0[2]', 1,
            '-floating_ground', 1]

With above modifications I am running the simulation successfully however when I want to display the results, I am getting point mismatch error in meshalyzer. Also, what I want is to stimulate the heart from a vertex. Therefore, I switch to using the *.vtx file as in the link:

https://opencarp.org/q2a/830/how-define-stimulus-through-vtx-file-22_simple-experiment?show=830#q830

So, I modify the stimulation code as:

    stim = ["-num_stim", 1,
            "-stimulus[0].vtx_file", "path/to/vtx/file"]

And getting the same error:

L5 : error: Empty stimulus[0] electrode def! Aborting!

Using the suggestions in the following link, I am modifying the simple.par folder for the stimulation definition by changing  stim[0].crct.type = 2 (referring to: https://opencarp.org/q2a/804/prescribed-epicardial-potential?show=808#a808) and by adding the following lines:

stim[0].elec.vtx_file = stimulationvtxfile.vtx
stim[0].elec.vtx_fcn = 1

And finally I am getting this error:

L5 : get_mesh error: mesh of type "Extracellular Electric" not found! Aborting!

1 Answer

0 votes
by (3.6k points)
Hi,

Could you please post here the content of your vtx file?

Cheers,

Jorge
by (340 points)
Hi,

Of course, here it is:

 4
 extra
 730
 667
 148
 2982

Best,

Kocak
by (3.6k points)
Hi,

I would suggest reading the online parameter documentation (https://opencarp.org/documentation/opencarp-parameters#master) and check how do you want to set up your stimuli with the help of the stimulation example (https://opencarp.org/documentation/examples/02_ep_tissue/02_stimulation).

Here is a short example of a set of parameters for one stimulus:

num_stim                 = 1
stim[0].crct.type        = 0
stim[0].pulse.strength   = 60.0
stim[0].ptcl.duration    = 2.0
stim[0].ptcl.start       = 0.0
stim[0].ptcl.npls        = 1
stim[0].elec.vtx_file    = "path/to/vtxfile.vtx"

Cheers,

Jorge
by (340 points)
Thank you for the reply.

I have gone through the documentation and example you recommended. Unfortunately, the example is using 'mesh.block_boundary_condition' function. However, I am trying to stimulate using *.vtx file. I have checked the other examples from openCARP and figured that 'Adjusting wavelength to experimental data' example is using the *.vtx file in the link (https://git.opencarp.org/openCARP/experiments/-/blob/master/tutorials/02_EP_tissue/03C_tuning_wavelength/Mesh_1.5cm_Sheet/stim.vtx). Learning from this example, I am trying to stimulate the block in simple carputils example (https://opencarp.org/documentation/examples/02_ep_tissue/00_simple) from a vertex. For this only modifications I have done are:

1. Define stim as:

    stim = ['-num_stim', 1,
            '-stimulus[0].vtx_file', os.path.join(EXAMPLE_DIR, 'stimulationvtxfile')]

2. Change stim[0].crct.type =  0 to stim[0].crct.type =  2 in *.par file.

3. Add following lines to *.par file:

stim[0].elec.vtx_file = stimulationvtxfile
stim[0].elec.vtx_fcn = 1

4. Put a *.vtx file with following text:

3
extra
1
21
126

I am still getting the error:

L5 : get_mesh error: mesh of type "Extracellular Electric" not found! Aborting!

Checking the source code and carputils functions, I still cannot find the cause or potential workaround on this issue. It is a bottleneck for my simulation studies for a couple of weeks now so any help is highly appreciated at this point.

Best,

Kocak
by (3.6k points)
Hi,

I believe your issue is that you are trying to stimulate a domain that does not exist in your simulation. I would suggest checking what you are trying to simulate and, according to your experiment setup, using the stimulus that would fit your experiment best. If you check the online parameter, you will see that type 2 correspond to extracellular stimulation. Feel free to ask again if you are still having any issues.

Cheers,

Jorge
Welcome to openCARP Q&A. Ask questions and receive answers from other members of the community. For best support, please use appropriate TAGS!
architecture, carputils, documentation, experiments, installation-containers-packages, limpet, slimfem, website, governance
...