code: def animate_connectome(
      nodes,
      connectomes,
      cthresh="75%",
      figdir="frames",
      force_refresh=False,
  ):  # move to helpers
      """
      inputs:
        nodes: a K by 3 array of node center locations
  
        connectomes: a T by [((K^2 - K)/2) + K] array of per-timepoint connectomes.
                     Each timepoint's connectime is represented in a vectorized
                     format *including the diagonal* (i.e., self connections).
  
        figdir: where to save temporary files and final output
  
        force_refresh: if True, overwrite existing temporary files.  If False,
                       re-use existing temporary files and generate only the
                       temporary files that do not yet exist.
  
      outputs:
        ani: a matplotlib FuncAnimation object
      """
  
      if not os.path.exists(figdir):
          os.makedirs(figdir)
  
      # save a jpg file for each frame (this takes a while, so don't re-do already made images)
      def get_frame(t, fname):
          if force_refresh or not os.path.exists(fname):
              nl.plotting.plot_connectome(
                  tc.vec2mat(connectomes[t, :]),
                  nodes,
                  node_color="k",
                  edge_threshold=cthresh,
                  output_file=fname,
              )
  
      timepoints = np.arange(connectomes.shape[0])
      fnames = [
          os.path.join(figdir, str(t) + ".jpg") for t in timepoints
      ]
      tmp = [get_frame(t, f) for t, f in zip(timepoints, fnames)]
  
      # create a movie frame from each of the images we just made
      fig = plt.figure()
  
      def get_im(fname):
          # print(fname)
          plt.axis("off")
          return plt.imshow(plt.imread(fname), animated=True)
  
      ani = mlab.animation.FuncAnimation(
          fig, get_im, fnames, interval=50
      )
      return ani
  
imports: import numpy
  import pandas
  import nibabel
  import nilearn
  from nilearn.input_data import NiftiMasker
  import nilearn.plotting
  import matplotlib
  import matplotlib.pyplot
  import holoviews
  import timecorr
  import os
  from brainiak.factoranalysis.htfa import HTFA
  import warnings
  import seaborn
label_desc: Use image node_id 10 for calling a global function with example usage: animate_connectome(nodes, connectomes, cthresh, figdir, force_refresh) and returns: ani, plt