Commit 04a8d3ab authored by jayd1860's avatar jayd1860
Browse files

v1.16.3

-- Add exporting of mean HRF feature
-- Fix typo in InitGuiControls.m, datatype causing matlab error.
-- Improve naming of exported data in exported data file
parent 74ff54f2
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
@@ -213,24 +213,21 @@ classdef DataClass < FileLoadSaveClass

        
        % ---------------------------------------------------------
        function ml = GetMeasListDod(obj)
            ml = zeros(length(obj.measurementList), 2);
            for ii=1:length(obj.measurementList)
                if  obj.measurementList(ii).GetWavelengthIndex()==1
                    ml(ii,:) = [obj.measurementList(ii).GetSourceIndex(), obj.measurementList(ii).GetDetectorIndex()];
                end
            end
        function idxs = GetMeasurementListIdxs(obj, CondIdxs)
            % Get all the measurementList array idxs matching the
            % conditions in the CondNames argument 
            idxs = zeros(1,length(obj.measurementList));
            kk=1;
            for iCh = 1:length(obj.measurementList)
                for iCond = 1:length(CondIdxs)
                    if sum(obj.measurementList(iCh).dataTypeIndex == CondIdxs)
                        idxs(kk) = iCh;
                        kk=kk+1;
                        break;
                    end
        
        
        % ---------------------------------------------------------
        function ml = GetMeasListDc(obj)
            ml = zeros(length(obj.measurementList), 2);
            for ii=1:length(obj.measurementList)
                if  obj.measurementList(ii).GetDataTypeLabel()==6
                    ml(ii,:) = [obj.measurementList(ii).GetSourceIndex(), obj.measurementList(ii).GetDetectorIndex()];
                end
            end
            idxs(idxs==0) = [];
        end

        
+74 −0
Original line number Diff line number Diff line
@@ -625,6 +625,52 @@ classdef GroupClass < TreeNodeClass
        end

        
        % ----------------------------------------------------------------------------------
        function tblcells = ExportMeanHRF(obj, iBlk)
            if nargin<2
                iBlk = 1;
            end
            
            nCh   = obj.procStream.GetNumChForOneCondition(iBlk);
            nCond = length(obj.CondNames);
            nSubj = length(obj.subjs);
            
            % Determine table dimensions            
            nHdrRows = 3;               % Blank line + name of columns
            nHdrCols = 2;               % Condition name + subject name
            nDataRows = nSubj*nCond;    
            nDataCols = nCh;                 % Number of channels for one condition (for example, if data type is Hb Conc: (HbO + HbR + HbT) * num of SD pairs)
            nTblRows = nDataRows + nHdrRows;
            nTblCols = nDataCols + nHdrCols;
            cellwidthCond = max(length('Condition'), obj.CondNameSizeMax());
            cellwidthSubj = max(length('Subject Name'), obj.SubjNameSizeMax());
            
            %%%% Initialize 2D array of TableCell objects with the above row * column dimensions            
            tblcells = repmat(TableCell(), nTblRows, nTblCols);
            
            % Header row: Condition, Subject Name, HbO,1,1, HbR,1,1, HbT,1,1, ...
            tblcells(2,1) = TableCell('Condition', cellwidthCond);
            tblcells(2,2) = TableCell('Subject Name', cellwidthSubj);
            [tblcells(2,3:end), cellwidthData] = obj.procStream.GenerateTableCellsHeader_MeanHRF(iBlk);
            
            % Generate data rows
            for iSubj = 1:nSubj
                rowIdxStart = ((iSubj-1)*nCond)+1 + nHdrRows;
                rowIdxEnd   = rowIdxStart + nCond - 1;
                
                tblcells(rowIdxStart:rowIdxEnd, 1:2)        = obj.subjs(iSubj).GenerateTableCellsHeader_MeanHRF(cellwidthCond, cellwidthSubj);
                tblcells(rowIdxStart:rowIdxEnd, 3:nTblCols) = obj.subjs(iSubj).GenerateTableCells_MeanHRF(cellwidthData, iBlk);
            end
            
            % Create ExportTable initialized with the filled in 2D TableCell array. 
            % ExportTable object is what actually does the exporting to a file. 
            tbl = ExportTable(obj.name, 'HRF mean', tblcells);
            tbl.Open()
            tbl.Save();
            tbl.Close();
            
        end
        
    end  % Public Save/Load methods
        
    
@@ -777,6 +823,34 @@ classdef GroupClass < TreeNodeClass
            end
        end
        

        % ----------------------------------------------------------------------------------
        function n = CondNameSizeMax(obj)
            n = 0;
            if isempty(obj.CondNames)
                return;
            end
            for ii = 1:length(obj.CondNames)
                if length(obj.CondNames{ii}) > n
                    n = length(obj.CondNames{ii});
                end
            end
        end
        
        
        % ----------------------------------------------------------------------------------
        function n = SubjNameSizeMax(obj)
            n = 0;
            if isempty(obj.subjs)
                return;
            end
            for ii = 1:length(obj.subjs)
                if length(obj.subjs(ii).name) > n
                    n = length(obj.subjs(ii).name);
                end
            end
        end
                
    end  % Private methods

end % classdef GroupClass < TreeNodeClass
+75 −9
Original line number Diff line number Diff line
@@ -439,7 +439,7 @@ classdef ProcResultClass < handle
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Export related methods
    % 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    methods
        
