Location: Computational analysis of the human sinus node action potential @ f3b351895abd / Figure05.py

Author:
nima <nafs080@aucklanduni.ac.nz>
Date:
2021-03-22 12:00:42+13:00
Desc:
URL for the sedml file replaced with the name of the sedml file in the folder
Permanent Source URI:
https://staging.physiomeproject.org/workspace/648/rawfile/f3b351895abdb51e580b634b4233d3d33cf67149/Figure05.py

# To reproduce the data needed for Figure 4 in associated Physiome 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 Figure04.py
#

import opencor as opencor
# import numpy as np

#different values for y_shift
y_shift = [-15,-10,-5,0,5,10,15]
t = ["time"]
V_m = {}
# Time = {}
# load the reference model
simulation = opencor.open_simulation("New_HumanSAN_Fabbri_Fantini_Wilders_Severi_2017.sedml")
data = simulation.data()
data.set_ending_point(1.9)
data.set_point_interval(0.001)

# simulation.reset(True)
#
#
# simulation.run()

for y in y_shift:
    # reset everything in case we are running interactively and have existing results
    simulation.reset(True)
    simulation.clear_results()

    data.constants()["i_f/i_f_y_gate/y_shift"] = y
    simulation.run()
    ds = simulation.results().data_store()
    # Time = ds.voi_and_variables()["environment/time"].values()
    V_m[y] = ds.voi_and_variables()["Membrane/V"].values()

    # print((V_m))
    # for key, value in glucose_i.items():
    #     print(key, value)

simulation.reset(True)
simulation.clear_results()

Time = {}
for i in range(0,1):
    simulation.run()
    ds = simulation.results().data_store()
    Time[t[0]] = ds.voi_and_variables()["environment/time"].values()
    # print(Time)

# print(type(Time))
# print(type(V_m))

V_m.update(Time)
# print(V_m)


# cache results for plotting
outfile = open("Fig05.csv", 'w')
cols = []
for key, item in V_m.items():
     outfile.write(str(key) + ",")
     cols.append(item)
outfile.write("\n")


for i in range(0, len(cols[0])):
    for j in range(0, len(cols)):
        outfile.write(str(cols[j][i]) + ",")
    outfile.write("\n")
outfile.close()