\chapter{Results}
\label{chp:results}
\section{Classification}
%TODO: Confusion Matrices
    \subsection{Comparison of methods of recording}
        The different methods of recording (EEG, EMG and Low frequencies) also differ in the results. An ANOVA gives $p<0.001$ for all classifications done on 4 different movements and rest.
        \begin{figure}
            \centering
            \includegraphics[width=0.9\textwidth]{pictures/results/classEEGemgLF.png}
            \caption{EEG, EMG and LF compared based on classification accuracy with 5 classes}
            \label{fig:classEEGemgLF}
        \end{figure}
        The mean classification accuracys for the default run are are given in Table~\ref{tab:accs}.
        \begin{table}
            \centering
            \begin{math}
                \begin{array}
                    {r||c|c|c|c}
                    &\text{EMG}&\text{EEG}&\text{LF}&\text{chance}\\\hline
                    mean&60.4&40.4&32.7&20\\
                    std&7.97&2.27&3.35\\
                    max&71.9&46.7&43.4\\
                    min&35.7&37.2&26.2
                \end{array}
            \end{math}
            \caption{Accuracys for the different methods of recording in default configuration}
            \label{tab:accs}
        \end{table}
    \subsection{EMG}
        In figure~\ref{fig:overviewEMG} the different settings for classification based on EMG-data are shown. Default has values as in \ref{mat:default}. The runs with pause leave out the data 1 second before the movement begins (cf. \ref{mat:pause}).
        \begin{figure}
            \centering
            \includegraphics[width=\textwidth]{pictures/results/overviewEMG.png}
            \caption{Classification with EMG-data}
            \label{fig:overviewEMG}
        \end{figure}
        When calculating an ANOVA on the data with and without pause we get $p<0.001$.
    \subsection{EEG}
        In figure~\ref{fig:overviewEEG} the different settings for classification based on EEG-data are shown. Default has values as in \ref{mat:default}. The runs with pause leave out the data 1 second before the movement begins (cf. \ref{mat:pause}). Runs with offset have an offset of 1 or 2 (cf. \ref{mat:offset}).
        \begin{figure}
            \centering
            \includegraphics[width=\textwidth]{pictures/results/overviewEEG.png}
            \caption{Classification with EEG-data}
            \label{fig:overviewEEG}
        \end{figure}
    \subsection{Low Frequencies}
        In figure~\ref{fig:overviewLF} the different settings for classification based on LowFrequency(LF)-data are shown. Default has values as in \ref{mat:default}. The runs with pause leave out the data 1 second before the movement begins (cf. \ref{mat:pause}). Runs with offset have an offset of 1 or 2 (cf. \ref{mat:offset}).
        \begin{figure}
            \centering
            \includegraphics[width=\textwidth]{pictures/results/overviewLF.png}
            \caption{Classification with LF-data}
            \label{fig:overviewLF}
        \end{figure}
    \subsection{Trade-off parameter}
        With a cross validation we compare the results for the soft-margin parameter for $\lambda=0.1,1,10$. The results are shown in figure~\ref{fig:svmCV}.%TODO
    \subsection{Confusion Matrices}
        A confusion matrix shows whether there is systematic error in classification. In figure \ref{fig:cmFull} there are the confusion matrices for EEG and Low Frequency data, in figure \ref{fig:cmEMG} there is the confusion matrix for EMG data. Since EMG works well for classifying Move/Rest there is also one where only the decision is shown which movement is present. In the second plot we see that many movements are classified as class 3. Especially those belonging to class 2.
        \begin{figure}[p]
            \centering
            \includegraphics[width=\textwidth]{pictures/results/cmEEGfull.png}
            \includegraphics[width=\textwidth]{pictures/results/cmLFfull.png}
            \caption{Confusion Matrices in default configuration}
            \label{fig:cmFull}
        \end{figure}
        \begin{figure}[p]
            \centering
            \includegraphics[width=\textwidth]{pictures/results/cmEMGfull.png}
            \includegraphics[width=\textwidth]{pictures/results/cmEMGmovements.png}
            \caption{Confusion Matrices in default configuration}
            \label{fig:cmEMG}
        \end{figure}

