⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rri_getsubject_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 3 页
字号:
%RRI_GETSUBJECT_UI Get subject directory based on conditions
%
%   Usage: [selected_dir, subj_files_row, img_ext] = ...
%	rri_getsubject_ui(condition, selected_conditions, ...
%		old_dir, subj_files_row_old, subj_files, num_subj_init, img_ext)
%
%   RRI_GETSUBJECT_UI(condition, selected_conditions, old_dir) returns
%   a selected directory, with a subject-image vector containing all
%   the filtered images in that directory, and a condtion-image
%   vector containing the images corresponding to the selected
%   conditions.
%
%   See also RRI_GETDIRECTORY
%

%   Called by rri_input_subject_ui
%
%   I (condition) - A cell array containing all the conditions.
%   I (selected_conditions) - <obsolete>
%   I (old_dir) - Starting directory name. If none, use current directory.
%   I (subj_files_row_old) - subj file name returned by this function.
%   I (subj_files) - subj_files field in session file.
%   I (num_subj_init) - Number of characters for subject initial
%   I (img_ext) - filter (img file extension)
%   O (selected_dir) - full directory spec name that user selected.
%   O (subj_files_row) - A cell array containing all the filtered images.
%   O (img_ext) - filter (img file extension)
%
%   Created on 23-SEP-2002 by Jimmy Shen
%   Modified feb,03 to allow muliple choose & case insensitive
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [selected_dir, subj_files_row, filter] = rri_getsubject_ui(varargin)

    if nargin == 0 | ~ischar(varargin{1})		% if not action
        condition = [];
        selected_conditions = [];
        old_dir = pwd;
        if isempty(old_dir)
            old_dir = filesep;
        end;

        if(nargin > 1)
            condition = varargin{1};
            selected_conditions = varargin{2};

            if(nargin > 2), old_dir = varargin{3}; end;
            if(nargin > 3), subj_files_row_old = varargin{4}; end;
            if(nargin > 4), subj_files = varargin{5}; end;
            if(nargin > 5), num_subj_init = varargin{6}; end;
            if(nargin > 6), filter = varargin{7}; end
        else
            error('Check input arguments');
        end

        init(condition, selected_conditions, old_dir, ...
		subj_files_row_old, subj_files, num_subj_init, filter);

        uiwait;						% wait for user finish

        selected_dir = getappdata(gcf, 'selected_dir');
        subj_files_row = getappdata(gcf,'subj_files_row');
        filter = getappdata(gcf,'imgfile_filter');

        cd (getappdata(gcf,'StartDirectory'));		% go back to start dir
        close(gcf);
        return;
    end

    h = findobj(gcf,'Tag','MessageLine');
    set(h,'String','');					% clear the message line,

    action = varargin{1};

    if strcmp(action,'move_slider'),
        MoveSlider;
    elseif strcmp(action,'update_directorylist'),
        UpdateDirectoryList;
    elseif strcmp(action,'update_imagefilter'),
        UpdateImageFilter;
    elseif strcmp(action,'update_selecteddir'),
        UpdateSelectedDir;
    elseif strcmp(action,'select_imagefile'),
	select_imagefile
    elseif strcmp(action,'done_button_pressed'),
        DoneButtonPressed;
    elseif strcmp(action,'cancel_button_pressed'),
        setappdata(gcf, 'selected_dir',[]);
        uiresume;
    elseif strcmp(action,'delete_fig')
        delete_fig;
    end;

    return;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%   Init: Initialize the GUI layout
