# Author : Leyla Noroozbabaee # Date: 12/09/2021 # To reproduce the data needed for Figure 3 in associated original paper, # execute this script in the Python console in OpenCOR. This can be done # with the following commands at the prompt in the OpenCOR Python console: # # In [1]: cd path/to/folder_this_file_is_in # In [2]: run Fig6_sim.py import opencor as oc import numpy as np # The prefix of the saved output file name prefilename = 'Fig6' # Load the simulation file simfile = 'Fig6_IP3_Imtiaz_2002.sedml' simulation = oc.open_simulation(simfile) # The data object houses all the relevant information # and pointers to the OpenCOR internal data representations data = simulation.data() # Set the experiments, the stimulus range I_clamp1 = np.linspace(-35, 35, num=30) # Define the interval of interest for this simulation experiment duration = 3 start, end, pointInterval = 0, duration, 0.001 data.set_starting_point(start) data.set_ending_point(end) data.set_point_interval(pointInterval) # Data to save varName = np.array(["Time", "vm", "I_stim"]) vars = np.reshape(varName, (1, len(varName))) rows = duration * 1000 + 1 r = np.zeros((rows, len(varName))) for index, i in enumerate(I_clamp1): # Reset states and parameters simulation.reset(True) # Set constant parameter values data.constants()['vm/cm'] = 0.5 data.constants()['vm/I_clamp1'] = i simulation.run() # Access simulation results results = simulation.results() # Grab a specific algebraic variable results r [:, 0] = results.voi().values() r [ :, 1 ] = results.states()['vm/vm'].values() r [ :, 2 ] = results.algebraic()['vm/I_stim'].values() simulation.clear_results() # Save the simulation result of the last run filename = '%s_%s.csv' % (prefilename, index) np.savetxt(filename, vars, fmt='%s', delimiter=",") with open(filename, "ab") as f: np.savetxt(f, r, delimiter=",") f.close