Home > bioelectromagnetism > mri_toolbox.m

mri_toolbox

PURPOSE ^

mri_toolbox - Graphical user interface (GUI) to various MRI tools

SYNOPSIS ^

function [ varargout ] = mri_toolbox(command)

DESCRIPTION ^

 mri_toolbox - Graphical user interface (GUI) to various MRI tools
 
 The main gui is the primary store for general parameters 
 and provides access to other tools.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ varargout ] = mri_toolbox(command)
0002 
0003 % mri_toolbox - Graphical user interface (GUI) to various MRI tools
0004 %
0005 % The main gui is the primary store for general parameters
0006 % and provides access to other tools.
0007 %
0008 
0009 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0010 
0011 % Licence:  GNU GPL, no express or implied warranties
0012 % History:  07/2003, Darren.Weber_at_radiology.ucsf.edu
0013 %                    adapted from eeg_toolbox
0014 %
0015 % Depends:  various tools in the mri_toolbox
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 if ~exist('command','var'),
0019     command = 'init';
0020 elseif isempty(command),
0021     command = 'init';
0022 end
0023 
0024 command = lower(command);
0025 
0026 % first establish GUI or get userdata
0027 switch command,
0028 case 'init',
0029     MRITOOLBOX = init;    
0030 otherwise,
0031     MRITOOLBOX = get(gcbf,'Userdata');
0032 end
0033 
0034 
0035 % now run commands, if required
0036 switch command,
0037 case 'init',
0038     % taken care of above
0039     
0040 case 'openavw',
0041     gui_avw_open(MRITOOLBOX.mri,'init',MRITOOLBOX.gui);
0042     
0043 case 'opencor',
0044     gui_cor_open(MRITOOLBOX.mri,'init',MRITOOLBOX.gui);
0045     
0046 case 'openge',
0047     gui_ge_open(MRITOOLBOX.mri,'init',MRITOOLBOX.gui);
0048     
0049 case 'defaultreturn',
0050     % keep this command so the return action is tidy
0051     %mri = MRITOOLBOX.mri; % done below just before return
0052     
0053 case 'defaultreset',
0054     MRITOOLBOX.mri = mri_toolbox_defaults('create');
0055     
0056 case 'defaultsave',
0057     mri_toolbox_defaults('write',MRITOOLBOX.mri);
0058     
0059 case 'saveas',
0060     mri_toolbox_defaults('write_other',MRITOOLBOX.mri);
0061     
0062 case 'recent',
0063     
0064     % -- get recent files list
0065     
0066     recentfiles = mri_toolbox_recent;
0067     
0068     % -- remove current menu items for recent files
0069     
0070     if isfield(MRITOOLBOX.menu,'recentfiles'),
0071         handleIndex = find(ishandle(MRITOOLBOX.menu.recentfiles));
0072         delete(MRITOOLBOX.menu.recentfiles(handleIndex));
0073     end
0074     MRITOOLBOX.menu.recentfiles = [];
0075     
0076     % -- recreate recent files menu items
0077     
0078     if and(size(recentfiles,2) == 1, isempty(recentfiles{1})),
0079         if ishandle(MRITOOLBOX.menu.recent),
0080             set(MRITOOLBOX.menu.recent,'Label','No Recent Files');
0081         end
0082     else
0083         if ishandle(MRITOOLBOX.menu.recent),
0084             set(MRITOOLBOX.menu.recent,'Label','Recent Files');
0085         end
0086         
0087         % -- add recent files to menu and setup their callbacks
0088         
0089         for i=1:length(recentfiles),
0090             if ~isempty(recentfiles{i}),
0091                 MRITOOLBOX.menu.recentfiles(i) = uimenu(MRITOOLBOX.menu.recent,...
0092                     'Label',recentfiles{i},...
0093                     'Callback',strcat('[recentfiles,mri] = mri_toolbox_recent(''',...
0094                     recentfiles{i},''',''load''); ',...
0095                     'MRITOOLBOX = get(gcbf,''Userdata''); ',...
0096                     'gui_mri_open(mri,''init'',MRITOOLBOX.gui); ',...
0097                     'clear MRITOOLBOX recentfiles;'));
0098             end
0099         end
0100         
0101         % -- add recent files clear command
0102         
0103         MRITOOLBOX.menu.recentfiles(i+1) = uimenu(MRITOOLBOX.menu.recent,...
0104             'Label','Clear All',...
0105             'Callback',strcat('mri_toolbox_recent('''',''clear''); ',...
0106             'mri_toolbox(''recent''); '));
0107     end
0108     
0109 case 'exit',
0110     close gcbf;
0111     
0112 otherwise,
0113     fprintf('...invalid command to mri_toolbox\n\n');
0114     
0115 end
0116 
0117 
0118 switch command,
0119 case 'exit',
0120 otherwise,
0121     set(MRITOOLBOX.gui,'UserData',MRITOOLBOX);
0122 end
0123 
0124 if nargout > 0,
0125     if isfield(MRITOOLBOX,'mri'),
0126         if ~isempty(MRITOOLBOX.mri),
0127             varargout{1} = MRITOOLBOX.mri;
0128         end
0129     end
0130 end
0131 
0132 
0133 return
0134 
0135 
0136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0137 % Paint the GUI
0138 function [H] = init()
0139 
0140 % Parameters are supplied in the file defaultfile.
0141 H.mri = mri_toolbox_defaults('read');
0142 
0143 GUIwidth  = 250;
0144 GUIheight = 50;
0145 
0146 H.gui = figure('Name','MRI Toolbox','Tag','MRI_TOOLBOX',...
0147     'NumberTitle','off','HandleVisibility','callback',...
0148     'MenuBar','none');
0149 set(H.gui,'Position',[1 1 GUIwidth GUIheight]);  % Activate GUI Figure
0150 movegui(H.gui, 'center');
0151 
0152 % -- file menu
0153 
0154 H.menu.file_menu = uimenu(H.gui,'Label','File',...
0155     'Callback','mri_toolbox(''recent'');');
0156 
0157 if exist('avw_read.m') == 2,
0158     H.menu.open_mri = uimenu(H.menu.file_menu,'Label','Open Analyze 7.5',...
0159         'Callback','mri = mri_toolbox(''openAVW'');','Accelerator','a');
0160 end
0161 
0162 if exist('cor_img_read.m') == 2,
0163     H.menu.open_mri = uimenu(H.menu.file_menu,'Label','Open FreeSurfer COR',...
0164         'Callback','mri = mri_toolbox(''openCOR'');','Accelerator','f');
0165 end
0166 
0167 if exist('ge_series_read.m') == 2,
0168     H.menu.open_mri = uimenu(H.menu.file_menu,'Label','Open GE Signa 5.x/LX',...
0169         'Callback','mri = mri_toolbox(''openGE'');','Accelerator','g');
0170 end
0171 
0172 H.menu.recent = uimenu(H.menu.file_menu,'Label','Recent');
0173 H.menu.quit   = uimenu(H.menu.file_menu,'Label','Exit',...
0174     'Callback','mri_toolbox(''exit'');','Accelerator','x');
0175 
0176 % -- Parameters menu
0177 
0178 H.menu.p_menu = uimenu(H.gui,'Label','Parameters');
0179 H.menu.show   = uimenu(H.menu.p_menu,'Label','Return to Workspace',...
0180     'Callback','mri = mri_toolbox(''defaultreturn'')');
0181 H.menu.reset  = uimenu(H.menu.p_menu,'Label','Reset to Defaults',...
0182     'Callback','mri = mri_toolbox(''defaultreset'');');
0183 H.menu.save   = uimenu(H.menu.p_menu,'Label','Save Defaults',...
0184     'Callback','mri = mri_toolbox(''defaultsave'');');
0185 H.menu.saveas = uimenu(H.menu.p_menu,'Label','Save As Data Workspace',...
0186     'Callback','mri = mri_toolbox(''saveas'');');
0187 
0188 % -- help menu
0189 
0190 H.menu.help = uimenu(H.gui,'Label','Help','Callback','doc mri_toolbox;');
0191 
0192 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003