%
%   I (condition) - A cell array containing all the conditions.
%   I (selected_conditions) - <obsolete>
%   I (old_dir) - Starting directory name. If none, use current directory.
%   I (subj_files_row_old) - Old subj_files_row that was saved before.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function init(condition, selected_conditions, old_dir, ...
		subj_files_row_old, subj_files, num_subj_init, filter)

    StartDirectory = pwd;				% save start dir
    if isempty(StartDirectory),
        StartDirectory = filesep;
    end;

    save_setting_status = 'on';
    getsubject_pos = [];

    try
       load('pls_profile');
    catch
    end

    if ~isempty(getsubject_pos) & strcmp(save_setting_status,'on')

       pos = getsubject_pos;

    else

       w = 0.8;
       h = 0.7;
       x = (1-w)/2;
       y = (1-h)/2;

       pos = [x y w h];

    end

    h0 = figure('Color',[0.8 0.8 0.8], ...
   	'Units','normal', ...
        'Name','Subject Directory Detail', ...
        'MenuBar','none', ...
        'NumberTitle','off', ...
        'interruptible', 'off', ...
        'busyaction', 'cancel', ...
        'deletefcn','rri_getsubject_ui(''delete_fig'');', ...
   	'Position',pos, ...
        'WindowStyle', 'modal', ...
   	'Tag','figGetSubject', ...
   	'ToolBar','none');

    x = 0.01;
    y = 0;
    w = 1;
    h = 0.06;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% Message Line Label
        'Style','text', ...
        'Units','normal', ...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0.8 0.0 0.0], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
        'HorizontalAlignment','left', ...
        'Position',pos, ...
        'String','', ...
        'Tag','MessageLine');

    x = 0.05;
    y = 0.88;
    w = 0.25;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% directories label
	'Units','normal', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','Directory', ...
	'Style','text', ...
	'Tag','lblDirs');

    y = 0.25;
    h = 0.63;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% directories listbox
	'Units','normal', ...
   	'FontUnits','normal', ...
   	'FontSize',0.048, ...
	'Position',pos, ...
	'String','', ...
	'Style','listbox', ...
        'Callback','rri_getsubject_ui(''update_directorylist'');', ...
	'Tag','listDirs', ...
        'max',1, ...
        'User',1, ...
	'Value',1);

    y = 0.16;
    h = 0.06;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% selected dir label
	'Units','normal', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','Selected Directory', ...
	'Style','text', ...
	'Tag','lblSelectedDir');

    y = 0.1;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% selected dir edit
	'Units','normal', ...
	'BackgroundColor',[1 1 1], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','', ...
	'Style','edit', ...
        'Callback','rri_getsubject_ui(''update_selecteddir'');', ...
	'Tag','editSelectedDir');

    x = 0.32;
    y = 0.16;
    w = 0.2;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% subject filter label
	'Units','normal', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','Subject File Filter', ...
	'Style','text', ...
	'Tag','lblImageFilter');


    x = 0.6;
    w = 0.35;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% subj name consistency check
	'Units','normal', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','File names are the same across subjects', ...
	'Style','check', ...
	'value', 1, ...
	'enable','on', ...
	'Tag','chkSubjConsistency');


    x = 0.32;
    y = 0.1;
    w = 0.2;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% subject filter edit
	'Units','normal', ...
	'BackgroundColor',[1 1 1], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String',filter, ...
	'Style','edit', ...
        'Callback','rri_getsubject_ui(''update_imagefilter'');', ...
	'Tag','editImageFilter');

    x = 0.6;
    y = y-0.02;
    w = 0.15;
    h = 0.07;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% DONE
	'Units','normal', ...
   	'FontUnits','normal', ...
   	'FontSize',0.4, ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','DONE', ...
        'Callback','rri_getsubject_ui(''done_button_pressed'');', ...
	'Tag','DONEButton');

    x = 0.8;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% CANCEL
	'Units','normal', ...
   	'FontUnits','normal', ...
   	'FontSize',0.4, ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','CANCEL', ...
        'Callback','rri_getsubject_ui(''cancel_button_pressed'');', ...
	'Tag','CANCELButton');

    x = 0.35;
    y = 0.88;
    w = 0.4;
    h = 0.06;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% selected condition label
	'Units','normal', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','center', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','   Inputed Conditions', ...
	'Style','text', ...
	'Tag','lblCondition');

    x = x+w;
    y = 0.88;
    w = 0.18;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% filtered file label
	'Units','normal', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','center', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','Subject Files', ...
	'Style','text', ...
	'Tag','lblFilteredFile');

    x = 0.32;
    y = 0.25;
    w = 0.63;
    h = 0.63;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% selected condition frame
	'Units','normal', ...
	'BackgroundColor',[0.9 0.9 0.9], ...
	'Position',pos, ...
	'Style','frame', ...
	'Tag', 'frameCondition');

    x = 0.917;
    w = 0.03;

    pos = [x y w h];

    h1 = uicontrol('Parent',h0, ...		% v scroll bar
	'Style', 'slider', ...
   	'Units','normal', ...
   	'Min',1, ...
   	'Max',20, ...
   	'Value',20, ...
   	'Position',pos, ...
	'Enable','Off', ...
   	'Callback','rri_getsubject_ui(''move_slider'');', ...
   	'Tag','sliderCondition');

    x = 0.33;
    y = 0.81;
    w = 0.04;
    h = 0.06;

    pos = [x y w h];

    c_h1 = uicontrol('Parent',h0, ...		% selected condition idx
   	'Style','text', ...
   	'Units','normal', ...
	'BackgroundColor',[0.9 0.9 0.9], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
   	'HorizontalAlignment','right', ...
   	'Position',pos, ...
   	'String','', ...
	'Visible','On', ...
   	'Tag','idxCondition');

    x = x+w+0.01;
    w = 0.33;

    pos = [x y w h];

    c_h2 = uicontrol('Parent',h0, ...		% selected condition name
	'Units','normal', ...
	'BackgroundColor',[0.9 0.9 0.9], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String','', ...
	'Style','edit', ...
	'Enable','Inactive', ...
	'Tag','nameCondition');

    x = x+w;
    w = 0.02;

    pos = [x y w h];

    c_h3 = uicontrol('Parent',h0, ...		% colon label
	'Units','normal', ...
	'BackgroundColor',[0.9 0.9 0.9], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String',':', ...
	'Style','text', ...
	'Tag','lblColon');

    x = x+w;
    w = 0.17;

    pos = [x y w h];

    c_h4 = uicontrol('Parent',h0, ...		% filtered file name combo box
	'Units','normal', ...
	'BackgroundColor',[1 1 1], ...
   	'FontUnits','normal', ...
   	'FontSize',0.5, ...
	'ListboxTop',0, ...
	'Position',pos, ...
	'String',' ', ...
	'Style','push', ...
	'horizon','left', ...
	'Tag','cboImageFile', ...
	'Value', 1);
%	'Style','popupmenu', ...

    if num_subj_init == -1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -