cd
build_path niak psom
cd /home/pbellec/git/niak_tutorials/connectome
Adding library niak to the search path. Adding library psom to the search path.
This tutorial shows how to use the NIAK subtype pipeline to identify subgroups of subjects with homogeneous seed-based functional connectivity maps in the COBRE lightweight20 release, and check if some subtypes are associated with a diagnosis of schizophrenia. See the documentation of the pipeline for a more detailed description of the options. Download the tutorial as a notebook here and a matlab script here. To run this tutorial, we recommend to use jupyter from a niak docker container, as described in the NIAK installation page.
To run that tutorial, you need to complete first the correlation maps tutorial. You also need to run both tutorials in the same folder.
We first load the phenotypic data from the COBRE sample. This command will not work if you haven't downloaded the data yet as part of the rmap tutorial.
path_cobre = [pwd filesep 'cobre_lightweight20'];
file_pheno = [path_cobre filesep 'phenotypic_data.tsv.gz'];
tab = niak_read_csv_cell(file_pheno);
Now we convert the values into a series of numerical covariates, that we save in a separate .csv file:
list_subject = tab(2:end,1);
patient = strcmp(tab(2:end,5),'Patient');
age = str2double(tab(2:end,2));
FD = str2double(tab(2:end,9));
opt_csv.labels_x = list_subject; % Labels for the rows
opt_csv.labels_y = { 'age' , 'patient' , 'fd' };
niak_write_csv('model_patient.csv', [age patient FD] , opt_csv);
We specify to the pipeline where to find the model:
files_in.model = [pwd filesep 'model_patient.csv'];
Now we are going to get a list of the connectivity maps associated with each subject for one network, say the DMN. Labels for each network have been specified when running the connectome
pipeline. We simply grab the outputs of the connectome pipeline.
path_connectome = [pwd filesep 'connectome'];
files_conn = niak_grab_connectome(path_connectome);
files_in.data = files_conn.rmap;
We specify the mask of brain networks to the pipeline, so that it can use it to mask the grey matter.
files_in.mask = files_conn.network_rois;
First specify where to save the outputs, and how many networks to use:
%% General
opt.folder_out = [pwd filesep 'subtype'];
Then specify which covariates to use as confounds before the generation of subtypes.
% a list of variable names to be regressed out
% If unspecified or left empty, no confounds are regressed
opt.stack.regress_conf = {'fd'};
The options for the subtypes themselves:
%% Subtyping
opt.subtype.nb_subtype = 2; % the number of subtypes to extract
opt.subtype.sub_map_type = 'mean'; % the model for the subtype maps (options are 'mean' or 'median')
Now we add an association test between subtypes and the patient label:
% scalar number for the level of acceptable false-discovery rate (FDR) for the t-maps
opt.association.patient.fdr = 0.05;
% turn on/off normalization of covariates in model (true: apply / false: don't apply)
opt.association.patient.normalize_x = false;
% turn on/off normalization of all data (true: apply / false: don't apply)
opt.association.patient.normalize_y = false;
% turn on/off adding a constant covariate to the model
opt.association.patient.flag_intercept = true;
% To test a main effect of a variable
opt.association.patient.contrast.patient = 1; % scalar number for the weight of the variable in the contrast
opt.association.patient.contrast.fd = 0; % scalar number for the weight of the variable in the contrast
opt.association.patient.contrast.age = 0; % scalar number for the weight of the variable in the contrast
% type of data for visulization (options are 'continuous' or 'categorical')
opt.association.patient.type_visu = 'continuous';
It is also possible to add a single chi-square test on the relationship between subtypes and a categorical variable:
% string name of the column in files_in.model on which the contigency table will be based
opt.chi2 = 'patient';
opt.flag_test = false; % Put this flag to true to just generate the pipeline without running it.
pipeline = niak_pipeline_subtype(files_in,opt);
Logs will be stored in /home/pbellec/git/niak_tutorials/connectome/subtype/logs/ Generating dependencies ... Percentage completed : 10 20 30 40 55 65 75 85 100- 0.01 sec Setting up the to-do list ... I found 9 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 29-Nov-2016 22:35:50 29-Nov-2016 22:35:50 Starting the pipeline manager... 29-Nov-2016 22:35:50 Starting the garbage collector... 29-Nov-2016 22:35:50 Starting worker number 1... Pipeline started on 29-Nov-2016 22:35:51 user: pbellec, host: acacia, system: unix ***************************************** 29-Nov-2016 22:35:52 stack_DMN submitted (1 run / 0 fail / 0 done / 8 left) 29-Nov-2016 22:35:52 stack_MOTOR submitted (2 run / 0 fail / 0 done / 7 left) 29-Nov-2016 22:35:53 stack_DMN finished (1 run / 0 fail / 1 done / 7 left) 29-Nov-2016 22:35:53 subtype_DMN submitted (2 run / 0 fail / 1 done / 6 left) 29-Nov-2016 22:35:54 stack_MOTOR finished (1 run / 0 fail / 2 done / 6 left) 29-Nov-2016 22:35:54 subtype_MOTOR submitted (2 run / 0 fail / 2 done / 5 left) 29-Nov-2016 22:35:57 subtype_DMN finished (1 run / 0 fail / 3 done / 5 left) 29-Nov-2016 22:35:57 chi2_network_1 submitted (2 run / 0 fail / 3 done / 4 left) 29-Nov-2016 22:36:00 subtype_MOTOR finished (1 run / 0 fail / 4 done / 4 left) 29-Nov-2016 22:36:00 weight_extraction submitted (2 run / 0 fail / 4 done / 3 left) 29-Nov-2016 22:36:01 chi2_network_1 finished (1 run / 0 fail / 5 done / 3 left) 29-Nov-2016 22:36:01 chi2_network_2 submitted (2 run / 0 fail / 5 done / 2 left) 29-Nov-2016 22:36:02 weight_extraction finished (1 run / 0 fail / 6 done / 2 left) 29-Nov-2016 22:36:02 association_test_patient submitted (2 run / 0 fail / 6 done / 1 left) 29-Nov-2016 22:36:03 chi2_network_2 finished (1 run / 0 fail / 7 done / 1 left) 29-Nov-2016 22:36:04 association_test_patient finished (0 run / 0 fail / 8 done / 1 left) 29-Nov-2016 22:36:04 visu_patient submitted (1 run / 0 fail / 8 done / 0 left) Deamon terminated on 29-Nov-2016 22:36:06 29-Nov-2016 22:36:05 visu_patient finished (0 run / 0 fail / 9 done / 0 left) 29-Nov-2016 22:36:06 Stopping idle worker 1 (not enough jobs left to do). ******************************************* Pipeline terminated on 29-Nov-2016 22:36:06 All jobs have been successfully completed.