% study_wrapper.m
%
% Pseudo code to recreate the study (requires MrCat)
%-------------------------------------------------------------------------
%
% version history
% 18072018 Rogier   Created
%
% copyright
% Rogier B. Mars, University of Oxford, 2018
%-------------------------------------------------------------------------

% Create surface_fdt_matrix2 for each subject and average
create_surface_fdt_matrix_take4b.sh
average_fdt_matrix2_take4b.m

% Combine L and R averages to a single LR fdt_matrix2

% Run MIGP and ICA
moriarty2('AVG_Matrix2_LR_15mm_take4_allsubjects.mat','outputbase','chimp_LR_take4_50ICs_allsubjects','nICs',50);

% Look at results, create hard parcellations, and .spec
cfg = [];
cfg.volume_tract_file = '../moriarty_results/chimp_LR_take4b_allsubjects_50ICs_beta_tracks.mat';
cfg.surface_tract_file = '../moriarty_results/chimp_LR_take4b_allsubjects_50ICs_ICApos.mat';
cfg.volume_standard = '/Users/rmars/code/MrCat-dev/data/chimpanzee/Chimplate/ChimpYerkes29_AverageT1w_restore_brain_15mm.nii.gz';
cfg.surface_standard = '/Users/rmars/code/MrCat-dev/data/chimpanzee/Chimplate/fsaverage_LR20k/ChimpYerkes29.L.pial.20k_fs_LR.surf.gii';
cfg.tract_space_coords_for_fdt_matrix2 = '../moriarty_results/tract_space_coords_for_fdt_matrix2';
cfg.outputbase = '../look_at_moriarty_results/chimp_LR_take4b_allsubjects_50ICs';
cfg.hemi = 'LR';
cfg.glassprojection = 'yes';
cfg.volumeinclude = 'pve_2_mask.nii.gz';
look_at_moriarty(cfg);

% GGM
moriarty_ggm('../moriarty_results/chimp_LR_take4b_allsubjects_50ICs_ICApos.mat','../moriarty_results/chimp_LR_take4b_allsubjects_50ICs_beta_tracks.mat','/Users/rmars/code/MrCat-dev/data/chimpanzee/Chimplate/ChimpYerkes29_AverageT1w_restore_brain_15mm.nii.gz','../look_at_moriarty_results/chimp_LR_take4b_allsubjects_50ICs','hemi','LR');
wb_command -add-to-spec-file ../look_at_moriarty_results/chimp_LR_take4b_allsubjects_50ICs_spec.spec CORTEX ../look_at_moriarty_results/chimp_LR_take4b_allsubjects_50ICs_ICAsurfacethresholded.dtseries.nii 

% Post-hoc analyses
analyze_laterality.m