Home > vbmeg > functions > gui > preAnalysis > sbi_meg > pa_sbi_meg_util.m

pa_sbi_meg_util

PURPOSE ^

This function is subcontracting function of sbi_meg GUI.

SYNOPSIS ^

function pa_sbi_meg_util(fig, command)

DESCRIPTION ^

 This function is subcontracting function of sbi_meg GUI.
 [USAGE]
    pa_sbi_meg_util(<fig>, <command>)
 [IN]
        fig : figure handle of leadfield gui.
    command : utility type
 [OUT]
    none

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pa_sbi_meg_util(fig, command)
0002 % This function is subcontracting function of sbi_meg GUI.
0003 % [USAGE]
0004 %    pa_sbi_meg_util(<fig>, <command>)
0005 % [IN]
0006 %        fig : figure handle of leadfield gui.
0007 %    command : utility type
0008 % [OUT]
0009 %    none
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
0016 %
0017 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0018     error('invalid figure was specified.');
0019 end
0020 if ~exist('command', 'var') || isempty(command)
0021     error('invalid command was specified.');
0022 end
0023 
0024 %
0025 % --- Main Procedure
0026 %
0027 % load data(@see pa_sbi_meg_create)
0028 data = guidata(fig);
0029 
0030 switch(command)
0031     case 'update_output_fname'
0032         update_output_fname(data.H);
0033     case 'update_exec_push_status'
0034         update_exec_push_status(data.H);
0035     case 'exec_meg'
0036         exec_meg(data);
0037     case 'reset_parameter'
0038         reset_parameter(data.H);
0039 end
0040 
0041 % save data
0042 guidata(fig, data);
0043 
0044 function update_output_fname(H)
0045 % This function makes output filename and sets filename to GUI.
0046 % [IN]
0047 %    H : GUI component handles
0048 % [OUT]
0049 %    none
0050     global vbmeg_inst;
0051     define = vbmeg_inst.const;
0052 
0053     fname = get(H.sbi_file_edit, 'String');
0054 %    [path, name, ext] = fileparts(fname);
0055     [fpath, fname, fext] = vb_get_file_parts(fname);
0056 
0057     keyword = get(H.keyword_edit, 'String');
0058     if length(keyword) ~= 0
0059         sep = '_';
0060     else
0061         sep = [];
0062     end
0063 
0064 
0065     % save directory
0066     save_dir = get(H.save_dir_edit, 'String');
0067 
0068     % save_dir/sbi_filename.meg.mat
0069     megmatfname = [save_dir filesep fname, sep, keyword, define.MEG2_EXTENSION];
0070     
0071     set(H.megmat_file_edit, 'String', megmatfname);
0072     update_exec_push_status(H);
0073 
0074 function update_exec_push_status(H)
0075 % This function changes Exec button status.(clickable or not)
0076 % [IN]
0077 %    H : GUI component handles
0078 % [OUT]
0079 %    none
0080 
0081     if ~isempty(get(H.sbi_file_edit, 'String')) & ...
0082        ~isempty(get(H.Dicom_file_edit, 'String')) & ...
0083        ~isempty(get(H.megmat_file_edit, 'String'))
0084         set(H.meg_exec_push, 'Enable', 'on');
0085     else
0086         set(H.meg_exec_push, 'Enable', 'off');
0087     end
0088 
0089 function exec_meg(data)
0090 % This function execute vb_job_meg with set parameter.
0091 % [IN]
0092 %    H : GUI component handles
0093 % [OUT]
0094 %    H : GUI component handles
0095 
0096     H = data.H; % component handles
0097     %%%%%%%%%%%%%%%%%%%%
0098     % Parameter setting
0099     %%%%%%%%%%%%%%%%%%%%
0100 
0101     % project root directory
0102     proj_root = get(H.prjroot_edit, 'String');
0103 
0104     % advanced parameters are set here.
0105     meg_parm = data.sbi_meg_parm;
0106 
0107     % SBI file
0108     meg_parm.sbi_file = get(H.sbi_file_edit, 'String');
0109 
0110     % device
0111     meg_parm.device   = 'SBI';
0112 
0113     % DICOM file
0114     dicom_str = get(H.Dicom_file_edit, 'String');
0115 %    [path, name, ext] = fileparts(dicom_str);
0116     [fpath, fname, fext] = vb_get_file_parts(dicom_str);
0117     meg_parm.dicom_dir  = [fpath filesep];
0118     meg_parm.dicom_file = [fname fext];
0119     
0120     % Analyze file
0121     meg_parm.analyze_file = get(H.analyze_edit, 'String');
0122     
0123     % MEG-MAT file(output)
0124     meg_parm.meg_file = get(H.megmat_file_edit, 'String');
0125 
0126     % keyword
0127     meg_parm.keyword = get(H.keyword_edit, 'String');
0128 
0129     % comment
0130     meg_parm.comment = get(H.comment_edit, 'String');
0131 
0132     %%%%%%%%%%%%%%%%%%%%
0133     % execute job
0134     %%%%%%%%%%%%%%%%%%%%
0135     str = get(H.meg_exec_push, 'String');
0136     set(H.meg_exec_push, 'String', 'Processing...');
0137     pause(0.01); % for update button string
0138 
0139     vb_job_meg(proj_root, meg_parm);
0140 
0141     set(H.meg_exec_push, 'String', str);
0142 
0143 function reset_parameter(H)
0144 % This function resets brain GUI.
0145 % [IN]
0146 %    H : GUI component handles
0147 % [OUT]
0148 %    none
0149 
0150     set(H.analyze_edit, 'String', '');
0151     set(H.sbi_file_edit, 'String', '');
0152     set(H.Dicom_file_edit, 'String', '');
0153     set(H.keyword_edit, 'String', '');
0154     set(H.comment_edit, 'String', '');
0155     set(H.save_dir_edit, 'String', '');
0156     set(H.megmat_file_edit, 'String', '');

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