code: def mat2chord(connectome, cthresh=0.05):
      """
      inputs:
        connectome: K by K connectivity matrix
  
        cthresh: only show connections in the top (cthresh*100)%; default = 0.25
  
      outputs:
        chord: a holoviews.Chord object displaying the connectome as a chord
               diagram
      """
  
      def mat2links(x, ids):
          links = []
          for i in range(x.shape[0]):
              for j in range(i):
                  links.append(
                      {
                          "source": ids[i],
                          "target": ids[j],
                          "value": np.abs(x[i, j]),
                          "sign": np.sign(x[i, j]),
                      }
                  )
          return pd.DataFrame(links)
  
      K = connectome.shape[0]
      nodes = pd.DataFrame(
          {"ID": range(K), "Name": [f"Node {i}" for i in range(K)]}
      )
  
      links = mat2links(connectome, nodes["ID"])
      chord = hv.Chord((links, hv.Dataset(nodes, "ID"))).select(
          value=(cthresh, None)
      )
      chord.opts(
          hv.opts.Chord(
              cmap="Category20",
              edge_cmap="Category20",
              edge_color=hv.dim("source").str(),
              labels="Name",
              node_color=hv.dim("ID").str(),
          )
      )
      return chord
  
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 11 for calling a global function with example usage: mat2chord(connectome, cthresh) and returns: chord, pd