code: def get_weights(self, data, F):
          
  
          beta = np.var(data)
          trans_F = F.T.copy()
          W = np.zeros((self.K, data.shape[1]))
          if self.weight_method == 'rr':
              W = np.linalg.solve(trans_F.dot(F) + beta * np.identity(self.K),
                                  trans_F.dot(data))
          else:
              W = np.linalg.solve(trans_F.dot(F), trans_F.dot(data))
          return W
docs: Calculate weight matrix based on fMRI data and factors
  
          Parameters
          ----------
  
          data : 2D array, with shape [n_voxel, n_tr]
              fMRI data from one subject
  
          F : 2D array, with shape [n_voxel,self.K]
              The latent factors from fMRI data.
  
  
          Returns
          -------
  
          W : 2D array, with shape [K, n_tr]
              The weight matrix from fMRI data.