Connectome pipeline

This tutorial shows how to use the NIAK connectome pipeline to generate seed-based functional connectivity maps on a single subject from the COBRE "lightweight" sample.

  • More documentation: on the various pipeline options can be found on the here.
  • .m script: The notebook and associated Matlab script are available here.
  • Time for completion: this tutorial will take 5-10 minutes to complete.

Preparing files

Functional MRI

First download a small preprocessed fMRI dataset.

In [1]:
clear
path_data = [pwd filesep];
[status,msg,data_fmri] = niak_wget('cobre_lightweight20_nii');

When starting from fMRI data preprocessed with NIAK, it is possible to use niak_grab_fmri_preprocess on the output folder to collect the file names, as described in the pipeline documentation. In this case, we explicitely list all the files

In [2]:
file_pheno = [data_fmri.path filesep 'phenotypic_data.tsv.gz'];
tab = niak_read_csv_cell(file_pheno);
list_subject = tab(2:end,1);
files_in = struct;
for ss = 1:length(list_subject)
    files_in.fmri.(list_subject{ss}).sess1.rest = [data_fmri.path filesep 'fmri_' list_subject{ss} '.nii.gz'];
end

Brain parcellation

The second input of the pipeline is a set of brain parcels. We will just download the so-called Cambridge functional template.

In [3]:
[status,msg,data_template] = niak_wget('cambridge_template_mnc1');

We are going to pick the parcellation into 7 distributed networks.

In [4]:
files_in.network = [data_template.path filesep 'template_cambridge_basc_multiscale_sym_scale007.mnc.gz'];

List of seeds

The next step is to generate a list of seeds. This requires creating a text file that looks like:

        , index
 MOTOR  , 3
 DMN    , 5

We are going to use NIAK's tool to write comma-separated values (CSV) in a file:

In [5]:
files_in.seeds = [path_data 'list_seeds.csv'];
opt_csv.labels_x = { 'MOTOR' , 'DMN' }; % The labels for the network
opt_csv.labels_y = { 'index' };
tab = [3 ; 5];
niak_write_csv(files_in.seeds,tab,opt_csv);

Set the options of the pipeline

Now we set up where to store the results:

In [6]:
opt.folder_out = [path_data 'connectome'];

We set options such that we will not generate graph properties, just the correlation maps:

In [7]:
opt.flag_p2p = false; % No parcel-to-parcel correlation values
opt.flag_global_prop = false; % No global graph properties
opt.flag_local_prop  = false; % No local graph properties
opt.flag_rmap = true; % Generate correlation maps

Run the pipeline

Now let's run the pipeline:

In [8]:
opt.flag_test = false; 
[pipeline,opt] = niak_pipeline_connectome(files_in,opt);
Adding seed MOTOR (parcel number 3)
Adding seed DMN (parcel number 5)

Logs will be stored in /sandbox/home/Desktop/workshop_niak/connectome/logs/
Generating dependencies ...
   Percentage completed :  0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100- 0.16 sec
Setting up the to-do list ...
   I found 93 job(s) to do.
I could not find any log file. This pipeline has not been started (yet?). Press CTRL-C to cancel.
Deamon started on 16-May-2017 12:03:12
16-May-2017 12:03:12 Starting the pipeline manager...
16-May-2017 12:03:12 Starting the garbage collector...
16-May-2017 12:03:12 Starting worker number 1...
16-May-2017 12:03:12 Starting worker number 2...
16-May-2017 12:03:12 Starting worker number 3...
16-May-2017 12:03:12 Starting worker number 4...

