Commit 61f11f04 authored by jayd1860's avatar jayd1860
Browse files

v1.16.1

-- Modify Export utility to be mode modular breaking up ProcResultClass.ExportHRF method into  ProcResultClass.GenerateTableCells_HRF which creates a 2D array of TableCell objects and ProcResultClass.ExportHRF which creates a ExportTable object that does the actual exporting.

-- Modify message menu message "current only or current and all under it" when exporting to be clearer and don't ask it when current element is a run. Move TreeNodeClass.ExportHRF method to RunClass where it makes more sense.

-- Minor change replacing replacefilesepinpath.m with improved filesepStandard.m.

-- Minor change to fix MenuBox being too small for the button when the button text is very long.
parent f0db636d
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -601,17 +601,25 @@ classdef GroupClass < TreeNodeClass
        
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, options, iBlk)
            if nargin<2
            if nargin<2 || isempty(options)
                q = MenuBox('Export only current group data OR current group data and all it''s subject data?', ...
                            {'Current group data only','Current group data and all it''s subject data','Cancel'});
                if q==1
                    options  = 'current';
                elseif q==2
                    options  = 'all';
                else
                    return
                end
            end
            if nargin<3
                iBlk = 1;
            end
            
            obj.procStream.ExportHRF(obj.name, obj.CondNames, iBlk)
            obj.procStream.ExportHRF(obj.name, obj.CondNames, iBlk);
            if strcmp(options, 'all')
                for ii=1:length(obj.subjs)
                    obj.subjs(ii).ExportHRF('all', iBlk)
                    obj.subjs(ii).ExportHRF('all', iBlk);
                end
            end
        end
+40 −42
Original line number Diff line number Diff line
@@ -438,6 +438,9 @@ classdef ProcResultClass < handle
    end
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Export related methods
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    methods
        
        % ----------------------------------------------------------------------------------
@@ -504,65 +507,60 @@ classdef ProcResultClass < handle
            end
        end
        
        
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, filename, CondNames, iBlk)
            if nargin<3
                iBlk = 1;
    end
        
            % Max column width in number ois characters
            maxcolwidth = 12;
            
            [pname, fname] = fileparts(filename);
            ext = '_HRF.txt';
            
            fd = fopen([pname, fname, ext], 'wt');
    methods
        
            fprintf(fd, '%s: exported HRF data\n', fname);
            fprintf('%s: exported HRF data\n', fname);
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_HRF(obj, CondNames, iBlk)
            
            tblcells = TableCell.empty();
            if isa(obj.dcAvg, 'DataClass')
                dataTimeSeries = obj.dcAvg.GetDataTimeSeries();
                measList = obj.dcAvg.measurementList;
                
                % Header: stim condition
                % Header: stim condition name row
                for iCh=1:length(measList)
                    stim_cond_str = sprintf('%s', CondNames{measList(iCh).dataTypeIndex});
                    nspaces = round((maxcolwidth - length(stim_cond_str)));
                    fprintf(fd, '%s%s\t', blanks(nspaces), stim_cond_str);
                    tblcells(1,iCh) = TableCell(sprintf('%s', CondNames{measList(iCh).dataTypeIndex}), 12);
                end
                fprintf(fd, '\n');
                
                % Header: Hb type row
                for iCh=1:length(measList)
                    hb_sd_str = sprintf('%s,%d,%d', measList(iCh).dataTypeLabel, measList(iCh).sourceIndex, measList(iCh).detectorIndex);
                    nspaces = round((maxcolwidth - length(hb_sd_str)));
                    fprintf(fd, '%s%s\t', blanks(nspaces), hb_sd_str);
                    tblcells(2,iCh) = TableCell(sprintf('%s,%d,%d', measList(iCh).dataTypeLabel, measList(iCh).sourceIndex, measList(iCh).detectorIndex), 12);
                end
                
                fprintf(fd, '\n');
                        
                % Data rows
                for t=1:size(dataTimeSeries,1)
                    for iCh=1:length(measList)
                        if isnan(dataTimeSeries(t,iCh))
                            nspaces = round((maxcolwidth - length('NaN')));
                            cname  = 'NaN';
                        else
                            nspaces = dataTimeSeries(t,iCh)>=0;
                            cname = sprintf('%s%0.5e', blanks(dataTimeSeries(t,iCh)>=0), dataTimeSeries(t,iCh));
                        end
                        tblcells(t+2,iCh) = TableCell(cname, 12);
                    end
                        fprintf(fd, '%s%0.5e\t', blanks(nspaces), dataTimeSeries(t,iCh));
                end
                    fprintf(fd, '\n');
            end
                fprintf(fd, '\n\n');            
        end
                
            fclose(fd);
        
        % ----------------------------------------------------------------------------------
        function tbl = ExportHRF(obj, filename, CondNames, iBlk)
            if nargin<3
                iBlk = 1;
            end
            
            % Generate table cells
            tblcells = obj.GenerateTableCells_HRF(CondNames, iBlk);
            
            % Create table and save it to a file
            tbl = ExportTable(filename, 'HRF', tblcells);
            tbl.Open()
            tbl.Save();
            tbl.Close();
        end
        
    end
    
end
+1 −1
Original line number Diff line number Diff line
@@ -345,7 +345,7 @@ classdef ProcStreamClass < handle
            if nargin<3
                iBlk = 1;
            end
            obj.output.ExportHRF(filename, CondNames, iBlk)
            obj.output.ExportHRF(filename, CondNames, iBlk);
        end

    end
+12 −2
Original line number Diff line number Diff line
@@ -641,7 +641,17 @@ classdef RunClass < TreeNodeClass
            nbytes = obj.acquired.MemoryRequired();
        end
    
    
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, iBlk)
            if nargin<2
                iBlk = 1;
            end
            obj.procStream.ExportHRF(obj.name, obj.CondNames, iBlk);
        end
         
    end
        
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Private methods
+12 −4
Original line number Diff line number Diff line
@@ -427,17 +427,25 @@ classdef SubjClass < TreeNodeClass
        
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, options, iBlk)
            if nargin<2
            if nargin<2 || isempty(options)
                q = MenuBox('Export only current subject data OR current subject data and all it''s run data?', ...
                            {'Current subject data only','Current subject data and all it''s run data','Cancel'});
                if q==1
                    options  = 'current';
                elseif q==2
                    options  = 'all';
                else
                    return
                end
            end
            if nargin<3
                iBlk = 1;
            end

            obj.procStream.ExportHRF(obj.name, obj.CondNames, iBlk)
            obj.procStream.ExportHRF(obj.name, obj.CondNames, iBlk);
            if strcmp(options, 'all')
                for ii=1:length(obj.runs)
                    obj.runs(ii).ExportHRF(iBlk)
                    obj.runs(ii).ExportHRF(iBlk);
                end
            end
        end
Loading