diff --git a/text/TODO.txt b/text/TODO.txt index f07e85a..a62485f 100644 --- a/text/TODO.txt +++ b/text/TODO.txt @@ -100,5 +100,5 @@ 2016-11-02 ---------- BCI2000 - what does the signal values (int) mean? -via... +via finally fixed \o/ mean on EMG? diff --git a/text/thesis/02MaterialsAndMethods.tex b/text/thesis/02MaterialsAndMethods.tex index f999a92..36cdb24 100644 --- a/text/thesis/02MaterialsAndMethods.tex +++ b/text/thesis/02MaterialsAndMethods.tex @@ -154,11 +154,17 @@ \label{fig:kernel} \end{figure} Common kernels are polynomial, Gaussian and hyperbolic kernels. + \subsection{Confusion Matrix} + \label{mm:cm} + %TODO: 2 classes: specifity ... + The confusion matrix is a visualization of classifications. In it for every class the number of samples classified as each class is shown. This is interesting since it can show bias and give a feeling for similar cases where similar is meant according to the features.\\ + %TODO: figure Convusion matrix \subsection{Regression} Regression is the idea of finding $\beta$ so that $$y= X\beta+\epsilon$$ where X is the $n\times p$ input matrix and y the $n\times 1$ output vector of a system. Having this $\beta$ from given input the output can be predicted.\\ There are different ways to find this $\beta$. One common approach is the \emph{ordinary least squares}-Algorithm. $$\hat{\beta}=\arg\min\limits_{b\in\mathds{R}^p} \left(y-Xb\right)^T\left(y-Xb\right),$$ meaning the chosen $\hat\beta$ is that $b$ which produces the lowest error since $Xb$ should be - besides from noise $\epsilon$ - the same as $y$.\\ Choosing $\beta$ like this brings the risk of overfitting. The training data is matched well, new data however are classified poorly. This problem is addressed with RIDGE-Regression. \subsubsection{RIDGE-Regression} + \label{mm:ridge} Instead of minimizing only the error in RIDGE-Regression (also called \emph{Tikhonov regularization}) the size of vector $\beta$ is also minimized: $$\hat{\beta}=\arg\min\limits_{b\in\mathds{R}^p} \left(y-Xb\right)^T\left(y-Xb\right)+\lambda b^Tb.$$ $\lambda$ decides how big the influence of the size of $\beta$ or $b$ respectively is. \subsection{Cross Validation} @@ -319,7 +325,7 @@ where $N$ is the number of measurements in the time window and $x_i$ are the measurements themselves.\\ It describes the length of the way of a needle plotting the EMG on a self-moving band. \subsection{Classification} - \label{sec:newClass} + \label{mm:newClass} Very bad results when classifying EMG into Move/Rest made us further inspect the data. The actual movement came quite a while after the stimulus.\\ To address this problem we did a re-classification of the data according to actual movements (cf. Appendix~\ref{code:classify}). To decide whether the subject is moving or not we compare the mean EMG activity (from Waveform Length) to a threshold (10,000 by default).\\ If there is movement we define the class occurring most in the second before as the current task. If there is movement but the stimulus tells to rest, we assign the last active stimulus.\\ @@ -340,5 +346,26 @@ Size of this data is same as EMG and Synergies in length but has only three features per time step since we used only 3D positioning ($x,y$ and $\theta$) of the hand and no information about the fingers. \section{Data Analysis} \subsection{Classification} - Classification can be done in different ways. First approach was discriminating Movement from Rest. This was done by training an SVM and testing its results with 10-fold cross validation. This was done with EMG, EEG and LF data. EMG in this setting is trivial since it was the basis for the classification (cf. \ref{sec:newClass}).\\ - In a second step we tried to discriminate movement in different directions also with an SVM trained on EMG, EEG or LF data respectively. The fit of the model was also checked with 10-fold cross validation. + Classification can be done in different ways. First approach is discriminating Movement from Rest. This is done by training an SVM and testing its results with 10-fold cross validation. We do this with EMG, EEG and LF data. EMG in this setting is trivial since it was the basis for the classification (cf. \ref{mm:newClass}).\\ + In a second step we try to discriminate movement in different directions also with an SVM trained on EMG, EEG or LF data respectively. The fit of the model is also checked with 10-fold cross validation.\\ + For unbiased classification it is necessary to train with equally sized classes. For that purpose and to lower computation time we only take in 250 (as default) samples per class (cf. Comparison of results in Section~\ref{res:maxPerClass}).\\ + The parameter $c$ for the support vector machine is found with an additional step of cross validation or set to 1. (Results in Section~\ref{res:maxC}).\\ + To learn about biased classifications and about similar brain activity for different movements the confusion matrix is created (cf. Section~\ref{mm:cm}).\\ + The resulting accuracy is the mean of each of the 10 cross validation steps. + \subsection{Predicting Kinematics} + The prediction of kinematics is done with ridge regression. Since there are more data for kinematics than for EEG we use the mean position or movement and predict these.\\ + The regression is done in 10-fold cross validation for each dimension ($x,y,\theta$). The parameter $\lambda$ (cf. ~\ref{mm:ridge}) is ascertained with an additional cross validation. The resulting correlation is the mean correlation of each of the 10 parts with the best parameter lambda each. The correlation for the dimensions are calculated independently. + \subsection{Predicting Synergies} + Predicting Synergies works similar as for the kinematics. Only change is that the synergies may have other dimension. Nevertheless each synergy is predicted from all EEG data as one output and correlation is calculated for each synergy. + \subsection{Predicting EMG} + When predicting EMG data we use the sum of the waveform length in the time corresponding to the EEG data. As the EMG data was summed to gain the data for our use this is a reasonable approach.\\ + The remaining steps are the same as for kinematics and Synergies. + \subsection{EEG offset} + Since it takes some time for commands to go from brain to the muscles, we introduced an variable offset between EEG and other data. The offset has to be given in a number of shifts, so in default is a multiple of 200ms.\\ + Results are given in Section~\ref{res:offset}. + \subsection{Prediction with interim step} + All these analyses only show the accuracy of one step. To get a measure for the over-all performance we predict synergies from EEG and use them to predict EMG or kinematics respectively.\\ + The resulting correlation is the mean of the correlations of a 10-fold cross validation where the same unknown synergies are predicted from EEG and used to predict EMG or kinematics. So there is no correction step between the steps and EMG or kinematics are predicted from EEG via the Synergies. Here also different methods to determine Synergies are compared (see Section~\ref{res:differentSynergiesVia}). + \subsection{Evaluation} + +%TODO: evaluation