Pipeline started on 16-May-2017 12:03:14
user: , host: 7bb4dbfb9281, system: unix
****************************************
16-May-2017 12:03:16 mask_rois            submitted  (1 run | 0 fail | 0 done | 92 left)
16-May-2017 12:03:16 mask_background      submitted  (2 run | 0 fail | 0 done | 91 left)
16-May-2017 12:03:16 pipe_params          submitted  (3 run | 0 fail | 0 done | 90 left)
16-May-2017 12:03:16 cp_report_templates  submitted  (4 run | 0 fail | 0 done | 89 left)
16-May-2017 12:03:16 pipe_params          finished   (3 run | 0 fail | 1 done | 89 left)
16-May-2017 12:03:16 params               submitted  (4 run | 0 fail | 1 done | 88 left)
16-May-2017 12:03:17 cp_report_templates  finished   (3 run | 0 fail | 2 done | 88 left)
16-May-2017 12:03:18 params               finished   (2 run | 0 fail | 3 done | 88 left)
16-May-2017 12:03:21 mask_rois            finished   (1 run | 0 fail | 4 done | 88 left)
16-May-2017 12:03:21 select_rois          submitted  (2 run | 0 fail | 4 done | 87 left)
16-May-2017 12:03:21 connectome_40061     submitted  (3 run | 0 fail | 4 done | 86 left)
16-May-2017 12:03:21 connectome_40117     submitted  (4 run | 0 fail | 4 done | 85 left)
16-May-2017 12:03:21 connectome_40145     submitted  (5 run | 0 fail | 4 done | 84 left)
16-May-2017 12:03:21 connectome_40113     submitted  (6 run | 0 fail | 4 done | 83 left)
16-May-2017 12:03:21 connectome_40029     submitted  (7 run | 0 fail | 4 done | 82 left)
16-May-2017 12:03:21 connectome_40133     submitted  (8 run | 0 fail | 4 done | 81 left)
16-May-2017 12:03:23 select_rois          finished   (7 run | 0 fail | 5 done | 81 left)
16-May-2017 12:03:23 connectome_40117     finished   (6 run | 0 fail | 6 done | 81 left)
16-May-2017 12:03:23 connectome_40145     finished   (5 run | 0 fail | 7 done | 81 left)
16-May-2017 12:03:23 connectome_40029     finished   (4 run | 0 fail | 8 done | 81 left)
16-May-2017 12:03:23 connectome_40020     submitted  (5 run | 0 fail | 8 done | 80 left)
16-May-2017 12:03:23 connectome_40065     submitted  (6 run | 0 fail | 8 done | 79 left)
16-May-2017 12:03:23 connectome_40122     submitted  (7 run | 0 fail | 8 done | 78 left)
16-May-2017 12:03:23 connectome_40051     submitted  (8 run | 0 fail | 8 done | 77 left)
16-May-2017 12:03:23 mask_background      finished   (7 run | 0 fail | 9 done | 77 left)
16-May-2017 12:03:24 connectome_40061     finished   (6 run | 0 fail | 10 done | 77 left)
16-May-2017 12:03:24 connectome_40133     finished   (5 run | 0 fail | 11 done | 77 left)
16-May-2017 12:03:24 connectome_40020     finished   (4 run | 0 fail | 12 done | 77 left)
16-May-2017 12:03:24 connectome_40129     submitted  (5 run | 0 fail | 12 done | 76 left)
16-May-2017 12:03:24 connectome_40037     submitted  (6 run | 0 fail | 12 done | 75 left)
16-May-2017 12:03:24 connectome_40093     submitted  (7 run | 0 fail | 12 done | 74 left)
16-May-2017 12:03:24 connectome_40059     submitted  (8 run | 0 fail | 12 done | 73 left)
16-May-2017 12:03:25 connectome_40113     finished   (7 run | 0 fail | 13 done | 73 left)
16-May-2017 12:03:25 connectome_40104     submitted  (8 run | 0 fail | 13 done | 72 left)
16-May-2017 12:03:25 connectome_40065     finished   (7 run | 0 fail | 14 done | 72 left)
16-May-2017 12:03:25 connectome_40122     finished   (6 run | 0 fail | 15 done | 72 left)
16-May-2017 12:03:25 connectome_40051     finished   (5 run | 0 fail | 16 done | 72 left)
16-May-2017 12:03:25 connectome_40138     submitted  (6 run | 0 fail | 16 done | 71 left)
16-May-2017 12:03:25 connectome_40003     submitted  (7 run | 0 fail | 16 done | 70 left)
16-May-2017 12:03:25 connectome_40008     submitted  (8 run | 0 fail | 16 done | 69 left)
16-May-2017 12:03:26 connectome_40129     finished   (7 run | 0 fail | 17 done | 69 left)
16-May-2017 12:03:26 connectome_40037     finished   (6 run | 0 fail | 18 done | 69 left)
16-May-2017 12:03:26 connectome_40093     finished   (5 run | 0 fail | 19 done | 69 left)
16-May-2017 12:03:26 connectome_40059     finished   (4 run | 0 fail | 20 done | 69 left)
16-May-2017 12:03:26 connectome_40077     submitted  (5 run | 0 fail | 20 done | 68 left)
16-May-2017 12:03:27 connectome_40045     submitted  (6 run | 0 fail | 20 done | 67 left)
16-May-2017 12:03:27 rmap_seeds_40061     submitted  (7 run | 0 fail | 20 done | 66 left)
16-May-2017 12:03:27 rmap_seeds_40117     submitted  (8 run | 0 fail | 20 done | 65 left)
16-May-2017 12:03:27 connectome_40104     finished   (7 run | 0 fail | 21 done | 65 left)
16-May-2017 12:03:28 connectome_40138     finished   (6 run | 0 fail | 22 done | 65 left)
16-May-2017 12:03:28 connectome_40003     finished   (5 run | 0 fail | 23 done | 65 left)
16-May-2017 12:03:28 rmap_seeds_40145     submitted  (6 run | 0 fail | 23 done | 64 left)
16-May-2017 12:03:28 rmap_seeds_40113     submitted  (7 run | 0 fail | 23 done | 63 left)
16-May-2017 12:03:28 rmap_seeds_40029     submitted  (8 run | 0 fail | 23 done | 62 left)
16-May-2017 12:03:28 connectome_40008     finished   (7 run | 0 fail | 24 done | 62 left)
16-May-2017 12:03:28 connectome_40045     finished   (6 run | 0 fail | 25 done | 62 left)
16-May-2017 12:03:28 rmap_seeds_40133     submitted  (7 run | 0 fail | 25 done | 61 left)
16-May-2017 12:03:29 connectome_40077     finished   (6 run | 0 fail | 26 done | 61 left)
16-May-2017 12:03:29 rmap_seeds_40020     submitted  (7 run | 0 fail | 26 done | 60 left)
16-May-2017 12:03:29 rmap_seeds_40065     submitted  (8 run | 0 fail | 26 done | 59 left)
16-May-2017 12:03:31 rmap_seeds_40061     finished   (7 run | 0 fail | 27 done | 59 left)
16-May-2017 12:03:31 rmap_seeds_40117     finished   (6 run | 0 fail | 28 done | 59 left)
16-May-2017 12:03:31 rmap_seeds_40145     finished   (5 run | 0 fail | 29 done | 59 left)
16-May-2017 12:03:31 rmap_seeds_40113     finished   (4 run | 0 fail | 30 done | 59 left)
16-May-2017 12:03:31 rmap_seeds_40122     submitted  (5 run | 0 fail | 30 done | 58 left)
16-May-2017 12:03:31 rmap_seeds_40051     submitted  (6 run | 0 fail | 30 done | 57 left)
16-May-2017 12:03:31 rmap_seeds_40129     submitted  (7 run | 0 fail | 30 done | 56 left)
16-May-2017 12:03:31 rmap_seeds_40037     submitted  (8 run | 0 fail | 30 done | 55 left)
16-May-2017 12:03:34 rmap_seeds_40020     finished   (7 run | 0 fail | 31 done | 55 left)
16-May-2017 12:03:35 rmap_seeds_40029     finished   (6 run | 0 fail | 32 done | 55 left)
16-May-2017 12:03:35 rmap_seeds_40133     finished   (5 run | 0 fail | 33 done | 55 left)
16-May-2017 12:03:35 rmap_seeds_40065     finished   (4 run | 0 fail | 34 done | 55 left)
16-May-2017 12:03:35 rmap_seeds_40093     submitted  (5 run | 0 fail | 34 done | 54 left)
16-May-2017 12:03:35 rmap_seeds_40059     submitted  (6 run | 0 fail | 34 done | 53 left)
16-May-2017 12:03:35 rmap_seeds_40104     submitted  (7 run | 0 fail | 34 done | 52 left)
16-May-2017 12:03:35 rmap_seeds_40138     submitted  (8 run | 0 fail | 34 done | 51 left)
16-May-2017 12:03:37 rmap_seeds_40122     finished   (7 run | 0 fail | 35 done | 51 left)
16-May-2017 12:03:37 rmap_seeds_40051     finished   (6 run | 0 fail | 36 done | 51 left)
16-May-2017 12:03:37 rmap_seeds_40129     finished   (5 run | 0 fail | 37 done | 51 left)
16-May-2017 12:03:37 rmap_seeds_40037     finished   (4 run | 0 fail | 38 done | 51 left)
16-May-2017 12:03:37 rmap_seeds_40003     submitted  (5 run | 0 fail | 38 done | 50 left)
16-May-2017 12:03:37 rmap_seeds_40008     submitted  (6 run | 0 fail | 38 done | 49 left)
16-May-2017 12:03:37 rmap_seeds_40077     submitted  (7 run | 0 fail | 38 done | 48 left)
16-May-2017 12:03:37 rmap_seeds_40045     submitted  (8 run | 0 fail | 38 done | 47 left)
16-May-2017 12:03:40 rmap_seeds_40138     finished   (7 run | 0 fail | 39 done | 47 left)
16-May-2017 12:03:40 background           submitted  (8 run | 0 fail | 39 done | 46 left)
16-May-2017 12:03:40 rmap_seeds_40093     finished   (7 run | 0 fail | 40 done | 46 left)
16-May-2017 12:03:40 rmap_seeds_40104     finished   (6 run | 0 fail | 41 done | 46 left)
16-May-2017 12:03:40 network              submitted  (7 run | 0 fail | 41 done | 45 left)
16-May-2017 12:03:40 img_rmap_MOTOR_40061 submitted  (8 run | 0 fail | 41 done | 44 left)
16-May-2017 12:03:40 rmap_seeds_40059     finished   (7 run | 0 fail | 42 done | 44 left)
16-May-2017 12:03:41 img_rmap_MOTOR_40117 submitted  (8 run | 0 fail | 42 done | 43 left)
16-May-2017 12:03:42 rmap_seeds_40045     finished   (7 run | 0 fail | 43 done | 43 left)
16-May-2017 12:03:42 rmap_seeds_40077     finished   (6 run | 0 fail | 44 done | 43 left)
16-May-2017 12:03:42 img_rmap_MOTOR_40145 submitted  (7 run | 0 fail | 44 done | 42 left)
16-May-2017 12:03:43 rmap_seeds_40003     finished   (6 run | 0 fail | 45 done | 42 left)
16-May-2017 12:03:43 rmap_seeds_40008     finished   (5 run | 0 fail | 46 done | 42 left)
16-May-2017 12:03:43 average_rmap_MOTOR   submitted  (6 run | 0 fail | 46 done | 41 left)
16-May-2017 12:03:43 average_rmap_DMN     submitted  (7 run | 0 fail | 46 done | 40 left)
16-May-2017 12:03:43 img_rmap_MOTOR_40113 submitted  (8 run | 0 fail | 46 done | 39 left)
.
16-May-2017 12:04:15 network              finished   (7 run | 0 fail | 47 done | 39 left)
16-May-2017 12:04:15 img_rmap_MOTOR_40029 submitted  (8 run | 0 fail | 47 done | 38 left)
16-May-2017 12:04:16 img_rmap_MOTOR_40117 finished   (7 run | 0 fail | 48 done | 38 left)
16-May-2017 12:04:16 img_rmap_MOTOR_40133 submitted  (8 run | 0 fail | 48 done | 37 left)
16-May-2017 12:04:16 img_rmap_MOTOR_40061 finished   (7 run | 0 fail | 49 done | 37 left)
16-May-2017 12:04:16 img_rmap_MOTOR_40020 submitted  (8 run | 0 fail | 49 done | 36 left)
.
16-May-2017 12:04:19 average_rmap_MOTOR   finished   (7 run | 0 fail | 50 done | 36 left)
16-May-2017 12:04:19 img_rmap_MOTOR_40065 submitted  (8 run | 0 fail | 50 done | 35 left)
16-May-2017 12:04:19 background           finished   (7 run | 0 fail | 51 done | 35 left)
16-May-2017 12:04:20 average_rmap_DMN     finished   (6 run | 0 fail | 52 done | 35 left)
16-May-2017 12:04:20 img_rmap_MOTOR_40122 submitted  (7 run | 0 fail | 52 done | 34 left)
16-May-2017 12:04:20 img_rmap_MOTOR_40051 submitted  (8 run | 0 fail | 52 done | 33 left)
16-May-2017 12:04:37 img_rmap_MOTOR_40113 finished   (7 run | 0 fail | 53 done | 33 left)
16-May-2017 12:04:37 img_rmap_MOTOR_40129 submitted  (8 run | 0 fail | 53 done | 32 left)
16-May-2017 12:04:40 img_rmap_MOTOR_40020 finished   (7 run | 0 fail | 54 done | 32 left)
16-May-2017 12:04:40 img_rmap_MOTOR_40037 submitted  (8 run | 0 fail | 54 done | 31 left)
16-May-2017 12:04:41 img_rmap_MOTOR_40029 finished   (7 run | 0 fail | 55 done | 31 left)
16-May-2017 12:04:41 img_rmap_MOTOR_40093 submitted  (8 run | 0 fail | 55 done | 30 left)
16-May-2017 12:04:41 img_rmap_MOTOR_40145 finished   (7 run | 0 fail | 56 done | 30 left)
16-May-2017 12:04:42 img_rmap_MOTOR_40059 submitted  (8 run | 0 fail | 56 done | 29 left)
.
16-May-2017 12:04:58 img_rmap_MOTOR_40133 finished   (7 run | 0 fail | 57 done | 29 left)
16-May-2017 12:04:58 img_rmap_MOTOR_40104 submitted  (8 run | 0 fail | 57 done | 28 left)
16-May-2017 12:05:02 img_rmap_MOTOR_40051 finished   (7 run | 0 fail | 58 done | 28 left)
16-May-2017 12:05:02 img_rmap_MOTOR_40138 submitted  (8 run | 0 fail | 58 done | 27 left)
16-May-2017 12:05:02 img_rmap_MOTOR_40122 finished   (7 run | 0 fail | 59 done | 27 left)
16-May-2017 12:05:02 img_rmap_MOTOR_40003 submitted  (8 run | 0 fail | 59 done | 26 left)
16-May-2017 12:05:03 img_rmap_MOTOR_40065 finished   (7 run | 0 fail | 60 done | 26 left)
16-May-2017 12:05:03 img_rmap_MOTOR_40008 submitted  (8 run | 0 fail | 60 done | 25 left)
.
16-May-2017 12:05:20 img_rmap_MOTOR_40129 finished   (7 run | 0 fail | 61 done | 25 left)
16-May-2017 12:05:20 img_rmap_MOTOR_40077 submitted  (8 run | 0 fail | 61 done | 24 left)
16-May-2017 12:05:24 img_rmap_MOTOR_40059 finished   (7 run | 0 fail | 62 done | 24 left)
16-May-2017 12:05:24 img_rmap_MOTOR_40045 submitted  (8 run | 0 fail | 62 done | 23 left)
16-May-2017 12:05:25 img_rmap_MOTOR_40037 finished   (7 run | 0 fail | 63 done | 23 left)
16-May-2017 12:05:25 img_rmap_DMN_40061   submitted  (8 run | 0 fail | 63 done | 22 left)
16-May-2017 12:05:26 img_rmap_MOTOR_40093 finished   (7 run | 0 fail | 64 done | 22 left)
16-May-2017 12:05:26 img_rmap_DMN_40117   submitted  (8 run | 0 fail | 64 done | 21 left)
16-May-2017 12:05:41 img_rmap_MOTOR_40104 finished   (7 run | 0 fail | 65 done | 21 left)
16-May-2017 12:05:41 img_rmap_DMN_40145   submitted  (8 run | 0 fail | 65 done | 20 left)
16-May-2017 12:05:45 img_rmap_MOTOR_40003 finished   (7 run | 0 fail | 66 done | 20 left)
16-May-2017 12:05:45 img_rmap_DMN_40113   submitted  (8 run | 0 fail | 66 done | 19 left)
16-May-2017 12:05:48 img_rmap_MOTOR_40138 finished   (7 run | 0 fail | 67 done | 19 left)
16-May-2017 12:05:48 img_rmap_MOTOR_40008 finished   (6 run | 0 fail | 68 done | 19 left)
16-May-2017 12:05:48 img_rmap_DMN_40029   submitted  (7 run | 0 fail | 68 done | 18 left)
16-May-2017 12:05:48 img_rmap_DMN_40133   submitted  (8 run | 0 fail | 68 done | 17 left)
.
16-May-2017 12:06:02 img_rmap_MOTOR_40077 finished   (7 run | 0 fail | 69 done | 17 left)
16-May-2017 12:06:02 img_rmap_DMN_40020   submitted  (8 run | 0 fail | 69 done | 16 left)
16-May-2017 12:06:07 img_rmap_MOTOR_40045 finished   (7 run | 0 fail | 70 done | 16 left)
16-May-2017 12:06:07 img_rmap_DMN_40065   submitted  (8 run | 0 fail | 70 done | 15 left)
16-May-2017 13:01:12 No heartbeat for process psom1, counted as dead.
16-May-2017 13:01:13 Restarting (1/4) worker number 1...
16-May-2017 13:01:13 Worker 1 has been reset.
16-May-2017 13:01:17 img_rmap_DMN_40117   submitted  (7 run | 0 fail | 70 done | 16 left)
16-May-2017 13:01:17 img_rmap_DMN_40029   submitted  (8 run | 0 fail | 70 done | 15 left)
16-May-2017 13:01:17 img_rmap_DMN_40117   finished   (7 run | 0 fail | 71 done | 15 left)
16-May-2017 13:01:17 img_rmap_DMN_40122   submitted  (8 run | 0 fail | 71 done | 14 left)
16-May-2017 13:01:17 img_rmap_DMN_40061   finished   (7 run | 0 fail | 72 done | 14 left)
16-May-2017 13:01:17 img_rmap_DMN_40051   submitted  (8 run | 0 fail | 72 done | 13 left)
.
16-May-2017 13:01:45 img_rmap_DMN_40145   finished   (7 run | 0 fail | 73 done | 13 left)
16-May-2017 13:01:45 img_rmap_DMN_40129   submitted  (8 run | 0 fail | 73 done | 12 left)
16-May-2017 13:01:51 img_rmap_DMN_40113   finished   (7 run | 0 fail | 74 done | 12 left)
16-May-2017 13:01:51 img_rmap_DMN_40037   submitted  (8 run | 0 fail | 74 done | 11 left)
.
16-May-2017 13:01:58 img_rmap_DMN_40029   finished   (7 run | 0 fail | 75 done | 11 left)
16-May-2017 13:01:58 img_rmap_DMN_40133   finished   (6 run | 0 fail | 76 done | 11 left)
16-May-2017 13:01:58 img_rmap_DMN_40093   submitted  (7 run | 0 fail | 76 done | 10 left)
16-May-2017 13:01:58 img_rmap_DMN_40059   submitted  (8 run | 0 fail | 76 done | 9 left)
16-May-2017 13:01:59 img_rmap_DMN_40122   finished   (7 run | 0 fail | 77 done | 9 left)
16-May-2017 13:01:59 img_rmap_DMN_40104   submitted  (8 run | 0 fail | 77 done | 8 left)
16-May-2017 13:02:18 img_rmap_DMN_40020   finished   (7 run | 0 fail | 78 done | 8 left)
16-May-2017 13:02:19 img_rmap_DMN_40138   submitted  (8 run | 0 fail | 78 done | 7 left)
16-May-2017 13:02:23 img_rmap_DMN_40065   finished   (7 run | 0 fail | 79 done | 7 left)
16-May-2017 13:02:23 img_rmap_DMN_40003   submitted  (8 run | 0 fail | 79 done | 6 left)
.
16-May-2017 13:02:33 img_rmap_DMN_40051   finished   (7 run | 0 fail | 80 done | 6 left)
16-May-2017 13:02:33 img_rmap_DMN_40008   submitted  (8 run | 0 fail | 80 done | 5 left)
16-May-2017 13:02:36 img_rmap_DMN_40093   finished   (7 run | 0 fail | 81 done | 5 left)
16-May-2017 13:02:36 img_rmap_DMN_40077   submitted  (8 run | 0 fail | 81 done | 4 left)
16-May-2017 13:02:53 img_rmap_DMN_40129   finished   (7 run | 0 fail | 82 done | 4 left)
16-May-2017 13:02:53 img_rmap_DMN_40045   submitted  (8 run | 0 fail | 82 done | 3 left)
16-May-2017 13:02:55 img_rmap_DMN_40037   finished   (7 run | 0 fail | 83 done | 3 left)
16-May-2017 13:02:55 img_avg_MOTOR        submitted  (8 run | 0 fail | 83 done | 2 left)
.
16-May-2017 13:03:03 img_rmap_DMN_40104   finished   (7 run | 0 fail | 84 done | 2 left)
16-May-2017 13:03:03 img_avg_DMN          submitted  (8 run | 0 fail | 84 done | 1 left)
16-May-2017 13:03:06 img_rmap_DMN_40059   finished   (7 run | 0 fail | 85 done | 1 left)
16-May-2017 13:03:08 img_rmap_DMN_40077   finished   (6 run | 0 fail | 86 done | 1 left)
16-May-2017 13:03:25 img_rmap_DMN_40138   finished   (5 run | 0 fail | 87 done | 1 left)
16-May-2017 13:03:25 img_rmap_DMN_40003   finished   (4 run | 0 fail | 88 done | 1 left)
16-May-2017 13:03:29 img_avg_DMN          finished   (3 run | 0 fail | 89 done | 1 left)
16-May-2017 13:03:29 Stopping idle worker 1 (not enough jobs left to do).
.
16-May-2017 13:03:34 img_rmap_DMN_40008   finished   (2 run | 0 fail | 90 done | 1 left)
16-May-2017 13:03:34 Stopping idle worker 3 (not enough jobs left to do).
16-May-2017 13:03:46 img_rmap_DMN_40045   finished   (1 run | 0 fail | 91 done | 1 left)
16-May-2017 13:03:46 Stopping idle worker 2 (not enough jobs left to do).
16-May-2017 13:03:47 img_avg_MOTOR        finished   (0 run | 0 fail | 92 done | 1 left)
16-May-2017 13:03:47 rmap_report          submitted  (1 run | 0 fail | 92 done | 0 left)
16-May-2017 13:03:48 rmap_report          finished   (0 run | 0 fail | 93 done | 0 left)
16-May-2017 13:03:48 Stopping idle worker 4 (not enough jobs left to do).

