'''
Spatio-temporal animation
'''

from matplotlib.animation import FuncAnimation
import numpy as np
import matplotlib.pyplot as plt

number_of_excitatory_neurons_per_row = 30
number_of_frames = 50
frame_rate=25
activities = np.zeros((number_of_excitatory_neurons_per_row, number_of_excitatory_neurons_per_row, number_of_frames))
activities[:,:, 30:-1] = 1


fig, ax = plt.subplots(1,1)
image = ax.imshow(activities[:,:,0], vmin=0, vmax=1)

def animate(frame):
    image.set_array(activities[:,:,1])
    return image

animation = FuncAnimation(fig, animate, number_of_frames, interval=1000/frame_rate)
animation.save("out_2dgrid.mp4", dpi=number_of_excitatory_neurons_per_row, writer='imagemagick')