\section{Regression}
    \subsection{Comparison of methods of recording}
        \subsubsection{Velocities}
            Predicting velocities from EEG, EMG and Low Frequencies is significantly\footnote{$p<0.001$} pairwise different (cf. figure~\ref{fig:corrEEGemgLF}). The corresponding $p$-Values of the ANOVA are given in table~\ref{tab:pCorr}.\\
            The over all performance is given in table \ref{tab:corrKin}.
            \begin{figure}
                \centering
                \includegraphics[width=0.9\textwidth]{pictures/results/corrEEGemgLF.png}
                \caption{EEG, EMG and LF compared based on prediction of velocities}
                \label{fig:corrEEGemgLF}
            \end{figure}
            \begin{table}
                \centering
                \begin{math}
                    \begin{array}
                        {r||c|c|c}
                        &EEG&EMG&LF\\\hline
                        EEG&-&<0.001&<0.001\\
                        EMG&<0.001&-&<0.001\\
                        LF&<0.001&<0.001&-
                    \end{array}
                \end{math}
                \caption{$p$-Values for prediction of velocities from EEG, EMG or LF respectively}
                \label{tab:pCorr}
            \end{table}
            \begin{table}
                \centering
                \begin{math}
                    \begin{array}
                        {r||c|c|c|c}
                        &\text{EMG}&\text{EEG}&\text{LF}\\\hline
                        mean&(0.06,0.08,0.02)&(0.18,0.20,0.01)&(0.04,0.07,-0.01)\\
                        std&(0.05,0.05,0.02)&(0.15,0.13,0.09)&(0.05,0.05,0.04)\\
                        max&(0.19,0.17,0.11)&(0.49,0.49,0.21)&(0.16,0.17,0.10)\\
                        min&(-0.007,0.003,-0.01)&(-0.06,-0.03,-0.18)&(-0.07,-0.02,-0.08)
                    \end{array}
                \end{math}
                \caption{Correlations for the different methods of recording in default configuration predicting velocities}
                \label{tab:corrKin}
            \end{table}
        \subsubsection{Positions}
            Predicting positions from EEG, EMG and Low Frequencies is significantly\footnote{$p<0.001$} different, however not pairwise (cf. figure~\ref{fig:corrEEGemgLFpos}). Positions predicted from EMG and LF are not significantly different. The corresponding $p$-Values of the ANOVA are given in table~\ref{tab:pCorrPos}.\\
            The over all performance is given in table \ref{tab:corrPos}.
            \begin{figure}
                \centering
                \includegraphics[width=0.9\textwidth]{pictures/results/corrEEGemgLFpos.png}
                \caption{EEG, EMG and LF compared based on prediction of positions}
                \label{fig:corrEEGemgLFpos}
            \end{figure}
            \begin{table}
                \centering
                \begin{math}
                    \begin{array}
                        {r||c|c|c}
                        &EEG&EMG&LF\\\hline
                        EEG&-&<0.001&<0.001\\
                        EMG&<0.001&-&0.34\\
                        LF&<0.001&0.34&-
                    \end{array}
                \end{math}
                \caption{$p$-Values for prediction of positions from EEG, EMG or LF respectively}
                \label{tab:pCorrPos}
            \end{table}
            \begin{table}
                \centering
                \begin{math}
                    \begin{array}
                        {r||c|c|c|c}
                        &\text{EMG}&\text{EEG}&\text{LF}\\\hline
                        mean&(0.27,0.30,0.15)&(0.57,0.56,0.50)&(0.27,0.26,0.20)\\
                        std&(0.14,0.16,0.09)&(0.13,0.13,0.13)&(0.09,0.07,0.08)\\
                        max&(0.52,0.56,0.42)&(0.79,0.75,0.84)&(0.52,0.43,0.44)\\
                        min&(0.07,0.05,0.04)&(0.19,0.28,0.24)&(0.13,0.14,0.10)
                    \end{array}
                \end{math}
                \caption{Correlations for the different methods of recording in default configuration predicting positions}
                \label{tab:corrPos}
            \end{table}
    \subsection{Compare Prediction direct and via Synergies}
        \subsubsection{Velocities}
            There is a significant\footnote{$p<0.001$} difference between the predictions. The different synergies however have no significant difference ($p\approx0.87$). Also see figure~\ref{fig:directVia}.
            \begin{figure}
                \centering
                \includegraphics[width=\textwidth]{pictures/results/predictKinfromEEG.png}
                \caption{Velocities predicted from EEG direct or via Synergies}
                \label{fig:directVia}
            \end{figure}
        \subsubsection{Positions}
            There is a significant\footnote{$p<0.001$} difference between the predictions. The different synergies however have no significant difference ($p\approx0.85$). Also see figure~\ref{fig:directViaPos}.
            \begin{figure}
                \centering
                \includegraphics[width=\textwidth]{pictures/results/predictPosfromEEG.png}
                \caption{Positions predicted from EEG direct or via Synergies}
                \label{fig:directViaPos}
            \end{figure}
        \subsubsection{EMG}
            There is a significant difference between predicting EMG from EEG directly or via Autoencoders ($p<0.001$, see figure~\ref{fig:directViaEMG}).
            \begin{figure}
                \centering
                \includegraphics[width=\textwidth]{pictures/results/predictEMGfromEEG.png}
                \caption{EMG predicted from EEG direct or via Autoencoder}
                \label{fig:directViaEMG}
            \end{figure}
    \subsection{EEG}
        \subsubsection{Offset}
        \label{res:offsetEEG}
            Offset makes no significant difference when predicting Synergies\footnote{Autoencoder: $p\approx0.81$, PCA: $p\approx0.77$, NMF: $p\approx0.60$} or velocities ($p\approx0.99$) or positions ($p\approx0.98$).
        \subsubsection{Pause}
            Whether there is a pause of 1s or only 0.5s doesn't make a significant difference for Autoencoder ($p\approx0.13$), PCA ($p\approx0.29$), NMF ($p\approx0.05$) or Velocities ($p\approx0.95$).
        \subsubsection{EMG}
            We also predict EMG from EEG. The results are shown in figure \ref{fig:EEGemg}. There are no significant differences between the channels ($p\approx0.29$).
            \begin{figure}
                \centering
                \includegraphics[width=\textwidth]{pictures/results/EEGemg.png}
                \caption{Prediction of EMG from EEG}
                \label{fig:EEGemg}
            \end{figure}
    \subsection{EMG}
        Using a offset or not does not make any difference since the offset is only applied on EEG-data (cf. \ref{mat:offset}).\\
        Predicting synergies from EMG does not make sense since they are computed from EMG (cf. \ref{mat:synergies}).\\
        \subsubsection{Pause}
            There is no significant effect of the use of a pause when predicting velocities from EMG ($p\approx0.90$).
    \subsection{Low Frequencies}
        \subsubsection{Offset}
        \label{res:offsetLF}
            Offset makes no significant difference for predicting Autoencoder ($p\approx0.50$), PCA ($p\approx0.59$), NMF ($p\approx0.38$), velocities ($p\approx0.97$) or position ($p\approx1.0$).
        \subsubsection{Pause}
            There is no effect of pause for velocities from low frequencies ($p\approx0.73$).\\
            However there is an effect for Autoencoder ($p<0.001$), PCA ($p<0.001$) and NMF ($p<0.001$).

            The plot shows a better performance with a shorter pause and more data taken in (see figure~\ref{fig:lfToAutoencPause})
            \begin{figure}
                \centering
                \includegraphics[width=\textwidth]{pictures/results/lfToAutoencPause.png}
                \caption{Autoencoder data predicted from Low Frequencies}
                \label{fig:lfToAutoencPause}
            \end{figure}
    \subsection{Autoencoder}
        In table~\ref{tab:corrAutoenc} the correlations for velocities and positions predicted from Autoencoder are given. The data for the Autoencoder were calculated from recorded EMG data.
        \begin{table}
            \centering
            \begin{math}
                \begin{array}
                    {r||c|c|c|c}
                    &\text{velocities}&\text{positions}\\\hline
                    mean&(0.05,0.08,0.01)&(0.20,0.29,0.11)\\
                    std&(0.04,0.05,0.02)&(0.12,0.16,0.08)\\
                    max&(0.18,0.17,0.08)&(0.51,0.60,0.38)\\
                    min&(-0.02,-0.01,-0.01)&(0.03,0.03,0.02)
                \end{array}
            \end{math}
            \caption{Correlations for predicting velocities and positions from Autoencoder data}
            \label{tab:corrAutoenc}
        \end{table}
    \subsection{Cross-validation of Ridge Parameter}
        %TODO
\section{Topographical plots}
    %Maybe in discussion