*******************************************
Pipeline terminated on 16-May-2017 13:03:48
All jobs have been successfully completed.

Reviewing outputs

The pipeline generates an interatice dashboard to explore brain connectivity maps. Just open the file connectome/report/index.html in your browser.

All the correlation maps have been generated in the subfolder called rmap_seeds, inside the output folder. There are first two average (across all subjects) maps, for each selected seed. We can have a quick look at them. Note that the files have been named using the identification codes in the file files_in.seeds.

In [9]:
file_dmn   = [opt.folder_out filesep 'rmap_seeds' filesep 'average_rmap_DMN.nii.gz'];
file_motor = [opt.folder_out filesep 'rmap_seeds' filesep 'average_rmap_MOTOR.nii.gz'];
[hdr,rmap_dmn]   = niak_read_vol(file_dmn);
[hdr,rmap_motor] = niak_read_vol(file_motor);
size(rmap_dmn)
size(rmap_motor)
ans =

   27   32   26

ans =

   27   32   26

We will now use niak_vol2img to generate a series of axial slices for both maps.

In [10]:
% The default-mode network
opt_v = struct;
opt_v.vol_limits = [0.25 0.7];
opt_v.type_color = 'hot_cold';
niak_montage(rmap_dmn,opt_v)
In [11]:
% The sensorimotor network
opt_v = struct;
opt_v.vol_limits = [0.25 0.7];
opt_v.type_color = 'hot_cold';
niak_montage(rmap_motor,opt_v)

