Commit 8cd7b4fe authored by Jay Dubb's avatar Jay Dubb
Browse files

v1.25.10

-- Create single function in StimEdirGUI to cerate new coindition name and do some error checking on it as weel as displaying a warning message that adding a new condition might change the stim colors and reorder the conditions legend.

-- Fix child GUIs being obscured by MainGUI when launching. Add PositionFigures method to ChildGuiClass.m to move child GUI to left edge while moving parent GUI to right edge
parent a8e600b8
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@ if ~exist(fname, 'file')
else
    fid = H5F.open(fname,'H5F_ACC_RDWR','H5P_DEFAULT');
end
if iscell(data)
    data = cell2str_new(data);
end

filetype = H5T.copy('H5T_FORTRAN_S1'); 
H5T.set_size(filetype, size(data,2)); 
@@ -17,7 +19,11 @@ H5T.set_size(memtype, size(data,2));
space = H5S.create_simple(1, size(data,1), []); 

% Create the dataset and write the string data to it. 
try
    dset = H5D.create(fid, location, filetype, space, 'H5P_DEFAULT'); 
catch
    dset = H5D.open(fid, location);
end

% Transpose the data to match the layout in the H5 file to match C 
% generated H5 file. 
+5 −1
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@ else
        if ~isempty(findstr('rw', options))
            HDF5_DatasetWrite(fname, name, val);
        else
            try
                hdf5write(fname, name, val, 'WriteMode','append');
            catch
                HDF5_DatasetWriteStrings(fname, name, val)                
            end
        end
    catch
        return;
+97 −18
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ stimEdit.groupDirs = {};
stimEdit.format = '';
stimEdit.pos = [];
stimEdit.updateParentGui = [];
stimEdit.newCondWarning = false;


cfg = ConfigFileClass();
stimEdit.config.autoSaveAcqFiles = cfg.GetValue('Auto Save Acquisition Files');
@@ -221,13 +223,10 @@ global stimEdit
%      and runs same as if you were loading during Homer3 startup from the 
%      acquired data.
%
newname = inputdlg({'New Condition Name'}, 'New Condition Name');
newname = CreateNewConditionName();
if isempty(newname)
    return;
end
if isempty(newname{1})
    return;
end

% Get the name of the condition you want to rename
conditions = get(handles.popupmenuConditions, 'string');
@@ -239,10 +238,11 @@ oldname = conditions{idx};
% following line in favor of the one after it. 

iG = stimEdit.locDataTree.GetCurrElemIndexID();
stimEdit.locDataTree.groups(iG).RenameCondition(oldname, newname{1});
stimEdit.locDataTree.groups(iG).RenameCondition(oldname, newname);
if stimEdit.status ~= 0
    return;
end

stimEdit.locDataTree.groups(iG).SetConditions();
set(handles.popupmenuConditions, 'string', stimEdit.locDataTree.groups(iG).GetConditions());
Display(handles);
@@ -412,6 +412,93 @@ menu_choice = MenuBox(menuTitleStr, actionLst);




% ------------------------------------------------
function err = IsCondError(CondName, overrideLength)
global stimEdit
err = 0;

if ~exist('overrideLength','var')
    overrideLength = false;
end

iG = stimEdit.locDataTree.GetCurrElemIndexID();
CondNamesGroup = stimEdit.locDataTree.groups(iG).GetConditions();
if isempty(CondName)
    err = -1;
    return;
end
if iscell(CondName)
    CondName = CondName{1};
end
if length(CondName) > 1 && ~overrideLength
    msg{1} = sprintf('ERROR: Due to a bug in the latest Homer3 version '); 
    msg{2} = sprintf('new condition names have a 1 character limit. ');
    msg{3} = sprintf('This will be fixed in a near future Homer3 release. ');
    msg{4} = sprintf('For now please name the new condition using only one character');
    MessageBox([msg{:}]);
    err = -1;
end
if ismember(CondName, CondNamesGroup)
    err = -2;
end



% ------------------------------------------------
function status = NewCondWarning()
global stimEdit

status = 0;

if stimEdit.newCondWarning
    return;
