Programming Intro Exercises - NSBLab/MATLAB-connectome-intro GitHub Wiki

Programming Language Exercises

These exercises are intended to recap some of the topics covered in the previous sections (e.g. importing data, plotting data, simple statistics). These exercises are not specific to any particular language - you should attempt these in your choice of language.

The data required for the exercises are available in the repo here. Solutions are provided in MATLAB (exercises.mlx here), and other languages coming soon.

Importing and Manipulating Data

  • Import the data from 2-subjects.csv as an array, matrix or equivalent
  • Separate that data into 2 variables (which are square matrices). The first variable should be called subj1 and should contain the data from the first 82 rows. The next variable should be called subj2 and should contain the data from the next 82 rows.
    • The first 34 rows/cols are the left hemisphere cortex. The next 7 are the left subcortex. The next 34 are the right hemisphere cortex. The last 7 are the right subcortex.
  • Import the data from coords.csv as an array, matrix or equivalent into the variable coords

Plotting Data

Analysing Data

  • Correlations between subjects
    • Find the positions in the heatmaps that are non-zero for both subj1 and subj2.
    • Plot the log of the edge weights of the two subjects at these locations on a 2-D scatter plot. https://github.com/BMHLab/MATLAB-connectome-intro/wiki/images/Picture10.png
    • Find the correlation coefficient of this plot.
      • Correlation between log(subj1 edge weight) and log(subj2 edge weight) is 0.718259
    • Optionally, plot a line of regression and find the regression coefficients.
      • Regression coefficients are 0.7398 -0.9963

Advanced Exercises

  • GLM of eigenmodes
    • Read in modes.csv to a variable modes. This should be a 34 x 25 matrix. Note that each of the 34 points corresponds to the first 34 points of the subj datasets.
    • Save the degree of the first 34 nodes of subj1 to a variable called subj1_degree (ideally as a column).
    • Use regression/a generalised linear model, find the loadings of the node degree onto the modes matrix.
      • Your output should be a 25 x 1 vector of coefficients indicating the loadings used to reconstruct the node degree.
    • Now, create a reconstruction of the original degree data using the loadings and the data from modes. What is the correlation between the reconstruction and the original degree data?
      • Correlation between subj1 degree and 25 modes is 0.904497
    • Using a for loop or otherwise, find the reconstruction accuracy/correlation coefficient when using 5, 10, 15, 20, or 25 modes:
      • Using 5 modes, recon accuracy = 0.668466
      • Using 10 modes, recon accuracy = 0.779506
      • Using 15 modes, recon accuracy = 0.827639
      • Using 20 modes, recon accuracy = 0.883510
      • Using 25 modes, recon accuracy = 0.904497
    • Optionally, find and plot the reconstruction accuracy when using 2, 3, 4, ..., 25 modes: https://github.com/BMHLab/MATLAB-connectome-intro/wiki/images/Picture11.png