There are also two files which contain the seeds as binary masks. E.g.:

In [12]:
file_mask_dmn   = [opt.folder_out filesep 'rmap_seeds' filesep 'mask_DMN.nii.gz'];
[hdr,mask_dmn]   = niak_read_vol(file_mask_dmn);
opt_v = struct;
opt_v.vol_limits = [0 1];
opt_v.type_color = 'hot_cold';
niak_montage(mask_dmn,opt_v)

Finally, there are also individual connectivity maps for each subject, named using the IDs we used in files_in.fmri. If multiple runs were specified per subject, the pipeline would average the maps from all runs.

In [13]:
file_dmn_40003   = [opt.folder_out filesep 'rmap_seeds' filesep 'rmap_40003_DMN.nii.gz'];
[hdr,rmap_dmn_40003]   = niak_read_vol(file_dmn_40003);
opt_v = struct;
opt_v.vol_limits = [0.4 1];
opt_v.type_color = 'hot_cold';
niak_montage(rmap_dmn_40003,opt_v)

We will now load a connectome, aka an individual matrix of correlation between time series of different parcels.

In [19]:
file_connectome_40003   = [opt.folder_out filesep 'connectomes' filesep 'connectome_rois_40003.mat'];
data = load(file_connectome_40003);

The connectome is stored in a variable called conn. The matrix has been vectorized, keeping only diagonal and lower triangular values. To get back a square matrix we need to run niak_lvec2mat:

