code: def get_surrogate_connectivity(self, measure_name, repeats=100, plot=False, random_state=None):
          
          cs = surrogate_connectivity(measure_name, self.activations_[self.trial_mask_, :, :],
                                      self.var_, self.nfft_, repeats, random_state=random_state)
  
          if plot is None or plot:
              fig = plot
              if self.plot_diagonal == 'fill':
                  diagonal = 0
              elif self.plot_diagonal == 'S':
                  diagonal = -1
                  sb = self.get_surrogate_connectivity('absS', repeats)
                  sb /= np.max(sb)     # scale to 1 since components are scaled arbitrarily anyway
                  su = np.percentile(sb, 95, axis=0)
                  fig = self.plotting.plot_connectivity_spectrum([su], fs=self.fs_, freq_range=self.plot_f_range,
                                                            diagonal=1, border=self.plot_outside_topo, fig=fig)
              else:
                  diagonal = -1
              cu = np.percentile(cs, 95, axis=0)
              fig = self.plotting.plot_connectivity_spectrum([cu], fs=self.fs_, freq_range=self.plot_f_range,
                                                        diagonal=diagonal, border=self.plot_outside_topo, fig=fig)
              return cs, fig
  
          return cs
docs: Calculate spectral connectivity measure under the assumption of no actual connectivity.
  
          Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity
          distribution if there was no causal structure in the data.
  
          Parameters
          ----------
          measure_name : str
              Name of the connectivity measure to calculate. See :class:`Connectivity` for supported measures.
          repeats : int, optional
              How many surrogate samples to take.
  
          Returns
          -------
          measure : array, shape = [`repeats`, n_channels, n_channels, nfft]
              Values of the connectivity measure for each surrogate.
  
          See Also
          --------
          :func:`scot.connectivity_statistics.surrogate_connectivity` : Calculates surrogate connectivity