Home > vbmeg > functions > fmri > vb_make_fmri_data.m

vb_make_fmri_data

PURPOSE ^

Make fMRI activity data from SPM voxel file.

SYNOPSIS ^

function [fMRINew, AreaNew, SPM] = vb_make_fmri_data(proj_root, fmri_parm)

DESCRIPTION ^

 Make fMRI activity data from SPM voxel file. 
 
 [syntax]
 [fMRINew, AreaNew, SPM] = vb_make_fmri_data(proj_root, fmri_parm)

 [input]
 proj_root: <<string>> Project root directory.
 fmri_parm: <<struct>> Parameters for SPM voxel mapping.
 --- fields of fmri_parm
  brain_file  : <<string>> Cortical surface model file (.brain.mat).
  spm_file    : <<string>> SPM voxel file (.spm.mat). 
  fmri_id     : <<string>> fMRI ID.
  SPM_Radius  : <<float>> Search radius for SPM active points.
  SPM_zstep   : <<float>> Slice step size in z-direction.
  Gauss_radius: <<float>> Half-width of Gaussian filter.
  Gauss_max   : <<float>> Maximum distance for averaging SPM.
 ---
 
 [output]
 fMRINew: <<struct>> fMRI activity information. 
 --- fields of fMRINew
  xxP: <<vector>> fMRI activity. 
  key: <<string>> ID of this data for retrieval. 
 ---

 AreaNew: <<struct>> Activated area information based on fMRI. 
 --- fields of AreaNew
  Iextract: <<vector>> Index of area. 
  key     : <<string>> ID of the area created. 
 ---

 [history]
 Originaly written by S.Kajihara
 Ver 1.1  modified by M. Sato  2003-4-15

 2005-03-20 Modified by TY
 Ver 0.20  modified by M. Sato  2005-4-8
 Coordinate system is changed SPM right-handed coordinate.
 2005-09-06 O.Y Ver 0.30b
 An area information is also created.
 2008-05-28 rhayashi  removed Gauss_step parameter
 2008-11-10 Taku Yoshioka
  Struct 'SPM' is returned. 
 2010-06-25 Taku Yoshioka
  RAS coordinate system is assumed for SPM voxel file, but this function
  maintains backward compatibility with old version of SPM voxel
  file. See line 85-93. 
  Verbose level support. 
 2016-5-31 M Sato
  cortex mapping is done according to MNI or SPM coordinate

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [fMRINew, AreaNew, SPM] = vb_make_fmri_data(proj_root, fmri_parm)
0002 % Make fMRI activity data from SPM voxel file.
0003 %
0004 % [syntax]
0005 % [fMRINew, AreaNew, SPM] = vb_make_fmri_data(proj_root, fmri_parm)
0006 %
0007 % [input]
0008 % proj_root: <<string>> Project root directory.
0009 % fmri_parm: <<struct>> Parameters for SPM voxel mapping.
0010 % --- fields of fmri_parm
0011 %  brain_file  : <<string>> Cortical surface model file (.brain.mat).
0012 %  spm_file    : <<string>> SPM voxel file (.spm.mat).
0013 %  fmri_id     : <<string>> fMRI ID.
0014 %  SPM_Radius  : <<float>> Search radius for SPM active points.
0015 %  SPM_zstep   : <<float>> Slice step size in z-direction.
0016 %  Gauss_radius: <<float>> Half-width of Gaussian filter.
0017 %  Gauss_max   : <<float>> Maximum distance for averaging SPM.
0018 % ---
0019 %
0020 % [output]
0021 % fMRINew: <<struct>> fMRI activity information.
0022 % --- fields of fMRINew
0023 %  xxP: <<vector>> fMRI activity.
0024 %  key: <<string>> ID of this data for retrieval.
0025 % ---
0026 %
0027 % AreaNew: <<struct>> Activated area information based on fMRI.
0028 % --- fields of AreaNew
0029 %  Iextract: <<vector>> Index of area.
0030 %  key     : <<string>> ID of the area created.
0031 % ---
0032 %
0033 % [history]
0034 % Originaly written by S.Kajihara
0035 % Ver 1.1  modified by M. Sato  2003-4-15
0036 %
0037 % 2005-03-20 Modified by TY
0038 % Ver 0.20  modified by M. Sato  2005-4-8
0039 % Coordinate system is changed SPM right-handed coordinate.
0040 % 2005-09-06 O.Y Ver 0.30b
0041 % An area information is also created.
0042 % 2008-05-28 rhayashi  removed Gauss_step parameter
0043 % 2008-11-10 Taku Yoshioka
0044 %  Struct 'SPM' is returned.
0045 % 2010-06-25 Taku Yoshioka
0046 %  RAS coordinate system is assumed for SPM voxel file, but this function
0047 %  maintains backward compatibility with old version of SPM voxel
0048 %  file. See line 85-93.
0049 %  Verbose level support.
0050 % 2016-5-31 M Sato
0051 %  cortex mapping is done according to MNI or SPM coordinate
0052 %
0053 % Copyright (C) 2011, ATR All Rights Reserved.
0054 % License : New BSD License(see VBMEG_LICENSE.txt)
0055 
0056 %
0057 % VBMEG constants and cortical model file
0058 %
0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0060 coord_const = vb_define_coordinate;
0061 
0062 if isempty(proj_root)
0063     brain_file = [fmri_parm.brain_file];
0064 else
0065     brain_file = [proj_root filesep fmri_parm.brain_file];
0066 end
0067 %
0068 % Parameters about fMRI
0069 %
0070 % A vertex point of cortical surface V(n) is chosen as an activity when
0071 % it is located inside the sphere of radius 'SPM_Radius' with the center
0072 % V(n).
0073 %
0074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0075 
0076 vb_disp(sprintf('SPM_Radius  : %g',fmri_parm.SPM_Radius));
0077 vb_disp(sprintf('SPM_zstep   : %g',fmri_parm.SPM_zstep));
0078 
0079 % Gauss filter parameter to average SPM t-value
0080 vb_disp(sprintf('Gauss_radius: %g',fmri_parm.Gauss_radius));
0081 vb_disp(sprintf('Gauss_max   : %g',fmri_parm.Gauss_max));
0082 
0083 %
0084 % Load data
0085 %
0086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0087 %load([brain_file],'V'); % Vertex in SPM coordinate [m]
0088 %if isfield(fmri_parm,'MNI') && fmri_parm.MNI == ON
0089 %    V = vb_load_cortex(brain_file,'MNI');
0090 %else
0091 %    V = vb_load_cortex(brain_file);
0092 %end
0093 
0094 load([fmri_parm.spm_file]); % SPM data
0095 vb_disp(['--- Load SPM voxel data: ' fmri_parm.spm_file]);
0096 
0097 spmx = SPM.XYZmm'; % SPM point coordinate [x, y, z] (mm)
0098 spmz = SPM.Z;      % t (z) -value
0099 
0100 
0101 %  check MNI or SPM coordinate
0102 if isfield(SPM,'coord_type') 
0103     if strcmp(SPM.coord_type, coord_const.COORDINATE_MNI_RIGHT_MM)
0104         %  load MNI coordinate
0105         V = vb_load_cortex(brain_file,'MNI');
0106     elseif strcmp(SPM.coord_type, coord_const.COORDINATE_SPM_RIGHT_MM)
0107         %  load SPM coordinate
0108         V = vb_load_cortex(brain_file);
0109     else
0110         error('SPM.coord_type is not correct')
0111     end
0112 else
0113     error('SPM.coord_type is not set')
0114 end
0115 %
0116 % Flip left-right (X-axis) in SPM coordinate for old SPM voxel file
0117 % Left-hand to Right-hand  coordinate
0118 %
0119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0120 %if (~isfield(SPM,'vbmeg_RAS') | ~SPM.vbmeg_RAS) ...
0121 %      & (~isfield(SPM,'coord_type') ...
0122 %      | ~strcmp(SPM.coord_type,coord_const.COORDINATE_SPM_RIGHT_MM)),
0123 %  spmx(:,1) = -spmx(:,1);
0124 %end;
0125 
0126 clear pack;
0127 %
0128 % Select the dipoles around the active area in fMRI
0129 %
0130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0131 tic;
0132 vb_disp('--- Select dipoles ');
0133 
0134 % Search active vertex in 3D-sphere with Rmax [mm]
0135 [xxix ,xxP3] = vb_spm_to_cortex(spmx, spmz, V*1000, fmri_parm);
0136 
0137 spm_parm.SPM_Radius   = fmri_parm.SPM_Radius;
0138 spm_parm.SPM_zstep    = fmri_parm.SPM_zstep;
0139 spm_parm.Gauss_radius = fmri_parm.Gauss_radius;
0140 spm_parm.Gauss_max    = fmri_parm.Gauss_max;
0141 
0142 % xxix : active dipole index
0143 % xxP3 : fMRI activity
0144 % Act information
0145 tmp             = zeros(size(V,1),1);
0146 tmp(xxix)       = xxP3;
0147 fMRINew.xxP     = tmp;
0148 fMRINew.key     = fmri_parm.fmri_id;
0149 fMRINew.comment = spm_parm;
0150 
0151 % Area information
0152 AreaNew.Iextract = xxix;
0153 AreaNew.key = fmri_parm.area_id;
0154 
0155 vb_disp(sprintf('%f[sec]',toc));
0156   
0157 clear spmx3 spmx spmz;
0158 
0159 return;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005