In [20]:
size(data.conn)
conn = niak_lvec2mat(data.conn);
size(conn)
ans =

   28    1

ans =

   7   7

We have 7 parcels corresponding to our original brain parcellations. Parcels do not need to be numbered 1, 2, ... etc in the original parcellation volume. The numeric IDs of each parcel are stored in data.ind_roi:

In [22]:
data.ind_roi
ans =

   1
   2
   3
   4
   5
   6
   7

So here parcels were actually numbered 1 to 7. We can visualize the connectivity matrix:

In [23]:
niak_visu_matrix(conn)
ans =  1

Here the connectivity values are Fisher transformation of correlation coefficients between average time series (for the inter-parcel connectivity), and Fisher transformation of average correlation between any pair of disctinct voxels inside the parcel (for intra-parcel connectivity).

Finally note that you can get a list of all files generated by the pipeline easily:

In [24]:
files = niak_grab_connectome(opt.folder_out)
files =

  scalar structure containing the fields:

    network_rois = /sandbox/home/Desktop/workshop_niak/connectome/network_rois.nii.gz
    connectome =

      scalar structure containing the fields:

        40003 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40003.mat
        40008 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40008.mat
        40020 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40020.mat
        40029 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40029.mat
        40037 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40037.mat
        40045 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40045.mat
        40051 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40051.mat
        40059 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40059.mat
        40061 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40061.mat
        40065 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40065.mat
        40077 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40077.mat
        40093 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40093.mat
        40104 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40104.mat
        40113 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40113.mat
        40117 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40117.mat
        40122 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40122.mat
        40129 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40129.mat
        40133 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40133.mat
        40138 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40138.mat
        40145 = /sandbox/home/Desktop/workshop_niak/connectome/connectomes/connectome_rois_40145.mat

    rmap =

      scalar structure containing the fields:

        DMN =

          scalar structure containing the fields:

            40003: 1x79 sq_string
            40008: 1x79 sq_string
            40020: 1x79 sq_string
            40029: 1x79 sq_string
            40037: 1x79 sq_string
            40045: 1x79 sq_string
            40051: 1x79 sq_string
            40059: 1x79 sq_string
            40061: 1x79 sq_string
            40065: 1x79 sq_string
            40077: 1x79 sq_string
            40093: 1x79 sq_string
            40104: 1x79 sq_string
            40113: 1x79 sq_string
            40117: 1x79 sq_string
            40122: 1x79 sq_string
            40129: 1x79 sq_string
            40133: 1x79 sq_string
            40138: 1x79 sq_string
            40145: 1x79 sq_string

        MOTOR =

          scalar structure containing the fields:

            40003: 1x81 sq_string
            40008: 1x81 sq_string
            40020: 1x81 sq_string
            40029: 1x81 sq_string
            40037: 1x81 sq_string
            40045: 1x81 sq_string
            40051: 1x81 sq_string
            40059: 1x81 sq_string
            40061: 1x81 sq_string
            40065: 1x81 sq_string
            40077: 1x81 sq_string
            40093: 1x81 sq_string
            40104: 1x81 sq_string
            40113: 1x81 sq_string
            40117: 1x81 sq_string
            40122: 1x81 sq_string
            40129: 1x81 sq_string
            40133: 1x81 sq_string
            40138: 1x81 sq_string
            40145: 1x81 sq_string


    mask =

      scalar structure containing the fields:

        DMN = /sandbox/home/Desktop/workshop_niak/connectome/rmap_seeds/mask_DMN.nii.gz
        MOTOR = /sandbox/home/Desktop/workshop_niak/connectome/rmap_seeds/mask_MOTOR.nii.gz


Using that tool you can easily move to other toolboxes. Check FSL PALM for non-parametric linear regression tests on the connectivity maps (Matlab/Octave-based), and the brain connectivity toolbox for graph analysis (Matlab/Octave-based).