PROJECT VOXEL PERCENT SIGNAL MAP ON THE BRAIN SURFACE MODEL [Notice] con_*.img must be normalized to the standard brain using T1-structural image used for creating a brain file. [Input] brain_file : cortical surface model act_file : act file area_file : area file Tthres : T-value threshold Rthres : radius threshold (mm) SPMimginfo(ii) : arrays of struct containing information of T-image .dirname : directory name for image file .imgfilename : file name of image to be projected .imglabel : label of image to be projected. These label are used as actkey and areakey .baseimgfilename : file name for the baseline image .ncon : the number of positive contrast for each CON image .peak : regressor peak value .spm_ver : spm version [Output] Acts are added to "act_file" and Areas are added to "area_file" Reference : see http://cibsr.stanford.edu/documents/FMRIPercentSignalChange.pdf 2016/07/26 O.Yamashita * 'spm_ver' moves to 'SPMimginfo'. 2016/07/06 O.Yamashita * solve the region expansion problem 2016/07/01 O.Yamashita * first version based on vbdot_fmri_project_Tmap_corext.m Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_fmri_unsn_project_PSmap_cortex(brain_file,act_file,area_file,sn_file,PSthres,Rthres,SPMimginfo) 0002 % PROJECT VOXEL PERCENT SIGNAL MAP ON THE BRAIN SURFACE MODEL 0003 % 0004 % [Notice] 0005 % con_*.img must be normalized to the standard brain using T1-structural image used for creating 0006 % a brain file. 0007 % 0008 % [Input] 0009 % brain_file : cortical surface model 0010 % act_file : act file 0011 % area_file : area file 0012 % Tthres : T-value threshold 0013 % Rthres : radius threshold (mm) 0014 % SPMimginfo(ii) : arrays of struct containing information of T-image 0015 % .dirname : directory name for image file 0016 % .imgfilename : file name of image to be projected 0017 % .imglabel : label of image to be projected. These label 0018 % are used as actkey and areakey 0019 % .baseimgfilename : file name for the baseline image 0020 % .ncon : the number of positive contrast for each CON image 0021 % .peak : regressor peak value 0022 % .spm_ver : spm version 0023 % 0024 % [Output] 0025 % Acts are added to "act_file" and Areas are added to "area_file" 0026 % 0027 % Reference : see http://cibsr.stanford.edu/documents/FMRIPercentSignalChange.pdf 0028 % 0029 % 2016/07/26 O.Yamashita 0030 % * 'spm_ver' moves to 'SPMimginfo'. 0031 % 2016/07/06 O.Yamashita 0032 % * solve the region expansion problem 0033 % 2016/07/01 O.Yamashita 0034 % * first version based on vbdot_fmri_project_Tmap_corext.m 0035 % 0036 % Copyright (C) 2011, ATR All Rights Reserved. 0037 % License : New BSD License(see VBMEG_LICENSE.txt) 0038 0039 0040 spmdir = SPMimginfo(1).dirname; 0041 spm_ver = SPMimginfo(1).spm_ver; 0042 0043 fprintf('Image directory name : %s,...\n', spmdir); 0044 for jj = 1 : length(SPMimginfo), 0045 fprintf('%s will be registered as %s ...\n', SPMimginfo(jj).imgfilename, SPMimginfo(jj).imglabel); 0046 end 0047 0048 % scale factor for con image 0049 0050 for jj = 1 : length(SPMimginfo), 0051 loadimgfile = [spmdir SPMimginfo(jj).imgfilename]; 0052 key = SPMimginfo(jj).imglabel; 0053 0054 baseimgfile = [spmdir SPMimginfo(jj).baseimgfilename]; 0055 [B] = vb_load_analyze_to_right(baseimgfile); 0056 bmean = mean(B(~isnan(B(:)))); 0057 scale = 1./SPMimginfo(jj).ncon/bmean*SPMimginfo(jj).peak*100; 0058 0059 0060 % surface mesh 0061 V = vb_load_cortex(brain_file, 'subj'); 0062 V = V * 1000; % mm 0063 0064 0065 % vox image and coordinates 0066 VG=spm_vol(loadimgfile); 0067 [map,XYZ] = spm_read_vols(VG); 0068 map = map * scale; 0069 0070 % 0071 % thresholding affects resulting surface image !!! 0072 % 0073 0074 % map(abs(map) < PSthres) = NaN; 0075 % ix=find(~isnan(map)); 0076 % XYZ = XYZ(:,ix); 0077 % map = map(ix)'; 0078 ix = find(~isnan(map)); % brain mask 0079 XYZ = XYZ(:,ix); 0080 map = map(ix); 0081 map(abs(map) < PSthres) = 0; % 0082 0083 0084 r2thres = Rthres^2; 0085 0086 % standard brain --> individual brain 0087 XYZmm = backword_transform_normalized_to_subject_native(sn_file, spm_ver, XYZ'); 0088 0089 % vox --> surf 0090 Tval = vb_voximg2surimg(XYZmm,map,V, r2thres, 1); 0091 0092 0093 % add act 0094 fprintf('\nAdd PS-map to %s with act-key %s \n', act_file, key) 0095 act.xxP = Tval; 0096 act.key = key; 0097 act.spmdir = spmdir; 0098 act.imgname = SPMimginfo(jj).imgfilename; 0099 load(act_file, 'MRI_ID'); 0100 vb_add_act(act_file, act, MRI_ID, OFF); 0101 0102 % % add area 0103 % fprintf('Add PS-map to %s with area-key %s \n', area_file, key) 0104 % area.Iextract = find(Tval~=0); 0105 % area.key = key; 0106 % area.spmdir = spmdir; 0107 % area.imgname = SPMimginfo(jj).imgfilename; 0108 % vb_add_area(area_file, area); 0109 0110 0111 end 0112 0113 function XYZmm = backword_transform_normalized_to_subject_native(snfile, spm_ver, XYZmm_mni) 0114 % XYZmm_mni : Nvox*3 0115 0116 switch (lower(spm_ver)) 0117 case 'spm2', 0118 sn = load(snfile); 0119 XYZmm=vb_unsn(XYZmm_mni,sn); 0120 0121 case {'spm5','spm8'}, 0122 XYZmm = spm_get_orig_coord_spm5(XYZmm_mni,snfile); 0123 end;