Commit 1fb30baa authored by jayd1860's avatar jayd1860
Browse files

v1.41.0

-- Add ability to plot selected measurements in exported HRF file from ExportDataGUI
-- In ConfigFileClass exclude AppSettings.cfg in submodules folder under Homer3 root folder
parent 93d18b0c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1028,6 +1028,18 @@ classdef ProcResultClass < handle
        
        
        
        % ----------------------------------------------------------------------------------
        function filename = ExportHRF_GetFilename(obj, filename)
            [p, f] = fileparts(obj.SetFilename(filename));
            filename = [filesepStandard(p, 'nameonly:dir'), f];
            
            % Create table export data to file
            tbl = ExportTable(filename, 'HRF');
            filename = tbl.GetFilenameFull();
        end
        
        
        
        % ----------------------------------------------------------------------------------
        function tbl = ExportMeanHRF(obj, filename, CondNames, trange, iBlk)
            if ~exist('iBlk','var') || isempty(iBlk)
+6 −0
Original line number Diff line number Diff line
@@ -1839,6 +1839,12 @@ classdef ProcStreamClass < handle
        end
        
        
        % ----------------------------------------------------------------------------------
        function filename = ExportHRF_GetFilename(obj, filename)
            filename = obj.output.ExportHRF_GetFilename(filename);
        end
        
        
        % ----------------------------------------------------------------------------------
        function ExportMeanHRF(obj, filename, CondNames, trange, iBlk)
            if ~exist('iBlk','var') || isempty(iBlk)
+7 −0
Original line number Diff line number Diff line
@@ -1090,6 +1090,13 @@ classdef TreeNodeClass < handle
    
        
        
        % ----------------------------------------------------------------------------------
        function filename = ExportHRF_GetFilename(obj)
            filename = obj.procStream.ExportHRF_GetFilename([obj.path, obj.GetOutputFilename()]);
        end
    
        
        
        % ----------------------------------------------------------------------------------
        function tblcells = ExportMeanHRF_Alt(obj, procElemSelect, trange, iBlk)
            tblcells = [];
+5.23 KiB (25.8 KiB)

File changed.

No diff preview for this file type.

+166 −2
Original line number Diff line number Diff line
@@ -17,16 +17,22 @@ else
end



% ----------------------------------------------------------------
function InitOutput()
global exportvar

if isfield(exportvar, 'hFigPlot')
    if ishandle(exportvar.hFigPlot)
        delete(exportvar.hFigPlot)
    end
end
exportvar = [];

% Output data structure
exportvar.pathname = '';
exportvar.filename = '';

exportvar.hFigPlot = -1;
exportvar.format = '';
% exportvar.formatchoices = {'.txt','.xls'};
exportvar.formatchoices = {'.txt'};
@@ -39,6 +45,7 @@ exportvar.trange = [0,0];
exportvar.procElemSelect = '';



% ----------------------------------------------------------------
function UpdateOutput(handles)
global exportvar
@@ -118,6 +125,7 @@ set(handles.radiobuttonCurrProcElemAndSubTree, 'value', 0);
popupmenuDataType_Callback(handles.popupmenuDataType, [], handles)

UpdateOutput(handles);
SetLoadPlotPanelVisible(handles, 'off')

handles.output = hObject;
guidata(hObject, handles);
@@ -133,10 +141,12 @@ global exportvar
varargout{1} = exportvar;



% ----------------------------------------------------------------
function figure_DeleteFcn(~, ~, ~)



% ----------------------------------------------------------------
function popupmenuDataType_Callback(hObject, ~, handles)
UpdateOutput(handles)
@@ -182,7 +192,13 @@ UpdateOutput(handles)


% ----------------------------------------------------------------
function pushbuttonSubmit_Callback(~, ~, handles)
function pushbuttonExport_Callback(~, ~, handles)
global exportvar
if isfield(exportvar, 'hFigPlot')
    if ishandle(exportvar.hFigPlot)
        delete(exportvar.hFigPlot)
    end
end
delete(handles.figure)


@@ -216,3 +232,151 @@ UpdateOutput(handles)
function figure_CloseRequestFcn(hObject, ~, ~)
InitOutput();
delete(hObject);


% ----------------------------------------------------------------
function pushbuttonPlot_Callback(~, ~, handles)
global exportvar
global maingui
global logger
logger = InitLogger(logger);

