def _prepare_for_cross_validation(self, corr, clf):
        """Prepare data for voxelwise cross validation.

        If the classifier is sklearn.svm.SVC with precomputed kernel,
        the kernel matrix of each voxel is computed, otherwise do nothing.

        Parameters
        ----------
        corr: 3D array in shape [num_processed_voxels, num_epochs, num_voxels]
            the normalized correlation values of all subjects in all epochs
            for the assigned values, in row-major
        clf: classification function
            the classifier to be used in cross validation

        Returns
        -------
        data: 3D numpy array
            If using sklearn.svm.SVC with precomputed kernel,
            it is in shape [num_processed_voxels, num_epochs, num_epochs];
            otherwise it is the input argument corr,
            in shape [num_processed_voxels, num_epochs, num_voxels]
        """
        time1 = time.time()
        (num_processed_voxels, num_epochs, _) = corr.shape
        if isinstance(clf, sklearn.svm.SVC) and clf.kernel == 'precomputed':
            # kernel matrices should be computed
            kernel_matrices = np.zeros((num_processed_voxels, num_epochs,
                                        num_epochs),
                                       np.float32, order='C')
            for i in range(num_processed_voxels):
                blas.compute_kernel_matrix('L', 'T',
                                           num_epochs, self.num_voxels2,
                                           1.0, corr,
                                           i, self.num_voxels2,
                                           0.0, kernel_matrices[i, :, :],
                                           num_epochs)
                # shrink the values for getting more stable alpha values
                # in SVM training iteration
                num_digits = len(str(int(kernel_matrices[i, 0, 0])))
                if num_digits > 2:
                    proportion = 10**(2-num_digits)
                    kernel_matrices[i, :, :] *= proportion
            data = kernel_matrices
        else:
            data = corr
        time2 = time.time()
        logger.debug(
            'cross validation data preparation takes %.2f s' %
            (time2 - time1)
        )
        return data
Prepare data for voxelwise cross validation.

        If the classifier is sklearn.svm.SVC with precomputed kernel,
        the kernel matrix of each voxel is computed, otherwise do nothing.

        Parameters
        ----------
        corr: 3D array in shape [num_processed_voxels, num_epochs, num_voxels]
            the normalized correlation values of all subjects in all epochs
            for the assigned values, in row-major
        clf: classification function
            the classifier to be used in cross validation

        Returns
        -------
        data: 3D numpy array
            If using sklearn.svm.SVC with precomputed kernel,
            it is in shape [num_processed_voxels, num_epochs, num_epochs];
            otherwise it is the input argument corr,
            in shape [num_processed_voxels, num_epochs, num_voxels]