Change Cell Parameters after loading saved simulations

+1 vote
35 views
asked Nov 8, 2017 by J-H Plank (440 points)
edited Dec 1, 2017 by J-H Plank

Dear all,

I would like to change the the conductance for one current, e.g. the membrane_L_type_calcium_current_conductance, after loading a previously saved simulation.
The Chaste Guide concerning CodeGenerationFromCellML says the following:
"The variable can then be altered at run-time, via calls to the SetParameter method."
I also found that this method is a member of AbstractCardiacCell and some other classes. However, it is unfortunately unclear to me how this method can be used in this situation.

Edit: Sorry, my question is not very precise.

I want to run a mono-/bidomain simulation. That's why I declared a function similar to the PointStimulus2dCellFactory from the TestRunningBidomainSimulationsTutorial.hpp, which inherits from the AbstractCardiacCellFactory. This class contains the function CreateCardiacCellForTissueNode of type AbstractCardiacCell* defining the cell model for each node. At this level it is clear to me, how I can use the SetParameter method.

However, I would like to change these parameters at run-time, meaning I want to change them in the Test class, e.g. TestRunningBidomainSimulationsTutorial. It is unclear to me, how I can call the SetParameter function at this level. Furthermore I would like to know how to call the SetParameter function after loading a previously saved simulation.

Thanks in advance for any answers!
Jan-Hendrik

2 Answers

0 votes
answered Nov 15, 2017 by GaryM (940 points)

You can change the parameters within a cardiac cell model at any time (before or after saving/loading - that shouldn't matter) with the method SetParameter() that will be available for any cardiac cell. See the single cell tutorial for an example of how to call it.

But note that variables will need to be tagged with metadata in the CellML file to become automatically accessible via the GetParameter() and SetParameter() methods like this.

The CellML elements you want to access from within C++ will also need to be set as 'modifiable parameters', either by:

  1. Explicitly tagging certain CellML elements to get turned into parameters by following https://chaste.cs.ox.ac.uk/trac/wiki/ChasteGuides/CodeGenerationFromCellML#Modifiableparameters

or

  1. Setting all tagged variables to be turned into parameters by changing PyCML's global settings following these instructions: https://chaste.cs.ox.ac.uk/trac/wiki/ChasteGuides/CodeGenerationFromCellML#Project-specificconversionoptions
commented Dec 1, 2017 by J-H Plank (440 points)

Hi Gary,

thanks a lot for your answer. Unfortunately I realized that I did not ask my question very precisely, that's why I edited it.

Nevertheless your answer was quite useful by making me realize that the single cell part from Chaste could be quite useful for my work.

commented Dec 1, 2017 by GaryM (940 points)

I think I see what you want to do. CellFactory classes are only called when the problem is initialised, not after save and load.

You just have to get each cell from the CardiacProblem, which you can do at any time. There is an example here: https://chaste.cs.ox.ac.uk/trac/browser/git_repo/heart/test/TestCardiacSimulation.hpp#L127
(for parallel mesh)

and here
https://chaste.cs.ox.ac.uk/trac/browser/git_repo/heart/test/monodomain/TestMonodomainProblem.hpp#L1385
(for non-parallel mesh)

And then use Get/Set methods as above

commented Dec 4, 2017 by J-H Plank (440 points)

Hi Gary, thanks a lot. This should indeed solve my problem!

0 votes
answered Dec 1, 2017 by J-H Plank (440 points)

While editing my question and talking to some colleagues I came closer to the solution:

for (unsigned int i=0; i< mesh.GetNumNodes(); i++)   
    cell_factory.CreateCardiacCellForTissueNode(mesh.GetNodeOrHaloNode(i))->SetParameter("membrane_L_type_calcium_current_conductance",0);

This allows me to modify the parameters in the Test class.

However I still have no idea how to change this after loading a previously saved simulation. After loading the simulation I have a pointer of type MonodomainProblem, but this doesn't seem to have an AbstractCardiacCellFactory as a member. So I am wondering if it is even possible to change the cell model after loading the stimulation?

Welcome to Chaste Q&A, where you can ask questions and receive answers from other members of the community of Chaste developers and users.

See the Chaste wiki for installation instructions, guides and tutorials.

...