# Path: brainiak/utils/utils.py
# def circ_dist(x, y):
# def from_tri_2_sym(tri, dim):
# def from_sym_2_tri(symm):
# def sumexp_stable(data):
# def concatenate_not_none(data, axis=0):
# def cov2corr(cov):
#     def __init__(self, fname=None, include_orth=True, include_pols=True):
#     def read_afni(self, fname):
# def gen_design(stimtime_files, scan_duration, TR, style='FSL',
#                temp_res=0.01,
#                hrf_para={'response_delay': 6, 'undershoot_delay': 12,
#                          'response_dispersion': 0.9,
#                          'undershoot_dispersion': 0.9,
#                          'undershoot_scale': 0.035}):
# def _read_stimtime_FSL(stimtime_files, n_C, n_S, scan_onoff):
# def _read_stimtime_AFNI(stimtime_files, n_C, n_S, scan_onoff):
# def center_mass_exp(interval, scale=1.0):
# def usable_cpu_count():
# def phase_randomize(data, voxelwise=False, random_state=None):
# def p_from_null(observed, distribution,
#                 side='two-sided', exact=False,
#                 axis=None):
# def _check_timeseries_input(data):
# def array_correlation(x, y, axis=0):
# class ReadDesign:
# 
# Path: brainiak/funcalign/srm.py
# def _init_w_transforms(data, features, random_states, comm=MPI.COMM_SELF):
# def load(file):
#     def __init__(self, n_iter=10, features=50, rand_seed=0,
#                  comm=MPI.COMM_SELF):
#     def fit(self, X, y=None):
#     def transform(self, X, y=None):
#     def _init_structures(self, data, subjects):
#     def _likelihood(self, chol_sigma_s_rhos, log_det_psi, chol_sigma_s,
#                     trace_xt_invsigma2_x, inv_sigma_s_rhos, wt_invpsi_x,
#                     samples):
#     def _update_transform_subject(Xi, S):
#     def transform_subject(self, X):
#     def save(self, file):
#     def _srm(self, data):
#     def __init__(self, n_iter=10, features=50, rand_seed=0):
#     def fit(self, X, y=None):
#     def transform(self, X, y=None):
#     def _objective_function(self, data, w, s):
#     def _compute_shared_response(self, data, w):
#     def _update_transform_subject(Xi, S):
#     def transform_subject(self, X):
#     def _srm(self, data):
# class SRM(BaseEstimator, TransformerMixin):
# class DetSRM(BaseEstimator, TransformerMixin):
#         A = Xi.dot(S.T)
#         U, _, V = np.linalg.svd(A, full_matrices=False)
#         A = Xi.dot(S.T)
#         U, _, V = np.linalg.svd(A, full_matrices=False)


import logging
import numpy as np
import theano
import theano.tensor as T
import theano.compile.sharedvalue as S
import pymanopt
import gc
from sklearn.base import BaseEstimator, TransformerMixin, ClassifierMixin
from sklearn.utils import assert_all_finite
from sklearn.utils.validation import NotFittedError
from sklearn.utils.multiclass import unique_labels
from pymanopt.manifolds import Euclidean
from pymanopt.manifolds import Product
from pymanopt.solvers import ConjugateGradient
from pymanopt import Problem
from pymanopt.manifolds import Stiefel
from brainiak.utils import utils
from brainiak.funcalign import srm
        return s

    def predict(self, X):
        """Classify the output for given data

        Parameters
        ----------

        X : list of 2D arrays, element i has shape=[voxels_i, samples_i]
            Each element in the list contains the fMRI data of one subject
            The number of voxels should be according to each subject at
            the moment of training the model.

        Returns
        -------
        p: list of arrays, element i has shape=[samples_i]
            Predictions for each data sample.
        """
        # Check if the model exist
        if hasattr(self, 'w_') is False:
            raise NotFittedError("The model fit has not been run yet.")

        # Check the number of subjects
        if len(X) != len(self.w_):
            raise ValueError("The number of subjects does not match the one"
                             " in the model.")

        X_shared = self.transform(X)
        p = [None] * len(X_shared)
        for subject in range(len(X_shared)):