@@ -507,17 +507,81 @@ classdef ProcResultClass < handle
            end
        end
        
        
        % ----------------------------------------------------------------------------------
        function n = GetNumChForOneCondition(obj, iBlk)
            n = [];
            if nargin<2
                iBlk = 1;
            end
            if isa(obj.dcAvg, 'DataClass')
                n = length(obj.dcAvg(iBlk).GetMeasurementListIdxs(1));
            end            
        end
        
    end
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Export related methods
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    methods        
        
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_HRF(obj, CondNames, iBlk)
        function [tblcells, maxwidth] = GenerateTableCellsHeader_MeanHRF(obj, iBlk)
            if nargin<5
                iBlk = 1;
            end
            tblcells = TableCell.empty();
            maxwidth = length('HRF HbX,999,999');
            if isa(obj.dcAvg, 'DataClass')
                measList = obj.dcAvg(iBlk).measurementList;
                measListIdxs = obj.dcAvg(iBlk).GetMeasurementListIdxs(1);
                for iCh = measListIdxs
                    tblcells(1,iCh) = TableCell(sprintf('%s,%d,%d', measList(iCh).dataTypeLabel, measList(iCh).sourceIndex, measList(iCh).detectorIndex), maxwidth);
                end
            end
        end
        
        
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_MeanHRF(obj, name, CondNames, width, iBlk)
            if nargin<4
                width = 12;
            end
            if nargin<5
                iBlk = 1;
            end
            tblcells = TableCell.empty();
            if isa(obj.dcAvg, 'DataClass')
                dataTimeSeries = obj.dcAvg(iBlk).GetDataTimeSeries();                
                
                % Data rows
                for iCond = 1:length(CondNames)
                    measListIdxs = obj.dcAvg(iBlk).GetMeasurementListIdxs(iCond);
                    for iCh = measListIdxs
                        meanData = mean(dataTimeSeries(:,iCh));                        
                        if isnan(meanData)
                            cname  = 'N/A';
                        else
                            cname = sprintf('%s%0.5e', blanks(meanData>=0), meanData);
                        end                        
                        tblcells(iCond, mod(iCh-1, length(measListIdxs))+1) = TableCell(cname, width);
                    end
                end
            end
        end

            
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_HRF(obj, CondNames, iBlk)
            if nargin<3
                iBlk = 1;
            end
            tblcells = TableCell.empty();
            if isa(obj.dcAvg, 'DataClass')
                dataTimeSeries = obj.dcAvg.GetDataTimeSeries();
                measList = obj.dcAvg.measurementList;
                dataTimeSeries = obj.dcAvg(iBlk).GetDataTimeSeries();
                measList = obj.dcAvg(iBlk).measurementList;
                
                % Header: stim condition name row
                for iCh = 1:length(measList)
@@ -540,6 +604,8 @@ classdef ProcResultClass < handle
                        tblcells(t+2,iCh) = TableCell(cname, 12);
                    end
                end
            else
                
            end
        end
                
+57 −11
Original line number Diff line number Diff line
@@ -339,15 +339,6 @@ classdef ProcStreamClass < handle
            b = obj.output.HaveTimeCourseOutput();
        end
                
        
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, filename, CondNames, iBlk)
            if nargin<3
                iBlk = 1;
            end
            obj.output.ExportHRF(filename, CondNames, iBlk);
        end

    end
    
    
@@ -1289,6 +1280,15 @@ classdef ProcStreamClass < handle
            pValues = obj.output.GetVar('pValues',iBlk);
        end
    
        
        % ----------------------------------------------------------------------------------
        function n = GetNumChForOneCondition(obj, iBlk)
            if nargin<2
                iBlk = 1;
            end            
            n = obj.output.GetNumChForOneCondition(iBlk);
        end
        
    end
    
    
@@ -1455,5 +1455,51 @@ classdef ProcStreamClass < handle
        
    end

    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Export related methods
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    methods        
        
        % ----------------------------------------------------------------------------------
        function [tblcells, maxwidth] = GenerateTableCellsHeader_MeanHRF(obj, iBlk)
            if nargin<2
                iBlk = 1;
            end
            [tblcells, maxwidth] = obj.output.GenerateTableCellsHeader_MeanHRF(iBlk);
        end
        
        
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_MeanHRF(obj, name, CondNames, width, iBlk)
            if nargin<4
                width = 12;
            end
            if nargin<5
                iBlk = 1;
            end
            tblcells = obj.output.GenerateTableCells_MeanHRF(name, CondNames, width, iBlk);
        end

            
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_HRF(obj, CondNames, iBlk)
            if nargin<3
                iBlk = 1;
            end
            tblcells = obj.output.GenerateTableCells_HRF(name, CondNames, iBlk);
        end
                
        
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, filename, CondNames, iBlk)
            if nargin<3
                iBlk = 1;
            end
            obj.output.ExportHRF(filename, CondNames, iBlk);
        end
        
    end
    
end
+23 −0
Original line number Diff line number Diff line
@@ -425,6 +425,29 @@ classdef SubjClass < TreeNodeClass
        end

        
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCells_MeanHRF(obj, width, iBlk)
            if nargin<2
                width = 12;
            end
            if nargin<3
                iBlk = 1;
            end
            tblcells = obj.procStream.GenerateTableCells_MeanHRF(obj.name, obj.CondNames, width, iBlk);
        end
        
        
        % ----------------------------------------------------------------------------------
        function tblcells = GenerateTableCellsHeader_MeanHRF(obj, widthCond, widthSubj)
            tblcells = repmat(TableCell(), length(obj.CondNames), 2);
            for iCond = 1:length(obj.CondNames)
                % First 2 columns contain condition name and group, subject or run name
                tblcells(iCond, 1) = TableCell(obj.CondNames{iCond}, widthCond);
                tblcells(iCond, 2) = TableCell(obj.name, widthSubj);
            end
        end
        
        
        % ----------------------------------------------------------------------------------
        function ExportHRF(obj, options, iBlk)
            if nargin<2 || isempty(options)
Loading