end
msg{1} = sprintf('WARNING: Please note that adding a new condition or renaming an exiting one ');
msg{2} = sprintf('could change the colors of the stimuli and reorder the stim condition color legend ');
msg{3} = sprintf('in the top right corner of the axes window.');
q = MenuBox([msg{:}], {'Okay', 'Cancel', 'Don''t Warn Again and Proceed'});
if q==3
    stimEdit.newCondWarning = true;
elseif q==2
    status = -1;
end


% ------------------------------------------------
function CondName = CreateNewConditionName(overrideLength)

if ~exist('overrideLength','var')
    overrideLength = false;
end

CondName = '';
CondNameNew = inputdlg('','New Condition name');
if isempty(CondNameNew)
    return
end
while 1
    err = IsCondError(CondNameNew, overrideLength);
    if err==0
        break;
    end
    if err==-1
        CondNameNew = inputdlg('','New Condition name');
    end
    if err==-2
        CondNameNew = inputdlg('Condition already exists. Choose another name.','New Condition name');
    end
    if isempty(CondNameNew)
        return;
    end
end
CondName = CondNameNew{1};
if NewCondWarning() < 0
    CondName = '';
end



% ------------------------------------------------
function menu_choice = AddEditDelete(tPts_idxs_select, iS_lst, mode, menu_choice)
% Usage:
@@ -463,17 +550,10 @@ end
if isempty(iS_lst)
    % If stim added to new condition update group conditions
    if menu_choice==nCond+1
        CondNameNew = inputdlg('','New Condition name');
        if isempty(CondNameNew)
        CondName = CreateNewConditionName(true);
        if isempty(CondName)
            return;
        end
        while ismember(CondNameNew{1}, CondNamesGroup)
            CondNameNew = inputdlg('Condition already exists. Choose another name.','New Condition name');
            if isempty(CondNameNew)
                return;
            end
        end
        CondName = CondNameNew{1};
    else
        CondName = CondNamesGroup{menu_choice};
    end
@@ -503,11 +583,10 @@ else
        
        % Assign new condition to edited stim
        if menu_choice==nCond+1
            CondNameNew = inputdlg('','New Condition name');
            if isempty(CondNameNew)
            CondName = CreateNewConditionName(true);
            if isempty(CondName)
                return;
            end
            CondName = CondNameNew{1};
        else
            CondName = CondNamesGroup{menu_choice};
        end
+28 −2
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ classdef ChildGuiClass < handle
            handles = []; %#ok<*PROPLC>
            switch(length(a))
                % Note that in addition to the guis known args we add as the last arg the last gui position. 
                % We do this because even we can set the position after launching gui, it is much nices when 
                % We do this because even if we can set the position after launching gui, it is much nices when 
                % the gui is not seen to change position. If the position is set from within the GUI it 
                % appears only in the position we pass it since it is invisible until the gui's open function 
                % exits
@@ -165,9 +165,35 @@ classdef ChildGuiClass < handle
%                     set(obj.handles.figure, 'position',[p(1),p(2),p(3),p(4)]);
%                 end
                obj.SetTitle();
                
                % Try to make sure child gui is not obscured by prent gui
                obj.PositionFigures();
            end
        end
        
        
        % -------------------------------------------------------------------
        function PositionFigures(obj)
            hp = findobj('tag', 'MainGUI');
            if ~ishandles(hp)
                return;
            end

            up0 = get(hp, 'units');  
            uc0 = get(obj.handles.figure, 'units');
            
            set(hp, 'units', 'normalized');
            set(obj.handles.figure, 'units', 'normalized');
            
            pp = get(hp, 'position');
            pc = get(obj.handles.figure, 'position');

            set(hp, 'position', [1-pp(3), pp(2), pp(3), pp(4)])
            set(obj.handles.figure, 'position', [0, pc(2), pc(3), pc(4)])

            set(hp, 'units', up0);
            set(obj.handles.figure, 'units', uc0);
        end
        
        
        % -------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -2,5 +2,5 @@ function vrnnum = getVernum()

vrnnum{1} = '1';   % Major version #
vrnnum{2} = '25';  % Major sub-version #
vrnnum{3} = '9';   % Minor version #
vrnnum{3} = '10';   % Minor version #
vrnnum{4} = '0';   % Minor sub-version # or patch #: 'p1', 'p2', etc