Skip to content

Commit

Permalink
Added 'courtemanche-ramirez-1998-RushLarsen'/Changed PMJ delay calcul…
Browse files Browse the repository at this point in the history
…us to use the minLAT of the coupled ventricular cells
  • Loading branch information
bergolho committed Oct 13, 2023
1 parent 9b6a49d commit be9c28f
Show file tree
Hide file tree
Showing 9 changed files with 1,279 additions and 8 deletions.
5 changes: 4 additions & 1 deletion ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ When the minimum number of PMJs is not reached the solver will be in an infinite
<t> <sv_1> <sv_2> <sv_3> ... <sv_n>
. . . . .
. . . . .
. . . . .
. . . . .


Fix the "save_multiple_cell_state_variables". It cannot find the proper cell center.
64 changes: 64 additions & 0 deletions example_configs/activation_time_and_apd_example.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[main]
num_threads=4
dt_pde=0.01
simulation_time=5000.0
abort_on_no_activity=false
use_adaptivity=false

[update_monodomain]
main_function=update_monodomain_default

[save_result]
print_rate=10
mesh_print_rate=100
mesh_format=ensight
output_dir=./outputs/cable_save_activation_time_and_apd_example
init_function=init_save_with_activation_times
end_function=end_save_with_activation_times
main_function=save_with_activation_times
time_threshold=0.0
activation_threshold=-50.0
apd_threshold=-70.0
save_visible_mask=false
remove_older_simulation=true

[assembly_matrix]
init_function=set_initial_conditions_fvm
sigma_x=0.0000176
sigma_y=0.0000176
sigma_z=0.0000176
library_file=shared_libs/libdefault_matrix_assembly.so
main_function=homogeneous_sigma_assembly_matrix

[linear_system_solver]
tolerance=1e-16
use_preconditioner=no
max_iterations=500
library_file=shared_libs/libdefault_linear_system_solver.so
use_gpu=no
main_function=conjugate_gradient
init_function=init_conjugate_gradient
end_function=end_conjugate_gradient

[domain]
name=Cable Mesh with no fibrosis
start_dx=100.0
start_dy=100.0
start_dz=100.0
cable_length=10000.0
main_function=initialize_grid_with_cable_mesh

[ode_solver]
adaptive=false
dt=0.01
use_gpu=false
gpu_id=0
library_file= shared_libs/libToRORd_dynCl_mixed_endo_mid_epi.so

[stim_plain]
start = 0.0
duration = 2.0
current = -53.0
x_limit = 500.0
period=1000.0
main_function=stim_if_x_less_than
69 changes: 69 additions & 0 deletions scripts/reader_acm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import sys

def read_acm_file (filename, target_center_x, target_center_y, target_center_z):
file = open(filename)
counter_lines = 0
for line in file:
if (counter_lines > 1):
line = line.strip()
new_line = line.replace(",", " ")

# Cell geometry section
first_open_bracket_id = new_line.find('[') # find() -> lowest index
first_close_bracket_id = new_line.find(']')
second_open_bracket_id = new_line.rfind('[') # rfind() -> hightest index
second_close_bracket_id = new_line.rfind(']')
cell_geometry_data = new_line[0:first_open_bracket_id]
tokens = cell_geometry_data.split()
center_x, center_y, center_z, dx, dy, dz = float(tokens[0]), float(tokens[1]), float(tokens[2]), float(tokens[3]), float(tokens[4]), float(tokens[5])
#print("%g %g %g %g %g %g" % (center_x, center_y, center_y, dx, dy, dz))

# Activation time section
activation_time_values = []
activation_time_data = new_line[first_open_bracket_id+1:first_close_bracket_id].split()
for value in activation_time_data:
activation_time_values.append(float(value))
#print(activation_time_values)

# APD section
apd_values = []
apd_data = new_line[second_open_bracket_id+1:second_close_bracket_id].split()
for value in apd_data:
apd_values.append(float(value))
#print(apd_values)

# SUCESS: Found the target cell!
if (center_x == target_center_x and center_y == target_center_y and center_z == target_center_z):
return activation_time_values, apd_values

counter_lines = counter_lines + 1
file.close()
return activation_time_values, apd_values

def main():

if len(sys.argv) != 5:
print("-------------------------------------------------------------------------")
print("Usage:> python %s <input_file> <center_x> <center_y> <center_z>" % sys.argv[0])
print("-------------------------------------------------------------------------")
print("<input_file> = Input \".acm\" file with the activation time and APD data")
print("<center_x> = Cell center x position")
print("<center_y> = Cell center y position")
print("<center_z> = Cell center z position")
print("-------------------------------------------------------------------------")
return 1

input_file = sys.argv[1]
target_center_x = float(sys.argv[2])
target_center_y = float(sys.argv[3])
target_center_z = float(sys.argv[4])

activation_time_values, apd_values = read_acm_file(input_file, target_center_x, target_center_y, target_center_z)
print("Activation times:")
print(activation_time_values)
print()
print("APDs:")
print(apd_values)

if __name__ == "__main__":
main()
Loading

0 comments on commit be9c28f

Please sign in to comment.