clear % Change the path accordingly cd('C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\Atlases_Mikael\warp_atlas') basedir = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\Atlases_Mikael\warp_atlas\'; % parameters p_mb_mu = [basedir 'mu_T1.nii']; % MB atlas p_atlas = [basedir 'Buckner2011_Choi2012_17Networks_MNI152_FreeSurferConformed1mm_LooseMask.nii']; % your atlas p_atlas_mri = [basedir 'colin27_t1_tal_lin.nii']; % the colin T1w atlas is defined in the same space as the AAL atlas % p_atlas_mri = [basedir 'single_subj_T1.nii']; onam = 'BC17_c27'; odir = [basedir 'result']; %% We fit MB to the atlas space T1w image matlabbatch = {}; matlabbatch{1}.spm.tools.mb.run.mu.exist = {p_mb_mu}; matlabbatch{1}.spm.tools.mb.run.aff = 'Aff(3)'; matlabbatch{1}.spm.tools.mb.run.v_settings = [0.001 0 2 0.5 1]; matlabbatch{1}.spm.tools.mb.run.onam = onam; matlabbatch{1}.spm.tools.mb.run.odir = {odir}; matlabbatch{1}.spm.tools.mb.run.cat = {{}}; matlabbatch{1}.spm.tools.mb.run.gmm.chan.images = {p_atlas_mri}; matlabbatch{1}.spm.tools.mb.run.gmm.chan.inu.inu_reg = 10000; matlabbatch{1}.spm.tools.mb.run.gmm.chan.inu.inu_co = 40; matlabbatch{1}.spm.tools.mb.run.gmm.chan.modality = 1; matlabbatch{1}.spm.tools.mb.run.gmm.labels.false = []; matlabbatch{1}.spm.tools.mb.run.gmm.pr.file = {}; matlabbatch{1}.spm.tools.mb.run.gmm.pr.hyperpriors = []; matlabbatch{1}.spm.tools.mb.run.gmm.tol_gmm = 0.0005; matlabbatch{1}.spm.tools.mb.run.gmm.nit_gmm_miss = 32; matlabbatch{1}.spm.tools.mb.run.gmm.nit_gmm = 8; matlabbatch{1}.spm.tools.mb.run.gmm.nit_appear = 4; matlabbatch{1}.spm.tools.mb.run.accel = 0.8; matlabbatch{1}.spm.tools.mb.run.min_dim = 8; matlabbatch{1}.spm.tools.mb.run.tol = 0.001; matlabbatch{1}.spm.tools.mb.run.sampdens = 2; matlabbatch{1}.spm.tools.mb.run.save = true; matlabbatch{1}.spm.tools.mb.run.nworker = 0; spm_jobman('run', matlabbatch); %% We warp the atlas to MB space using the deformation computed above matlabbatch = {}; matlabbatch{1}.spm.util.defs.comp{1}.inv.comp{1}.def = {[basedir 'result\y_1_00001_colin27_t1_tal_lin_' onam '.nii']}; % matlabbatch{1}.spm.util.defs.comp{1}.inv.comp{1}.def = {[basedir 'result\y_1_00001_single_subj_T1_' onam '.nii']}; matlabbatch{1}.spm.util.defs.comp{1}.inv.space = {p_mb_mu}; matlabbatch{1}.spm.util.defs.out{1}.pull.fnames = {p_atlas}; matlabbatch{1}.spm.util.defs.out{1}.pull.savedir.saveusr = {[basedir 'result']}; matlabbatch{1}.spm.util.defs.out{1}.pull.interp = -1; matlabbatch{1}.spm.util.defs.out{1}.pull.mask = 1; matlabbatch{1}.spm.util.defs.out{1}.pull.fwhm = [0 0 0]; matlabbatch{1}.spm.util.defs.out{1}.pull.prefix = 'BC17_c27_'; spm_jobman('run', matlabbatch);