Home > phiwave > phiw_display.m

phiw_display

PURPOSE ^

displays activation image on structural image

SYNOPSIS ^

function phiw_display(action, disp_type, vols, phiw, defyn)

DESCRIPTION ^

 displays activation image on structural image
 FORMAT phiw_display(action, disp_type, vols, phiw, defyn)

 Inputs [default]
 action          - 'display' or 'orthcb' ['display']
 disp_type       - 'orth' orthoviews or 'slices' slice view [GUI]
 vols            - string or struct for either: activation image or
                   structural image followed by activation image [GUI]
 phiw            - struct with various display defaults [PHI.OPTIONS]
 defyn           - flag, if set, use all default display settings [GUI]
 
 The routine is a bit off-message from the point of view of the phiwave
 design philosophy, because it uses the PHI global structure directly to
 get defaults for the display.   It should probably be better considered
 as part of the phiwave.m function, but there we go.

 For example:
 phiw_display('display', 'my_con.img');

 Matthew Brett 10/10/00

 $Id: phiw_display.m,v 1.8 2005/06/21 17:03:47 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function phiw_display(action, disp_type, vols, phiw, defyn)
0002 % displays activation image on structural image
0003 % FORMAT phiw_display(action, disp_type, vols, phiw, defyn)
0004 %
0005 % Inputs [default]
0006 % action          - 'display' or 'orthcb' ['display']
0007 % disp_type       - 'orth' orthoviews or 'slices' slice view [GUI]
0008 % vols            - string or struct for either: activation image or
0009 %                   structural image followed by activation image [GUI]
0010 % phiw            - struct with various display defaults [PHI.OPTIONS]
0011 % defyn           - flag, if set, use all default display settings [GUI]
0012 %
0013 % The routine is a bit off-message from the point of view of the phiwave
0014 % design philosophy, because it uses the PHI global structure directly to
0015 % get defaults for the display.   It should probably be better considered
0016 % as part of the phiwave.m function, but there we go.
0017 %
0018 % For example:
0019 % phiw_display('display', 'my_con.img');
0020 %
0021 % Matthew Brett 10/10/00
0022 %
0023 % $Id: phiw_display.m,v 1.8 2005/06/21 17:03:47 matthewbrett Exp $
0024   
0025 if nargin < 1
0026   action = 'display';
0027 end
0028 if nargin < 2
0029   disp_type = [];
0030 end
0031 if nargin < 3
0032   vols = [];
0033 end
0034 if nargin < 4
0035   phiw = [];
0036 end
0037 if nargin < 5
0038   defyn = [];
0039 end
0040 
0041 phiw_global = spm('getglobal', 'PHI');
0042 phiw = mars_struct('ffillsplit', ...
0043            mars_struct('getifthere', phiw_global, 'OPTIONS'), ...
0044            phiw);
0045 
0046 switch lower(action)
0047 case 'display'
0048 [Finter,Fgraph,CmdLine] = spm('FnUIsetup','Display functional image');
0049 dist_opts = {'slices', 'orth'};
0050   
0051 if isempty(disp_type)
0052   tmp = spm_input('Display image', 1, 'b', ...
0053           'Slices|Sections|Cancel', [1 2 0], 1);
0054   if ~tmp, return, end
0055   disp_type = dist_opts{tmp};
0056 end
0057 
0058 disp_type = lower(disp_type);
0059 if ~ismember(disp_type, dist_opts)
0060   error('Don''t recognize display type');
0061 end
0062 if isempty(vols)
0063   vols = spm_get([0 1], 'img', 'Activation image to display');
0064 end
0065 if isempty(vols), return, end
0066 if ischar(vols), vols = spm_vol(vols);end
0067 if length(vols)>1 % assume 1st image is structural, 2nd functional
0068   actvol = vols(2);
0069   structv = vols(1);
0070 else
0071   actvol = vols;
0072   structv = [];
0073 end
0074 
0075 cmap=[];
0076 if isempty(defyn)
0077   defyn = spm_input('Display type', '+1', 'b', 'Default|Custom', [1 0], 1);
0078 end
0079 if ~defyn
0080   if isempty(structv),
0081     tmp = spm_input('Structural', '+1', 'b', 'Default|Custom', [0 1], 1);
0082     if tmp
0083       simg = spm_get([0 1], 'img', 'Structural for display');
0084       if isempty(simg), return, end
0085       structv = spm_vol(simg);
0086     end
0087   end
0088   if ~isempty(structv)
0089     [mx mn] = slover('volmaxmin', structv);
0090     phiw.structural.range = spm_input('Img range for structural','+1', ...
0091                       'e', [mn mx], 2);
0092   end
0093   tmp = spm_input('Colormap for contrast', '+1', 'b', 'Default|Custom', ...
0094           [0 1], 1);
0095   if tmp
0096     ypos = spm_input('!NextPos');
0097     while isempty(cmap)
0098       [cmap w]= slover('getcmap',...
0099                   spm_input('Activation colormap',ypos,'s', ...
0100                     phiw.display.cmapname));
0101       if isempty(cmap), disp(w);end
0102     end
0103   end
0104   phiw.display.actprop = spm_input('Activation intensity',...
0105               '+1', 'e',phiw.display.actprop);
0106 
0107   if strcmp(disp_type, 'slices')
0108     phiw.display.transform = deblank(spm_input('Image orientation', '+1', ...
0109                      ['Axial|Coronal|Sagittal'], ...
0110                      strvcat('axial','coronal', ...
0111                          'sagittal'),1));
0112     % slices for display
0113     phiw.display.slices = spm_input('Slices to display (mm)', '+1', 'e', ...
0114               sprintf('%0.0f:%0.0f:%0.0f',...
0115                   min(phiw.display.slices),...
0116                   mean(diff(phiw.display.slices)),...
0117                   max(phiw.display.slices)));
0118   end
0119 else % if defyn==1
0120   if ~isempty(structv)
0121     [mx mn] = slover('volmaxmin', structv);
0122     phiw.structural.range = [mn mx];  
0123   end
0124 end
0125 if isempty(structv)
0126   structv = spm_vol(phiw.structural.fname);
0127   if isempty(phiw.structural.range)
0128     [mx mn] = slover('volmaxmin', structv);
0129     phiw.structural.range = [mn mx];  
0130   end    
0131 end
0132 if isempty(cmap)
0133   cmap = slover('getcmap', phiw.display.cmapname);
0134 end
0135 
0136 % Range for cmap
0137 [mx mn] = slover('volmaxmin', actvol);
0138 amx = max(abs([mx mn]));
0139 range = [-amx amx];
0140 promptstr = sprintf('Range for cmap %0.2f:%0.2f',mn,mx); 
0141 finf = 0;
0142 while ~finf
0143   range = spm_input(promptstr,'+1', 'e', range, 2);
0144   finf = diff(range);
0145 end
0146 
0147 switch lower(disp_type)
0148  case 'orth'
0149   global st
0150   spm_image('init', structv.fname);
0151   mars_orthviews('Addtruecolourimage', 1, actvol.fname, cmap, phiw.display.actprop, ...
0152         range(2), range(1));
0153   st.callback = 'phiw_display(''orthcb'');';
0154  case 'slices'
0155   o = slover;
0156   img(1) = struct(...
0157       'type', 'truecolour',...
0158       'prop', phiw.display.actprop,...
0159       'range', range,...
0160       'vol', actvol,...
0161       'cmap', cmap);
0162   img(2) = struct(...
0163       'type', 'truecolour',...
0164       'prop', 1-phiw.display.actprop,...
0165       'range', phiw.structural.range,...
0166       'vol', structv,...
0167       'cmap', gray);
0168   o.img = img;
0169   o.cbar = 1;
0170   o.slices=phiw.display.slices;
0171   o.transform=phiw.display.transform;
0172 
0173   % use SPM figure window, and display
0174   o.figure = spm_figure('GetWin', 'Graphics'); 
0175   o = paint(o);
0176  
0177  otherwise
0178   error('Don''t recognize display type');
0179 end
0180 case 'orthcb'
0181 % callback function from mars_orthviews, gives activation rather than
0182 % structural intensity in text box.  Copied from spm_image.m
0183 global st
0184 if isfield(st,'mp'),
0185   fg = spm_figure('Findwin','Graphics');
0186   if any(findobj(fg) == st.mp),
0187     set(st.mp,'String',sprintf('%.1f %.1f %.1f',mars_orthviews('pos')));
0188     pos = mars_orthviews('pos',1);
0189     set(st.vp,'String',sprintf('%.1f %.1f %.1f',pos));
0190     if isfield(st.vols{1}, 'blobs') & isfield(st.vols{1}.blobs{1}, 'vol')
0191       pos = st.vols{1}.blobs{1}.mat \ st.vols{1}.mat * [pos; 1];
0192       ival = spm_sample_vol(st.vols{1}.blobs{1}.vol,pos(1), pos(2),pos(3),st.hld);
0193     else
0194       ival = spm_sample_vol(st.vols{1},pos(1), pos(2),pos(3),st.hld);
0195     end
0196     set(st.in,'String',sprintf('%g',ival));
0197   else,
0198     st.Callback = ';';
0199     rmfield(st,{'mp','vp','in'});
0200   end;
0201 else,
0202   st.Callback = ';';
0203 end;
0204 
0205 otherwise
0206  error('Can''t recognize action string')
0207 end;
0208 
0209 return

Generated on Wed 06-Jul-2005 18:07:21 by m2html © 2003