for index_data in data:
        grid[(grid > 0) & (grid <= 50)] -= 1
        if index_data == []:  # could use <if not individual_data.any():> but this is more readable.
            current_state = grid.copy()
            output.append(current_state)
        else:
            indices = np.unravel_index(index_data, a.shape)
            for ind in range(len(indices[0])):
                grid[indices[0][ind]][indices[1][ind]] = 50
            current_state = grid.copy()
            output.append(current_state)

    return output


e = at.ECG(shape=(200, 200), probe_height=3,
           m=args.mode)  # Assuming shape/probe height doesn't change.
file_name = args.output  #nput("Name of output file: ")
#print("Nu Value:")
nu = args.nu  #float(input())

print(file_name, nu, e.mode, Iterations)
# print(nu)

h5f = h5py.File('%s.h5' % file_name, 'w')
for index in range(Iterations):
    #nu = (np.random.rand() / 5) + 0.1
    start_time1 = time.time()
    index_grp = h5f.create_group('Index: %s' % index)

    a = fp.Heart(nu=nu, fakedata=True)
    crit_position = np.random.randint(40000)
pp = 0
print_counter(pp, number_of_rotors)
for i in range(number_of_rotors):

    # Initialising the Heart structure
    a = ps.Heart(nu=0.2, delta=0.0, fakedata=True)
    # Randomises the rotor x,y position
    cp_x_pos = randint(30, 169)
    cp_y_pos = randint(0, 199)
    a.set_circuit(np.ravel_multi_index([cp_y_pos, cp_x_pos], (200, 200)))
    rotor[i] = (cp_x_pos, cp_y_pos)

    # Initialising ECG recording (randomises the probe x,y position)
    current_ecg_x_pos = randint(20, 179)
    current_ecg_y_pos = randint(0, 199)
    ecg_processing = at.ECG(centre=(current_ecg_y_pos, current_ecg_x_pos),
                            m='g_single')
    ecg_start[i] = (current_ecg_x_pos, current_ecg_y_pos)

    # Animation grids
    animation_grid = np.zeros(a.shape)

    # reset time step counter
    ptr1 = 0

    prev_y_vector = None
    prev_x_vector = None

    # Loop checking
    y_short_memory = []
    x_short_memory = []
Beispiel #3
0
import propagate_singlesource as ps
import analysis_theano as at
import numpy as np
import matplotlib.pyplot as plt
from Functions import sampling_convert
# import pyqtgraph as pg
# import pyqtgraph.ptime as ptime
# from pyqtgraph.Qt import QtCore, QtGui
a = ps.Heart(fakedata=True)
a.set_pulse(220, [[100], [100]])
e = at.ECG(shape=(200, 200), probe_height=3)
raw_data = a.propagate(400)

converted_data = list()
grid = np.zeros(a.shape)
sampling_convert(raw_data,
                 converted_data,
                 shape=a.shape,
                 rp=a.rp,
                 animation_grid=grid)

ecg = e.solve(converted_data[100:])

probe_positions = e.probe_position

print probe_positions
print "Plotting..."
fig = plt.figure()
for index, i in enumerate(ecg):
    plt.plot(range(len(i)),
             i,