Home > vbmeg > functions > plotfunc > check_model > vb_check_sphere_slice.m

vb_check_sphere_slice

PURPOSE ^

Check sphere model

SYNOPSIS ^

function vb_check_sphere_slice(brainfile,megfile,analyzefile,Vradius)

DESCRIPTION ^

 Check sphere model

 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    vb_check_sphere_slice(brainfile,megfile,analyzefile,Vradius)
0002 % Check sphere model
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 if ~exist('Vradius','var') || isempty(Vradius)
0008     Vradius = 75; 
0009 else 
0010     Vradius = Vradius*1000; 
0011 end
0012 
0013 %analyzefile = brain_parm.analyze_file;
0014 %brainfile   = [proj_root '/' brain_parm.brain_file];
0015 %megfile     = [proj_root '/' meg_parm.meg_file];
0016 
0017 if ~exist(analyzefile,'file'), 
0018     fprintf('There is no analyze file: %s\n',analyzefile)
0019     fprintf('Check of sphere model is skipped\n')
0020     return
0021 end
0022 
0023 if iscell(megfile), megfile = megfile{1}; end;
0024 
0025 % Load sensor and sphere center position
0026 [pick,Qpick,Wsensor,Vcenter] = vb_load_sensor(megfile);
0027 
0028 % Load brain model
0029 [V] = vb_load_cortex(brainfile, 'subj');
0030 
0031 % Load MRI image
0032 [B, Vdim, Vsize] = vb_load_analyze_to_right(analyzefile);
0033 
0034 % Change coordinate to analyze_right voxcel coordinate
0035 Scenter = vb_spm_right_to_analyze_right(Vcenter(:)',Vdim,Vsize);
0036 Vana    = vb_spm_right_to_analyze_right(V,Vdim,Vsize);
0037 
0038 vdim    = ['x';'y';'z'];
0039 sindx   = round(Scenter);
0040 xyindx  = [ 2 3 ; 1 3; 1 2];
0041 step    = 1;
0042 xymode  = 0;
0043 Msize   = 4;        % marker size
0044 Mtype   = 'y.';        % marker type
0045 
0046 NX = 3; NY = 1;
0047 
0048 T = 1000;
0049 t = (0:T)*(2/T);
0050 x = Vradius*cos(pi*t);
0051 y = Vradius*sin(pi*t);
0052 
0053 figure;
0054 
0055 for n=1:3
0056     subplot(NY,NX,n);
0057     vb_plot_3d_image(B,sindx(n),vdim(n),xymode);
0058     hold on
0059     vb_plot_vertex(Vana, vdim(n), sindx(n), step, Msize, Mtype, xymode);
0060     plot(x/Vsize(n) + Scenter(xyindx(n,1)), y/Vsize(n) + Scenter(xyindx(n,2)), '-r');
0061 end
0062 
0063 subplot(NY,NX,2);
0064 title('Sphere and cortex model on MRI slice')
0065 
0066 %   vb_plot_3d_image(B,indx,vdim,mode,V)
0067 %
0068 % B : 3D-image [NBx, NBy, NBz]. The coordinate system must be RAS.
0069 %     Note that the default of ANALYZE coordinate is LAS.
0070 % indx : slice index in vdim-axis
0071 % vdim : slice cut direction
0072 %      = 'x' : Sagittal cut : Y-Z plane
0073 %      = 'y' : Coronal cut : X-Z plane
0074 %      = 'z' : Transverse (Axial) cut : X-Y plane
0075 % mode : 2D plot mode for X-Y
0076 %      = 0   : plot without transpose
0077 %      = 1   : plot by transposing 2D-image matrix
0078 % V    : Coordinates of points plotted with a slice (optional).
0079 %        The coordinate system of V is RAS.

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