U
    f»{j²  ã                   @   s*   d dl ZddlmZ dd„ Zd	dd„ZdS )
é    Né   )Ú_check_optionc                 C   s6   | j j|j jkrtdƒ‚t | j|jk¡r2tdƒ‚dS )zCheck that stcs are compatible.z$Data in stcs must have the same sizezTimes of two stcs must match.N)ÚdataÚshapeÚ
ValueErrorÚnpÚallÚtimes)Ústc1Ústc2© r   úU/var/www/html/bwave/python/venv/lib/python3.8/site-packages/mne/simulation/metrics.pyÚ
_check_stc   s    r   Úrmsc                 C   s†   t d|ddgƒ t| |ƒ | j|j }}|dkrJt t || d ¡¡}n8|dkr‚dt | ¡ | ¡ ¡tj 	|¡tj 	|¡   }|S )a[  Calculate matrix similarities.

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

    Returns
    -------
    score : float | array
        Calculated metric.

    Notes
    -----
    Metric calculation has multiple options:

        * rms: Root mean square of difference between stc data matrices.
        * cosine: Normalized correlation of all elements in stc data matrices.

    .. versionadded:: 0.10.0
    Úmetricr   Zcosiner   g      ð?)
r   r   r   r   ÚsqrtZmeanÚdotÚflattenZlinalgZnorm)r
   r   r   Zdata1Zdata2Zscorer   r   r   Úsource_estimate_quantification   s    
ÿr   )r   )Únumpyr   Úutilsr   r   r   r   r   r   r   Ú<module>   s   