class_docstr: Probabilistic Shared Response Model (SRM)
  
  Given multi-subject data, factorize it as a shared response S among all
  subjects and an orthogonal transform W per subject:
  
  .. math:: X_i \approx W_i S, \forall i=1 \dots N
  
  Parameters
  ----------
  
  n_iter : int, default: 10
      Number of iterations to run the algorithm.
  
  features : int, default: 50
      Number of features to compute.
  
  rand_seed : int, default: 0
      Seed for initializing the random number generator.
  
  comm : mpi4py.MPI.Intracomm
      The MPI communicator containing the data
  
  Attributes
  ----------
  
  w_ : list of array, element i has shape=[voxels_i, features]
      The orthogonal transforms (mappings) for each subject.
  
  s_ : array, shape=[features, samples]
      The shared response.
  
  sigma_s_ : array, shape=[features, features]
      The covariance of the shared response Normal distribution.
  
  mu_ : list of array, element i has shape=[voxels_i]
      The voxel means over the samples for each subject.
  
  rho2_ : array, shape=[subjects]
      The estimated noise variance :math:`\rho_i^2` for each subject
  
  comm : mpi4py.MPI.Intracomm
      The MPI communicator containing the data
  
  random_state_: `RandomState`
      Random number generator initialized using rand_seed
  
  Note
  ----
  
     The number of voxels may be different between subjects. However, the
     number of samples must be the same across subjects.
  
     The probabilistic Shared Response Model is approximated using the
     Expectation Maximization (EM) algorithm proposed in [Chen2015]_. The
     implementation follows the optimizations published in [Anderson2016]_.
  
     This is a single node version.
  
     The run-time complexity is :math:`O(I (V T K + V K^2 + K^3))` and the
     memory complexity is :math:`O(V T)` with I - the number of iterations,
     V - the sum of voxels from all subjects, T - the number of samples, and
     K - the number of features (typically, :math:`V \gg T \gg K`).
class_docstr_tok: ["Probabilistic","Shared","Response","Model","(","SRM",")","Given","multi-subject","data",",","factorize","it","as","a","shared","response","S","among","all","subjects","and","an","orthogonal","transform","W","per","subject",":","..","math",":",":","X_i","\\approx","W_i","S",",","\\forall","i=1","\\dots","N","Parameters","--","--","--","--","--","n_iter",":","int",",","default",":","10","Number","of","iterations","to","run","the","algorithm",".","features",":","int",",","default",":","50","Number","of","features","to","compute",".","rand_seed",":","int",",","default",":","0","Seed","for","initializing","the","random","number","generator",".","comm",":","mpi4py.MPI.Intracomm","The","MPI","communicator","containing","the","data","Attributes","--","--","--","--","--","w_",":","list","of","array",",","element","i","has","shape=","[","voxels_i",",","features","]","The","orthogonal","transforms","(","mappings",")","for","each","subject",".","s_",":","array",",","shape=","[","features",",","samples","]","The","shared","response",".","sigma_s_",":","array",",","shape=","[","features",",","features","]","The","covariance","of","the","shared","response","Normal","distribution",".","mu_",":","list","of","array",",","element","i","has","shape=","[","voxels_i","]","The","voxel","means","over","the","samples","for","each","subject",".","rho2_",":","array",",","shape=","[","subjects","]","The","estimated","noise","variance",":","math",":","`","\\rho_i^2","`","for","each","subject","comm",":","mpi4py.MPI.Intracomm","The","MPI","communicator","containing","the","data","random_state_",":","`","RandomState","`","Random","number","generator","initialized","using","rand_seed","Note","--","--","The","number","of","voxels","may","be","different","between","subjects",".","However",",","the","number","of","samples","must","be","the","same","across","subjects",".","The","probabilistic","Shared","Response","Model","is","approximated","using","the","Expectation","Maximization","(","EM",")","algorithm","proposed","in","[","Chen2015","]","_",".","The","implementation","follows","the","optimizations","published","in","[","Anderson2016","]","_",".","This","is","a","single","node","version",".","The","run-time","complexity","is",":","math",":","`","O","(","I","(","V","T","K","+","V","K^2","+","K^3",")",")","`","and","the","memory","complexity","is",":","math",":","`","O","(","V","T",")","`","with","I","-","the","number","of","iterations",",","V","-","the","sum","of","voxels","from","all","subjects",",","T","-","the","number","of","samples",",","and","K","-","the","number","of","features","(","typically",",",":","math",":","`","V","\\gg","T","\\gg","K","`",")","."]
docstr: Updates the mappings `W_i` for one subject.
  
  Parameters
  ----------
  
  Xi : array, shape=[voxels, timepoints]
      The fMRI data :math:`X_i` for aligning the subject.
  
  S : array, shape=[features, timepoints]
      The shared response.
  
  Returns
  -------
  
  Wi : array, shape=[voxels, features]
      The orthogonal transform (mapping) :math:`W_i` for the subject.
docstr_tok: ["Updates","the","mappings","`","W_i","`","for","one","subject",".","Parameters","--","--","--","--","--","Xi",":","array",",","shape=","[","voxels",",","timepoints","]","The","fMRI","data",":","math",":","`","X_i","`","for","aligning","the","subject",".","S",":","array",",","shape=","[","features",",","timepoints","]","The","shared","response",".","Returns","--","--","--","-","Wi",":","array",",","shape=","[","voxels",",","features","]","The","orthogonal","transform","(","mapping",")",":","math",":","`","W_i","`","for","the","subject","."]
code: def _update_transform_subject(Xi, S):
      """Updates the mappings `W_i` for one subject.
  
      Parameters
      ----------
  
      Xi : array, shape=[voxels, timepoints]
          The fMRI data :math:`X_i` for aligning the subject.
  
      S : array, shape=[features, timepoints]
          The shared response.
  
      Returns
      -------
  
      Wi : array, shape=[voxels, features]
          The orthogonal transform (mapping) :math:`W_i` for the subject.
      """
      A = Xi.dot(S.T)
      # Solve the Procrustes problem
      U, _, V = np.linalg.svd(A, full_matrices=False)
      return U.dot(V)
  
imports: import logging
  import numpy
  import scipy
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils import assert_all_finite
  from sklearn.exceptions import NotFittedError
  from mpi4py import MPI
  import sys
label_desc: Use image node_id 6 for calling the SRM obj's underlying member method code with example usage: obj._update_transform_subject(Xi, S) and returns: U