Unverified Commit 771c5dd7 authored by jayd1860's avatar jayd1860 Committed by GitHub
Browse files

Add session level proc stream user functions to fix tcca issues (#133)

* v1.37.1

-- Add session layer user functions for averaging run derived data.

* v1.37.2

-- Add session layer user functions and change name of subject level averaging functions to reflect session averages rather than run averages.
-- Change the way processing config files treat missing or obsolete sections by replacing them the default sections rather than replacing the whole file with a default processOpt_default.cfg
-- Add callback functions to session panel in ProcStreamEditGUI.fig
-- Change unit test proc stream config files to use new session level user functions

* v1.37.3

-- Fix error in exporting HRF when there is no HRF generated.
-- Change export mean hrf to to work for all processing levels not just all subjects.

* v1.37.4

-- Redo Export HRF mean to be more like Export HRF instead of combining all child Export HRF mean in a single export file.
-- Keep old Export HRF mean functionality and select either old or new with new config parameter "Export HRF Mean Output Style". The 2 values are    {old: all child processing elements in one file  |  new: one processing element per file}

* v1.37.5

-- Fix issue where stim conditions with no stimuli were not being saved to file when calling SnirfClass.Save()
-- Add functionality and config parameter "Export Processing Stream Functions" for saving processing stream function call chain that produced the derived result including a processing stream summary (this part is unfinished).

* v1.37.6

-- Fix issue of stim reordering from the original order in acquisition files
-- Fix type causing bug when loading initial processing stream
-- Clean up StimEditGUI.fig look, and warnings in code
-- Add FindProcElem method to DataTreeClass and TreeNodeClass to find any TreeNodeClass object by name and return its index.
-- Added copying of children reference in TreeNodeClass.Copy. This is important when creating a copy of a DataTreeClass or TreeNodeClass objects

* v1.38.0

-- Fix CondNames not being saved to groupResults.mat.
-- Fix matlab generated error selecting menu item File --> Save Groups

* v1.38.1

-- Add export capability of function call summary that generated current derived results and config param "Export Processing Stream Functions"
-- Set default value of "Export Processing Stream Functions" to "No"

* v1.38.2

-- Fix bug Meryem found when first condition has no stims the averaging at the subject and group levels doesn't work for the other conditions that do have stims. Fix is to have session averaging pass only total number of trials for each condition instead of what subject level processing does which is pass per/channel total trials.

* v1.38.2

-- Fix broken Copy Plots feature which dumps plots to separate figure
parent f8d5e28d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -7,4 +7,8 @@ on
% Stim Edit GUI Save Warnings # don't ask again, ask every time
% Stim Edit GUI Save Warnings # don't ask again, ask every time
don't ask again
don't ask again


% Export HRF Mean Output Style # all child processing elements in one file, one processing element per file
one processing element per file


% END
% END
+5 −3
Original line number Original line Diff line number Diff line
@@ -296,9 +296,6 @@ classdef NirsClass < AcqDataClass & FileLoadSaveClass
                obj.InitCondNames();
                obj.InitCondNames();
            end
            end
            
            
            % Always sort stimulus conditions and associated stims
            % to have a predictable order for display
            obj.SortStims();
        end
        end
        
        
        
        
@@ -468,7 +465,12 @@ classdef NirsClass < AcqDataClass & FileLoadSaveClass
            
            
            % Copy mutable properties to new object instance;
            % Copy mutable properties to new object instance;
            objnew.SD         = obj.SD;
            objnew.SD         = obj.SD;

            % Always sort stimulus conditions and associated stims
            % to have a predictable order for display
            objnew.s          = obj.s;
            objnew.s          = obj.s;
            obj.SortStims();
            
            objnew.CondNames  = obj.CondNames;
            objnew.CondNames  = obj.CondNames;
        end
        end
        
        
+5 −7
Original line number Original line Diff line number Diff line
@@ -327,6 +327,7 @@ classdef SnirfClass < AcqDataClass & FileLoadSaveClass
            
            
            % Copy mutable properties to new object instance;
            % Copy mutable properties to new object instance;
            objnew.stim = CopyHandles(obj.stim);
            objnew.stim = CopyHandles(obj.stim);
            objnew.SortStims();
            
            
            if strcmp(options, 'extended')
            if strcmp(options, 'extended')
                t = obj.GetTimeCombined();
                t = obj.GetTimeCombined();
@@ -457,7 +458,6 @@ classdef SnirfClass < AcqDataClass & FileLoadSaveClass
                end
                end
                ii=ii+1;
                ii=ii+1;
            end
            end
            obj.SortStims();
            
            
            % Load original, unedited stims, if they exist
            % Load original, unedited stims, if they exist
            ii=1;
            ii=1;
@@ -635,10 +635,8 @@ classdef SnirfClass < AcqDataClass & FileLoadSaveClass
        % -------------------------------------------------------
        % -------------------------------------------------------
        function SaveStim(obj, fileobj)
        function SaveStim(obj, fileobj)
            for ii = 1:length(obj.stim)
            for ii = 1:length(obj.stim)
                if ~isempty(obj.stim(ii).data)  % Do not save empty stim conditions to SNIRF files
                obj.stim(ii).SaveHdf5(fileobj, [obj.location, '/stim', num2str(ii)]);
                obj.stim(ii).SaveHdf5(fileobj, [obj.location, '/stim', num2str(ii)]);
            end
            end
            end
            if isempty(obj.stim0)
            if isempty(obj.stim0)
                obj.stim0 = obj.stim.copy();
                obj.stim0 = obj.stim.copy();
                for ii = 1:length(obj.stim0)
                for ii = 1:length(obj.stim0)
+3 −0
Original line number Original line Diff line number Diff line
@@ -28,4 +28,7 @@ No
% Default Processing Stream Style # SNIRF, NIRS
% Default Processing Stream Style # SNIRF, NIRS
SNIRF
SNIRF


% Export Processing Stream Functions # Yes, No
No

% END
% END
+59 −12
Original line number Original line Diff line number Diff line
@@ -282,11 +282,25 @@ classdef DataTreeClass < handle
                end
                end
                
                
            end
            end
            
            obj.PrintProcStream();
            
            obj.logger.Write('Loaded data set in %0.1f seconds\n', toc(t1));
            obj.logger.Write('Loaded data set in %0.1f seconds\n', toc(t1));
        end
        end
        
        
        
        


        % ---------------------------------------------------------------
        function PrintProcStream(obj)
            obj.logger.Write('\n');
            obj.logger.Write('============================================\n\n');
            obj.groups(1).PrintProcStream();
            obj.logger.Write('============================================\n');
            obj.logger.Write('\n');
        end
        
            
            
        % ---------------------------------------------------------------
        % ---------------------------------------------------------------
        function SetDataStorageScheme(obj)
        function SetDataStorageScheme(obj)


@@ -345,6 +359,11 @@ classdef DataTreeClass < handle
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            obj.ErrorCheckLoadedFiles();
            obj.ErrorCheckLoadedFiles();


            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % Generate the stimulus conditions for the group tree
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            obj.groups(iGroup).SetConditions();

            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % Load derived or post-acquisition data from a file if it
            % Load derived or post-acquisition data from a file if it
            % exists
            % exists
@@ -358,11 +377,6 @@ classdef DataTreeClass < handle
            	obj.groups(iGroup).InitProcStream(procStreamCfgFile);
            	obj.groups(iGroup).InitProcStream(procStreamCfgFile);
            end
            end
            
            
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % Generate the stimulus conditions for the group tree
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            obj.groups(iGroup).SetConditions();

        end
        end
        
        
        
        
@@ -451,6 +465,33 @@ classdef DataTreeClass < handle
        end
        end


        
        
        % ----------------------------------------------------------
        function idx = FindProcElem(obj, name)
            idx = [];
            for ii = 1:length(obj.groups)
                if strcmp(name, obj.groups(ii).GetName())
                    idx = obj.groups(ii).GetIndexID();
                    break;
                end
                if strcmp(name, obj.groups(ii).GetFilename())
                    idx = obj.groups(ii).GetIndexID();
                    break;
                end
                idx = obj.groups(ii).FindProcElem(name);
                if ~isempty(idx)
                    break;
                end
            end
        end
        
        
        % ----------------------------------------------------------
        function CondNames = GetConditions(obj)
             iG = obj.GetCurrElem().iGroup;
             CondNames = obj.groups(iG).GetConditions();
        end
        
        
        % ----------------------------------------------------------
        % ----------------------------------------------------------
        function ErrorCheckLoadedFiles(obj)
        function ErrorCheckLoadedFiles(obj)
            if isempty(obj.filesErr)
            if isempty(obj.filesErr)
@@ -595,10 +636,6 @@ classdef DataTreeClass < handle
        
        
        % ----------------------------------------------------------
        % ----------------------------------------------------------
        function Save(obj, hwait)           
        function Save(obj, hwait)           
            if ~exist('hwait','var')
                hwait = [];
            end
            
            % Check that there is anough disk space. NOTE: for now we
            % Check that there is anough disk space. NOTE: for now we
            % assume that all groups are on the same drive. This should be 
            % assume that all groups are on the same drive. This should be 
            % changed but for now we simplify. 
            % changed but for now we simplify. 
@@ -606,18 +643,28 @@ classdef DataTreeClass < handle
                return;
                return;
            end
            end
            
            
            if nargin==1
                hwait = waitbar_improved(0,  'Saving groups. Please wait ...');
            end
            
            t1 = tic;
            t1 = tic;
            for ii = 1:length(obj.groups)
            for ii = 1:length(obj.groups)
                obj.logger.Write('Saving group %d in %s\n', ii, [obj.groups(ii).pathOutputAlt, obj.groups(ii).GetFilename()]);
                obj.logger.Write('Saving group %d in %s\n', ii, [obj.groups(ii).pathOutputAlt, obj.groups(ii).GetFilename()]);
                obj.groups(ii).Save(hwait);
                obj.groups(ii).Save(hwait);
            end
            end
            obj.logger.Write('Completed saving processing results for all groups in %0.3f seconds.\n', toc(t1));
            obj.logger.Write('Completed saving processing results for all groups in %0.3f seconds.\n', toc(t1));
            
            if nargin==1
                close(hwait);
            end
        end
        end




        % ----------------------------------------------------------
        % ----------------------------------------------------------
        function CalcCurrElem(obj)
        function CalcCurrElem(obj)
            obj.currElem.ExportProcStreamFunctionsOpen();
            obj.currElem.Calc();
            obj.currElem.Calc();
            obj.currElem.ExportProcStreamFunctionsClose();
        end
        end


        
        
@@ -686,7 +733,7 @@ classdef DataTreeClass < handle
            if nfolders==0
            if nfolders==0
                nfolders = 1;
                nfolders = 1;
            end
            end
            numFilesMsg = sprintf('with %d data files in %d folders\n', dataInit.nfiles, nfolders);
            numFilesMsg = sprintf('%d data files in %d folders\n', dataInit.nfiles, nfolders);
            obj.logger.Write('\n');
            obj.logger.Write('\n');
            if dataInit.nfiles == 0
            if dataInit.nfiles == 0
                obj.logger.Write('DataTreeClass.PrintDatasetFormat:   Did not find any data0 files %s.\n', numFilesMsg);
                obj.logger.Write('DataTreeClass.PrintDatasetFormat:   Did not find any data0 files %s.\n', numFilesMsg);
Loading