
import numpy as np


def _check_stc(stc1, stc2):
    # XXX What should we check? that the data is having the same size?
    if stc1.data.shape != stc2.data.shape:
        raise ValueError('Data in stcs must have the same size')
    if stc1.times != stc2.times:
        raise ValueError('Times of two stcs must match.')



def source_estimate_quantification(stc1, stc2, metric='rms'):
    """Helper function to calculate matrix similarities.

    Parameters
    ----------
    stc1 : SourceEstimate
        First source estimate for comparison
    stc2 : SourceEstimate
        First source estimate for comparison
    metric : str
        Metric to calculate. 'rms', 'avg_corrcoef',

    Returns
    -------

    """

    # TODO Add checks for source space
    _check_stc(stc1, stc2)

    score = _calc_metric(stc1.data, stc2.data, metric)

def _calc_metric(data1, data2, metric):
    """Calculate metric of choice"""

    # Calculate root mean square difference between two matrices
    if metric == 'rms':
        return np.mean((stc1.data - stc2.data) ** 2)

    # Calculate correlation coefficient between matrix elements
    elif metric == 'avg_corrcoef':
        return np.mean(np.corrcoeff(stc1.data, stc2.data))


@@ -1,8 +1,112 @@
+# Authors: Yousra Bekhti%0A#          Mark Wronkiewicz %3Cwronk.mark@gmail.com%3E%0A#%0A# License: BSD (3-clause)%0A
 %0Aimport 
@@ -986,17 +986,27 @@
 %0A    %22%22%22
-C
+Helper to c
 alculate
@@ -1022,16 +1022,329 @@
 f choice
+.%0A%0A    Parameters%0A    ----------%0A    data1 : ndarray, shape(n_sources, ntimes)%0A        Second data matrix%0A    data2 : ndarray, shape(n_sources, ntimes)%0A        Second data matrix%0A    metric : str%0A        Metric to calculate. 'rms', 'corr',%0A%0A    Returns%0A    -------%0A    score : float%0A        Calculated metric%0A    
 %22%22%22%0A%0A   
@@ -1567,28 +1567,20 @@
 ric == '
-avg_corrcoef
+corr
 ':%0A     
@@ -1596,35 +1596,37 @@
  np.
-mean(np.corrcoeff(stc1.data
+correlate(stc1.data.flatten()
 , st
@@ -1636,8 +1636,16 @@
 data
+.flatten(
 ))%0A
-%0A

Add documentation, tests, fix corr