Unverified Commit d8238ba6 authored by Christian Arthur's avatar Christian Arthur Committed by GitHub
Browse files

App Settings GUI (#41)

* Updated DesignNotes.ppt

* Update 1
Added Zoom and Pan functionality to axesSDG (probe display) on the MainGUI with additional buttons in the GUI

* Update 1.1
Minor Zoom adjustments

* Update 1
- Revert Clear Axes update to fix probe plot refresh issue (causing other errors)
- Adjusted units to appear for subject and group data

* Mini Fix
- DisplayAxesSDG.m file sync

* Condition - Unit Problem Fix
- Fix mistake on relating ppf with conditions

* Initial Commit
- Added configSettingGUI.m
- Adjusted AppSettings.cfg and ConfigFileClass.m to accommodate parameters

* Adjusted AppSettings.cfg
- Deleted the "Last Checked for Updates" section to reflect the changes in the master branch

* Homer Integration and Minor Adjustments
- Integrated the configSettingsGUI.m to Homer3 as a menu under Settings
- Disable toolbar and menu bar interaction for configSettingsGUI
- Added missing(?) downsampling and segment tool for SNIRF files

* App Settings Change
- Change Data Storage Scheme to files

* Minor Adjustments
- Added newline to the end of MainGUI.m

* Minor Adjustments
- Added newline to the end of configSettingsGUI.m
parent 641e274c
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line

% Processing Stream Config File
% Processing Stream Config File #
processOpt_default.cfg

% Regression Test Active
% Regression Test Active # true, false
false

% Include Archived User Functions
% Include Archived User Functions # Yes, No
No

% Default Processing Stream Style
% Default Processing Stream Style # SNIRF, NIRS
SNIRF

% Logging
% Logging # On, Off
On

% Check For Updates
% Check For Updates # on, off
on

% Data Storage Scheme
% Data Storage Scheme # files, memory
files

% Auto Save Acquisition Files
% Auto Save Acquisition Files # No, Yes
No

% Group Data Loading Warnings
+2.17 KiB (94.5 KiB)

File changed.

No diff preview for this file type.

+4 −0
Original line number Diff line number Diff line
@@ -1927,3 +1927,7 @@ xlim( bbox(1:2) );
ylim( bbox(3:4) );
maingui.axesSDG.xlim = bbox(1:2);
maingui.axesSDG.ylim = bbox(3:4);

% --------------------------------------------------------------------
function menuItemAppConfigGUI_Callback(hObject, eventdata, handles)
configSettingsGUI();
+50 −10
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ classdef ConfigFileClass < FileClass
        % ----------------------------------------------------
        function obj = ConfigFileClass(filename0)
            obj.linestr = '';
            obj.sections = struct('name','','val','');
            obj.sections = struct('name','','val','','param','');
            obj.filename = '';
            
            % Error checks
@@ -74,18 +74,18 @@ classdef ConfigFileClass < FileClass
            %
            % Rule 2:
            % =======
            % % name1
            % % name1 # param1
            % % END
            %
            % Rule 3:
            % =======
            % % name1
            % % name1 # param1
            % val11
            % % END
            %
            % Rule 4:
            % =======
            % % name1
            % % name1 # param1
            % val11
            % val12
            % ....
@@ -94,13 +94,13 @@ classdef ConfigFileClass < FileClass
            %
            % Rule 5:
            % =======
            % % name1
            % % name1 # param1
            % val11
            % val12
            % ....
            % val1M
            %
            % % name2
            % % name2 # param2
            % val21
            % val22
            % ....
@@ -108,7 +108,7 @@ classdef ConfigFileClass < FileClass
            %
            %  .....
            %
            % % nameN
            % % nameN # paramN
            % valN1
            % valN2
            % ....
@@ -138,6 +138,7 @@ classdef ConfigFileClass < FileClass
                    end
                end
                name = obj.getSectionNameFromLine();
                param = obj.getSectionParamFromLine();
                
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %%%% Find next parameter's value %%%%
@@ -171,6 +172,7 @@ classdef ConfigFileClass < FileClass
                %%%% Assign name/value pair to next param %%%%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                obj.sections(iP).name = name;
                obj.sections(iP).param = param;
                obj.sections(iP).val = val;
                
                
@@ -200,7 +202,13 @@ classdef ConfigFileClass < FileClass
            end
            fprintf(obj.fid, '\n');
            for ii=1:length(obj.sections)
                if iscell(obj.sections(ii).param) && all(~cellfun(@isempty,obj.sections(ii).param))
                    fprintf(obj.fid, '%% %s # %s\n', obj.sections(ii).name, strjoin(obj.sections(ii).param,', '));
                elseif iscell(obj.sections(ii).param) && all(cellfun(@isempty,obj.sections(ii).param))
                    fprintf(obj.fid, '%% %s #\n', obj.sections(ii).name);
                else
                    fprintf(obj.fid, '%% %s\n', obj.sections(ii).name);
                end
                for jj=1:length(obj.sections(ii).val)
                    fprintf(obj.fid, '%s\n', obj.sections(ii).val{jj});
                end
@@ -297,13 +305,45 @@ classdef ConfigFileClass < FileClass
                ii=ii+1;
            end
            jj=ii;
            while jj<length(obj.linestr) && (obj.linestr(jj)~=sprintf('\n') || obj.linestr(jj)~=sprintf('\r'))
            while jj<length(obj.linestr) && (obj.linestr(jj)~=newline || obj.linestr(jj)~=sprintf('\r')) && ~strcmp(obj.linestr(jj),'#')
                jj=jj+1;
            end
            if strcmp(obj.linestr(jj),'#')
                jj = jj-2;
            end
            name = strtrim_improve(obj.linestr(ii:jj));
        end
        
        
        % -------------------------------------------------------------------------------------------------
        function param = getSectionParamFromLine(obj)
            param = '';
            if isempty(obj.linestr)
                return;
            end
            
            ii=1;
            while ii<length(obj.linestr) && obj.linestr(ii)~='#'
                ii=ii+1;
            end
            while ii<length(obj.linestr) && ~isalnum(obj.linestr(ii))
                ii=ii+1;
            end
            jj=ii;
            while jj<length(obj.linestr) && (obj.linestr(jj)~=newline || obj.linestr(jj)~=sprintf('\r'))
                jj=jj+1;
            end
            if ii == jj && strcmp(obj.linestr(ii),'#')
                param = cell(1,1);
            elseif ii == jj
                param = [];
            else
                param = strtrim_improve(obj.linestr(ii:jj));
                param = split(param,', ');
            end
        end
        
        
        % -------------------------------------------------------------------------------------------------
        function val = getSectionValueFromLine(obj)
            val = '';
@@ -316,7 +356,7 @@ classdef ConfigFileClass < FileClass
                ii=ii+1;
            end
            jj=ii;
            while jj<length(obj.linestr) && (obj.linestr(jj)~=sprintf('\n') || obj.linestr(jj)~=sprintf('\r'))
            while jj<length(obj.linestr) && (obj.linestr(jj)~=newline || obj.linestr(jj)~=sprintf('\r'))
                jj=jj+1;
            end
            val = obj.linestr(ii:jj);
+197 −0
Original line number Diff line number Diff line
function configSettingsGUI
    global cfgSet
    
    cfgSet = ConfigFileClass();
    
    f = figure('NumberTitle','off');
    f.Name = 'App Setting Config GUI';
    set(f, 'MenuBar', 'none');
    set(f, 'ToolBar', 'none');
    
    param = cell(length(cfgSet.sections),1);
    for i = 1:length(cfgSet.sections)
        param{i} = cfgSet.sections(i).param;
    end
    
    %Number of Parameters
    np = length(cfgSet.sections);
    %Number of Editable Parameters
    n = length(cfgSet.sections) - length(find(cellfun(@isempty,param)));
    
    nAdj = 1;               %Count for Editable Parameters
    p = cell(n,1);          %Panels
    c = cell(n,1);          %Parameters/User Inputs
    
    if n < 11
        if rem(n,2) ~= 0
            p{1} = uipanel('Title',cfgSet.sections(1).name,'FontSize',12,'Position',[0 1-(1/((n+1)/2)) 1 1/((n+1)/2)]);
            if isempty(cfgSet.sections(1).param)
                %Not editable?
                c{1} = uicontrol(p{1}, 'Style', 'text', 'FontSize', 15, 'Units', 'Normalized');
                c{1}.String = 'Not Editable';
                cfgSet.sections(1).val = [];
            elseif isempty(find(strcmp(cfgSet.sections(1).param,cfgSet.sections(1).val),1))
                c{1} = uicontrol(p{1}, 'Style', 'edit', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(1).name);
                c{1}.String = cfgSet.sections(1).val;
                c{1}.Position = [0.125 0.25 0.75 0.5];
                c{nAdj}.Callback = @setVal;
                nAdj = nAdj + 1;
            else
                c{1} = uicontrol(p{1}, 'Style', 'popupmenu', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(1).name);
                c{1}.String = cfgSet.sections(1).param;
                c{1}.Value = find(strcmp(cfgSet.sections(1).param,cfgSet.sections(1).val));
                c{1}.Position = [0.125 0.25 0.75 0.5];
                c{nAdj}.Callback = @setVal;
                nAdj = nAdj + 1;
            end
            if n < 2
                %End
            else
                for i = 2:np
                    if isempty(cfgSet.sections(i).param)
                        %Not editable?
                        continue;
                    elseif isempty(find(strcmp(cfgSet.sections(i).param,cfgSet.sections(i).val),1))
                        p{nAdj} = uipanel('Title',cfgSet.sections(i).name,'FontSize',12,'Position',[0.5*rem(nAdj,2) 1-(floor(nAdj/2)+1)*(1/(n/2+1)) 0.5 1/(n/2+1)]);
                        c{nAdj} = uicontrol(p{nAdj}, 'Style', 'edit', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i).name);
                        c{nAdj}.String = cfgSet.sections(i).val{1};
                        c{nAdj}.Callback = @setVal;
                    else
                        p{nAdj} = uipanel('Title',cfgSet.sections(i).name,'FontSize',12,'Position',[0.5*rem(nAdj,2) 1-(floor(nAdj/2)+1)*(1/(n/2+1)) 0.5 1/(n/2+1)]);
                        c{nAdj} = uicontrol(p{nAdj}, 'Style', 'popupmenu', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i).name);
                        c{nAdj}.String = cfgSet.sections(i).param;
                        c{nAdj}.Callback = @setVal;
                    end
                    c{nAdj}.Value = find(strcmp(cfgSet.sections(i).param,cfgSet.sections(i).val));
                    c{nAdj}.Position = [0.125 0.25 0.75 0.5];
                    nAdj = nAdj + 1;
                end
            end
        else
            if n == 0
                %Nothing
            else
                for i = 0:(np-1)
                    if i == 0
                        if isempty(cfgSet.sections(i+1).param)
                            %Not editable?
                            continue;
                        elseif isempty(find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val),1))
                            p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[0.5*rem(nAdj-1,2) 1-(floor((nAdj-1)/2)+1)*(1/(n/2+1)) 0.5 1/(n/2+1)]);
                            c{nAdj} = uicontrol(p{nAdj}, 'Style', 'edit', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                            c{nAdj}.String = cfgSet.sections(i+1).val{1};
                            c{nAdj}.Callback = @setVal;
                        else
                            p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[0.5*rem(nAdj-1,2) 1-(floor((nAdj-1)/2)+1)*(1/(n/2+1)) 0.5 1/(n/2+1)]);
                            c{nAdj} = uicontrol(p{nAdj}, 'Style', 'popupmenu', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                            c{nAdj}.String = cfgSet.sections(i+1).param;
                            c{nAdj}.Callback = @setVal;
                        end
                        c{nAdj}.Value = find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val));
                        c{nAdj}.Position = [0.125 0.25 0.75 0.5];
                        nAdj = nAdj + 1;
                    else
                        if isempty(cfgSet.sections(i+1).param)
                            %Not editable?
                            continue;
                        elseif isempty(find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val),1))
                            p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[0.5*rem(nAdj-1,2) 1-(floor((nAdj-1)/2)+1)*(1/(n/2+1)) 0.5 1/(n/2+1)]);
                            c{nAdj} = uicontrol(p{nAdj}, 'Style', 'edit', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                            c{nAdj}.String = cfgSet.sections(i+1).val{1};
                            c{nAdj}.Callback = @setVal;
                        else
                            p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[0.5*rem(nAdj-1,2) 1-(floor((nAdj-1)/2)+1)*(1/(n/2+1)) 0.5 1/(n/2+1)]);
                            c{nAdj} = uicontrol(p{nAdj}, 'Style', 'popupmenu', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                            c{nAdj}.String = cfgSet.sections(i+1).param;
                            c{nAdj}.Callback = @setVal;
                        end
                        c{nAdj}.Value = find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val));
                        c{nAdj}.Position = [0.125 0.25 0.75 0.5];
                        nAdj = nAdj + 1;
                    end
                end
            end
        end
    else
        div = ceil(n/5);
        for i = 0:(np-1)
            if i == 0
                if isempty(cfgSet.sections(i+1).param)
                    %Not editable?
                    continue;
                elseif isempty(find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val),1))
                    p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[(1/div)*(rem(nAdj-1,div)) 1-(floor((nAdj-1)/div)+1)*(1/ceil(n/div)) 1/div 1/ceil(n/div)]);
                    c{nAdj} = uicontrol(p{i+1}, 'Style', 'edit', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                    c{nAdj}.String = cfgSet.sections(i+1).val{1};
                    c{nAdj}.Callback = @setVal;
                else
                    p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[(1/div)*(rem(nAdj-1,div)) 1-(floor((nAdj-1)/div)+1)*(1/ceil(n/div)) 1/div 1/ceil(n/div)]);
                    c{nAdj} = uicontrol(p{i+1}, 'Style', 'edit', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                    c{nAdj}.String = cfgSet.sections(i+1).param;
                    c{nAdj}.Callback = @setVal;
                end
                c{nAdj}.Value = find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val));
                c{nAdj}.Position = [0.125 0.25 0.75 0.5];
                nAdj = nAdj + 1;
            else
                p{nAdj} = uipanel('Title',cfgSet.sections(i+1).name,'FontSize',12,'Position',[(1/div)*(rem(nAdj-1,div)) 1-(floor((nAdj-1)/div)+1)*(1/ceil(n/div)) 1/div 1/ceil(n/div)]);
                if isempty(cfgSet.sections(i+1).param)
                    %Not editable?
                    continue;
                elseif isempty(find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val),1))
                    c{nAdj} = uicontrol(p{i+1}, 'Style', 'popupmenu', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                    c{nAdj}.String = cfgSet.sections(i+1).val{1};
                    c{nAdj}.Callback = @setVal;
                else
                    c{nAdj} = uicontrol(p{i+1}, 'Style', 'popupmenu', 'FontSize', 15, 'Units', 'Normalized', 'Tag', cfgSet.sections(i+1).name);
                    c{nAdj}.String = cfgSet.sections(i+1).param;
                    c{nAdj}.Callback = @setVal;
                end
                c{nAdj}.Value = find(strcmp(cfgSet.sections(i+1).param,cfgSet.sections(i+1).val));
                c{nAdj}.Position = [0.125 0.25 0.75 0.5];
                nAdj = nAdj + 1;
            end
        end
    end
    
    if n < 11
        if rem(n,2) ~= 0
            p{nAdj} = uipanel('FontSize',12,'Position',[0 0 1 1/((n+1)/2+1)]);
        else
            p{nAdj} = uipanel('FontSize',12,'Position',[0 0 1 1/(n/2+1)]);
        end
    else
        p{nAdj} = uipanel('FontSize',12,'Position',[0 0 1 1/ceil(n/div)]);
    end
    c{nAdj} = uicontrol(p{nAdj}, 'Style', 'pushbutton', 'FontSize', 15, 'Units', 'Normalized', 'String', 'Save',...
              'Position', [0.125 0.25 0.25 0.5]);
    c{nAdj}.Callback = @cfgSave;
    c{nAdj+1} = uicontrol(p{nAdj}, 'Style', 'pushbutton', 'FontSize', 15, 'Units', 'Normalized', 'String', 'Exit',...
              'Position', [0.625 0.25 0.25 0.5]);
    c{nAdj+1}.Callback = @cfgExit;

%     clear cfgSet
end
    
    % -------------------------------------------------------------
    function setVal(src,~)
      global cfgSet
      if iscell(src.String)
        cfgSet.SetValue(src.Tag, src.String{src.Value});
      else
        cfgSet.SetValue(src.Tag, src.String);
      end
    end
    
    % -------------------------------------------------------------
    function cfgSave(~,~)
      global cfgSet
      cfgSet.Save();
      close;
    end
    
    % -------------------------------------------------------------
    function cfgExit(~,~)
        close;
    end
    
 No newline at end of file