Skip to content

Commit

Permalink
First pass at export function, fix vmin and vmax
Browse files Browse the repository at this point in the history
  • Loading branch information
ntolley committed May 23, 2023
1 parent b4b577f commit 6a8e90f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion hnn_core/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ def get_voltages(self):

vsec_array = np.vstack(vsec_list)
vsec_array = (vsec_array - self.vmin) / (self.vmax - self.vmin)
return np.vstack(vsec_list)
return vsec_array

def update_section_voltages(self, t_idx):
color_list = self.color_array[:, t_idx]
Expand Down Expand Up @@ -1322,6 +1322,15 @@ def _update_axes(self):

self.ax.view_init(self._elev, self._azim)

def export_movie(self, fname, dpi=300):
import matplotlib.animation as animation
ani = animation.FuncAnimation(
self.fig, self.set_time_idx, len(self.times) - 1, interval=30)

writer = animation.writers['ffmpeg'](fps=30)
ani.save(fname, writer=writer, dpi=dpi)
return ani

# Axis limits
@property
def xlim(self):
Expand Down Expand Up @@ -1410,6 +1419,10 @@ def time_idx(self, time_idx):
self._time_idx = time_idx
self.update_section_voltages(self._time_idx)

# Necessary for making animations
def set_time_idx(self, time_idx):
self.time_idx = time_idx

# Background color and voltage colormaps
@property
def bg_color(self):
Expand Down

0 comments on commit 6a8e90f

Please sign in to comment.