Sample Code

Purpose

I provide sample code in python for model identification. Model identification is the process we use to identify structural connections related to functional connections assigned with a probability. The aim is to demonstrate some of the concepts of our approach and I would also provide more examples and sample data in the future.
Note that this is sample code that DOES NOT INCLUDE the Gaussian graphical model. All the rights for this are reserved to Dr. Gael Varoquaux and a complete version of the software will be likely disseminated from their machine learning tools. Instead, I estimate the correlation coefficient based on the Ledoit-Wolf estimator. This is a regularised version of estimating covariance matrices compared to simple correlation coefficient.

Description of the Software

Inputs:

  • The structural connectivity matrices.
    n-by-n arrays contained in text files within the folder specified. Where n is the number of total regions examined.

  • The average time-series of fMRI data.
    n-by-vols array contained in text file within the folder specified. Where vols is the number of fMRI volumes. Data should be preprocessed. Typically, we also remove the average signal of white matter, csf and motion parameters.

  • The percentage of connections to be included in the model (controls sparsity).
    Typically, we use model selection to choice this parameter. Model selection involves cross-validation to select the model with the least prediction error. In our experiments, a value of around 60% to 70% provided the best results. This parameter may differ according to the description of structural and functional connectivity as well as the noise in the data.

  • For visualisation of the results:

    • A subset of regions should be provided.
      For a comprehensive visualisation of the results, we recommend a small sub-set of regions.

    • A threshold, thres.
      The structural connection with probability within the highest thres (as percentage) will be displayed.

Output:

  • An adjacency matrix that displays the structural connections related to the functional connections estimated from the subset of regions provided.

Functions:

The software includes the following functions:

  • fun2strucInt_v01.py:
    Main script to run. All the parameters and paths are set here.

    • It loads structural connectivity matrices and symmetrizes them.

    • It loads functional time series and estimate the precision matrix based on the LedoitWolf estimator.

    • It calls: StrucSup, cs_amdW, prepChol, visual_res.

  • StrucSup:
    It estimates the structural support. This is a square array n-by-n with with ones where a connection is supported and zero for the rest.

  • cs_amdW:
    It estimate the Minimum degree ordering that provide a sparser cholesky decomposition. Note that this is a function that wraps cs_amd.c function of the CSparse library, directly.

    • libctest.so.1.0: This is a compiled version of CSparse library on Ubuntu 10.04.1 LTS (64-bit machine), linked dynamically. If you have a different system you need to rebuild the library. In addition, if your system is a 32-bit machine, you will need to modify my_cs_amd.py to use c_int32.

  • prepChol:
    It estimate the cholesky decomposition based on the ordering provided. It also reshapes the data to be N-by-p arrays. Where N is the total non-zero number of connections and p is the number of subjects.

  • run_randomisedLasso:
    It runs randomised Lasso and it returns a list of elements. Each element corresponds to a functional connection and it is a list with N values. Each value is the probability the underlying structural connection to be selected.

  • visual_res:
    It reorder the results and prepare data for visualisation. Note that if a structural connection is picked in association with more than one functional connections, its probability will be averaged.

Software Requirements

It has been tested on a system with the following configuration:

Disclaimer

This software is provided 'as is’ and without any implied support or guarantee.
We would like to hear from you, if you find this work useful.

Downloads

  • Download mapFunctionOnStructure

  • Unnzip it with: tar -zxvf mapFunctionOnStructure.tar.gz

  • Edit 'fun2strucInt_v01.py’ to change the filepaths, filenames and parameters.

  • Execute 'run fun2strucInt_vO1.py’ within python.

Related Publications

  • F. Deligianni et al., Relating Brain Functional Connectivity to Anatomical Connections: Prediction and Inference, IEEE Trans on Med Imaging.

  • F. Deligianni, G. Varoquaux, B. Thirion, E. Robinson, D.J. Sharp, A. D. Edwards and D. Rueckert, Relating brain functional connectivity to anatomical connections: Model Selection, NIPS-MLNI, 2011. pdf

  • F. Deligianni, G. Varoquaux, B. Thirion, E.Robinson, D.Sharp, A.Edwards, and D.Rueckert, A Probabilistic Framework to Infer Brain Functional Connectivity from Anatomical Connections, IPMI, 296-307, 2011. pdf