str = get(handles.editChannels, 'string');
iCh = str2num(str);
if length(iCh) > 6
    MenuBox('Number of channels to plot exceeds maximum of 6','OK');
    return
end
if isempty(iCh)
    return
end
fnameExport = maingui.dataTree.currElem.ExportHRF_GetFilename();
fname = maingui.dataTree.currElem.GetName();
if ispathvalid(fnameExport) && GetFileSize(fnameExport)>0
    logger.Write('Loading %s\n', fnameExport);
    fid = fopen(fnameExport, 'rt');
    d = [];
    tt = 1;
    while 1
        l = fgetl(fid);
        if l == -1
            break
        end
        if tt>2
            d(tt,:) = str2num(l); %#ok<*AGROW>
        end
        tt = tt+1;
    end
    fclose(fid);
    t = d(:,1);
    d = d(:,2:end);

    if max(iCh)>size(d,2)
        return
    end
    if min(iCh)<1
        return
    end    
    if ishandle(exportvar.hFigPlot)
        delete(exportvar.hFigPlot)
    end
    exportvar.hFigPlot = figure('name',sprintf('%s channel [%s] data plot :', fname, num2str(iCh)), ...
        'toolbar','none', 'menubar','none', 'NumberTitle','off'); 
    h = plot(t, d(:,iCh));
    ha = get(h(1), 'parent');
    set(ha, 'xlim',[t(1), t(end)])
    PositionFigures(exportvar.hFigPlot, handles.figure);
else
    logger.Write('The export file for %s has not been generated yet.\n', fname);
end




% ----------------------------------------------------------------
function checkboxLoad_Callback(hObject, ~, handles)
val = get(hObject, 'value');
if val==1
    SetLoadPlotPanelVisible(handles, 'on')
else
    SetLoadPlotPanelVisible(handles, 'off')
end



% ----------------------------------------------------------------
function editChannels_Callback(~, ~, ~)



% ----------------------------------------------------------------
function SetLoadPlotPanelVisible(handles, onoff)
if ~exist('onoff', 'var')
    onoff = 'off';
end
if strcmp(onoff, 'on')
    enable = 'off';
else
    enable = 'on';
end
set(handles.uipanelLoadPlot, 'visible', onoff);
set(handles.pushbuttonPlot, 'visible', onoff);
set(handles.popupmenuExportFormat,  'enable', enable);
set(handles.editTimeRangeMin,  'enable', enable);
set(handles.editTimeRangeMax,  'enable', enable);
set(handles.textTimeRange,  'enable', enable);
set(handles.textExportFormat,  'enable', enable);
set(handles.textDataType,  'enable', enable);
set(handles.popupmenuDataType,  'enable', enable);
set(handles.editFilename, 'enable', enable);
set(handles.textFilename, 'enable', enable);
if strcmp(enable, 'off')
    set(handles.popupmenuDataType, 'value',1);
end



% -------------------------------------------------------------------
function PositionFigures(hc, hp)

% Get initial units of parent and child guis
us0 = get(0, 'units');
up0 = get(hc, 'units');
uc0 = get(hc, 'units');

% Normalize units of parent and child guis
set(0,'units','normalized');
set(hp, 'units', 'normalized');
set(hc, 'units', 'normalized');

% Get positions of parent and child guis
% Set screen units to be same as GUI
ps = get(0,'MonitorPositions');
pp = get(hp, 'position');
pc = get(hc, 'position');

% To work correctly for mutiple sceens, Ps must be sorted in ascending order
ps = sort(ps,'ascend');

% Find which monitor parent gui is in
for ii = 1:size(ps,1)
    if (pp(1)+pp(3)/2) < (ps(ii,1)+ps(ii,3))
        break;
    end
end

% Fix bug: if multiple monitors left-to-right physical arrangement does
% not match left-to-right virtual setting then subtract 1 from monitor number.
if ps(1)<0
    ii = ii-1;
end

% Re-position parent and child guis
set(hp, 'position', [ii-pp(3), pp(2), pp(3), pp(4)])
set(hc, 'position', [ii-1, pc(2), pc(3), pc(4)])


% Reset parent and child guis' units
set(0, 'units', us0);
set(hp, 'units', up0);
set(hc, 'units', uc0);
Loading