code: def _logprob_obs(self, data, mean_pat, var):
          
  
          n_vox = data.shape[0]
          t = data.shape[1]
  
          # z-score both data and mean patterns in space, so that Gaussians
          # are measuring Pearson correlations and are insensitive to overall
          # activity changes
          data_z = stats.zscore(data, axis=0, ddof=1)
          mean_pat_z = stats.zscore(mean_pat, axis=0, ddof=1)
  
          logprob = np.empty((t, self.n_events))
  
          if type(var) is not np.ndarray:
              var = var * np.ones(self.n_events)
  
          for k in range(self.n_events):
              logprob[:, k] = -0.5 * n_vox * np.log(
                  2 * np.pi * var[k]) - 0.5 * np.sum(
                  (data_z.T - mean_pat_z[:, k]).T ** 2, axis=0) / var[k]
  
          logprob /= n_vox
          return logprob
docs: Log probability of observing each timepoint under each event model
  
          Computes the log probability of each observed timepoint being
          generated by the Gaussian distribution for each event pattern
  
          Parameters
          ----------
          data: voxel by time ndarray
              fMRI data on which to compute log probabilities
  
          mean_pat: voxel by event ndarray
              Centers of the Gaussians for each event
  
          var: float or 1D array of length equal to the number of events
              Variance of the event Gaussians. If scalar, all events are
              assumed to have the same variance
  
          Returns
          -------
          logprob : time by event ndarray
              Log probability of each timepoint under each event Gaussian