# Path: brainiak/utils/utils.py
# def circ_dist(x, y):
# def from_tri_2_sym(tri, dim):
# def from_sym_2_tri(symm):
# def sumexp_stable(data):
# def concatenate_not_none(data, axis=0):
# def cov2corr(cov):
#     def __init__(self, fname=None, include_orth=True, include_pols=True):
#     def read_afni(self, fname):
# def gen_design(stimtime_files, scan_duration, TR, style='FSL',
#                temp_res=0.01,
#                hrf_para={'response_delay': 6, 'undershoot_delay': 12,
#                          'response_dispersion': 0.9,
#                          'undershoot_dispersion': 0.9,
#                          'undershoot_scale': 0.035}):
# def _read_stimtime_FSL(stimtime_files, n_C, n_S, scan_onoff):
# def _read_stimtime_AFNI(stimtime_files, n_C, n_S, scan_onoff):
# def center_mass_exp(interval, scale=1.0):
# def usable_cpu_count():
# def phase_randomize(data, voxelwise=False, random_state=None):
# def p_from_null(observed, distribution,
#                 side='two-sided', exact=False,
#                 axis=None):
# def _check_timeseries_input(data):
# def array_correlation(x, y, axis=0):
# class ReadDesign:
# 
# Path: brainiak/funcalign/srm.py
# def _init_w_transforms(data, features, random_states, comm=MPI.COMM_SELF):
# def load(file):
#     def __init__(self, n_iter=10, features=50, rand_seed=0,
#                  comm=MPI.COMM_SELF):
#     def fit(self, X, y=None):
#     def transform(self, X, y=None):
#     def _init_structures(self, data, subjects):
#     def _likelihood(self, chol_sigma_s_rhos, log_det_psi, chol_sigma_s,
#                     trace_xt_invsigma2_x, inv_sigma_s_rhos, wt_invpsi_x,
#                     samples):
#     def _update_transform_subject(Xi, S):
#     def transform_subject(self, X):
#     def save(self, file):
#     def _srm(self, data):
#     def __init__(self, n_iter=10, features=50, rand_seed=0):
#     def fit(self, X, y=None):
#     def transform(self, X, y=None):
#     def _objective_function(self, data, w, s):
#     def _compute_shared_response(self, data, w):
#     def _update_transform_subject(Xi, S):
#     def transform_subject(self, X):
#     def _srm(self, data):
# class SRM(BaseEstimator, TransformerMixin):
# class DetSRM(BaseEstimator, TransformerMixin):
#         A = Xi.dot(S.T)
#         U, _, V = np.linalg.svd(A, full_matrices=False)
#         A = Xi.dot(S.T)
#         U, _, V = np.linalg.svd(A, full_matrices=False)


# Path: brainiak/funcalign/sssrm.py
import logging
import numpy as np
import theano
import theano.tensor as T
import theano.compile.sharedvalue as S
import pymanopt
import gc
from sklearn.base import BaseEstimator, TransformerMixin, ClassifierMixin
from sklearn.utils import assert_all_finite
from sklearn.utils.validation import NotFittedError
from sklearn.utils.multiclass import unique_labels
from pymanopt.manifolds import Euclidean
from pymanopt.manifolds import Product
from pymanopt.solvers import ConjugateGradient
from pymanopt import Problem
from pymanopt.manifolds import Stiefel
from brainiak.utils import utils
from brainiak.funcalign import srm

        return s

    def predict(self, X):
        """Classify the output for given data

        Parameters
        ----------

        X : list of 2D arrays, element i has shape=[voxels_i, samples_i]
            Each element in the list contains the fMRI data of one subject
            The number of voxels should be according to each subject at
            the moment of training the model.

        Returns
        -------
        p: list of arrays, element i has shape=[samples_i]
            Predictions for each data sample.
        """
        # Check if the model exist
        if hasattr(self, 'w_') is False:
            raise NotFittedError("The model fit has not been run yet.")

        # Check the number of subjects
        if len(X) != len(self.w_):
            raise ValueError("The number of subjects does not match the one"
                             " in the model.")

        X_shared = self.transform(X)
        p = [None] * len(X_shared)
        for subject in range(len(X_shared)):

            sumexp, _, exponents = utils.sumexp_stable(