Commit ff12f1d5 authored by jayd1860's avatar jayd1860
Browse files

v1.18.5

-- Speed up MemoryRequired calculation by doing an estimate using first run, subject and group and multiplying by the number of each rather than traversing the whole dataTree and adding up memory required for all tree nodes. This requires only a constant short time to calculate memory required for 3 tree nodes no matter how large the data set is.

-- Add functionality to DataTreeClass.Save() method to save all groups to their own separate groupResults.mat.

-- Fix incorrect RunClass.MemoryRequired() calculation which wasn't add procStream memory.
parent 9d7e1f8c
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ classdef DataTreeClass < handle
            % dc and dod for each new current element (currElem) on the
            % fly. This should be a menu option in future releases
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % obj.logger.Write(sprintf('Memory required for data tree: %0.1f MB\n', obj.groups(ii).MemoryRequired() / 1e6));
            % obj.logger.Write(sprintf('Memory required for data tree: %0.1f MB\n', obj.MemoryRequired() / 1e6));
        end
        
        
@@ -314,12 +314,30 @@ classdef DataTreeClass < handle
        end


        % ----------------------------------------------------------------------------------
        function nbytes = MemoryRequired(obj, option)
            if ~exist('option','var')
                option = 'memory';
            end
            if isempty(obj)
                return;
            end
            nbytes = length(obj.groups) * obj.groups(1).MemoryRequired(option);
        end
        
        
        % ----------------------------------------------------------
        function Save(obj, hwait)
            if ~exist('hwait','var')
                hwait = [];
            end
            obj.groups(obj.currElem.iGroup).Save(hwait);
            
            t_local = tic;
            for ii = 1:length(obj.groups)
                obj.logger.Write(sprintf('Saving group %d in %s\n', ii, [obj.groups(ii).pathOutput, 'groupResults.mat']));
                obj.groups(ii).Save(hwait);
            end
            obj.logger.Write(sprintf('Completed saving groupResults.mat for all groups in %0.3f seconds.\n', toc(t_local)));
        end


+4 −25
Original line number Diff line number Diff line
@@ -265,29 +265,10 @@ classdef GroupClass < TreeNodeClass
            if ~exist('option','var')
                option = 'memory';
            end
            if strcmp(option, 'memory')
                nbytes = obj.spaceRequired.memory;
            else
                nbytes = obj.spaceRequired.disk;
            end
            if nbytes > 0
                return
            end
            if isempty(obj)
                return;
            end
            nbytes = obj.procStream.MemoryRequired();
            for ii=1:length(obj.subjs)
                nbytes = nbytes + obj.subjs(ii).MemoryRequired(option);
            end
            if nbytes > 5e8
                obj.spacesaver = true;
            end
            if strcmp(option, 'memory')
                obj.spaceRequired.memory = nbytes; 
            else
                obj.spaceRequired.disk = nbytes; 
            end
            nbytes = obj.procStream.MemoryRequired() + length(obj.subjs) * obj.subjs(1).MemoryRequired(option);
            end


@@ -616,14 +597,14 @@ classdef GroupClass < TreeNodeClass
        % ----------------------------------------------------------------------------------
        function [diskspaceToSpare, diskspacePercentRemaining] = CheckAvailableDiskSpace(obj, hwait)
            if ishandle(hwait)
                obj.logger.Write(sprintf('Calculating disk space required to save processing results ...\n'), obj.logger.ProgressBar(), hwait);
                obj.logger.Write(sprintf('Estimating disk space required to save processing results ...\n'), obj.logger.ProgressBar(), hwait);
            end
            diskspaceToSpare = (getFreeDiskSpace() - obj.MemoryRequired('disk'));   % Disk space to spare in megabytes
            diskspacePercentRemaining = 100 * diskspaceToSpare/obj.MemoryRequired('disk');
            msg = {};
            obj.logger.Write(sprintf('CheckAvailableDiskSpace:    disk space available = %0.1f MB,    disk space required = %0.1f MB\n', getFreeDiskSpace()/1e6, obj.MemoryRequired('disk')/1e6));
            obj.logger.Write(sprintf('CheckAvailableDiskSpace:    disk space available = %0.1f MB,    disk space required estimate = %0.1f MB\n', getFreeDiskSpace()/1e6, obj.MemoryRequired('disk')/1e6));
            if diskspaceToSpare < 0
                msg{1} = sprintf('ERROR: Cannot save processing results requiring %0.1f MB of disk space on current drive with only %0.1f MB of free space available.\n', ...
                msg{1} = sprintf('ERROR: Cannot save processing results requiring ~%0.1f MB of disk space on current drive with only %0.1f MB of free space available.\n', ...
                                  obj.MemoryRequired('disk')/1e6, getFreeDiskSpace()/1e6);
            elseif diskspacePercentRemaining < 200
                msg{1} = sprintf('WARNING: Available disk space on the current drive is low (%0.1f MB). This may cause problems saving processing results in the future.', ...
@@ -645,7 +626,6 @@ classdef GroupClass < TreeNodeClass
            end            
            
            obj.logger.Write(sprintf('Saving processed data in %s\n', [obj.path, 'groupResults.mat']));
            t_local = tic;
                       
            % Check that there is anough disk space 
            while CheckAvailableDiskSpace(obj, hwait) < 0
@@ -672,7 +652,6 @@ classdef GroupClass < TreeNodeClass
                MessageBox(ME.message);
                obj.logger.Write(ME.message);
            end            
            obj.logger.Write(sprintf('Completed saving groupResults.mat in %0.3f seconds.\n', toc(t_local)));
        end
        
        
+1 −1
Original line number Diff line number Diff line
@@ -644,7 +644,7 @@ classdef RunClass < TreeNodeClass
            if isempty(obj.acquired)
                return
            end
            nbytes = obj.acquired.MemoryRequired();
            nbytes = nbytes + obj.acquired.MemoryRequired();
        end
    
    
+2 −5
Original line number Diff line number Diff line
@@ -417,12 +417,9 @@ classdef SubjClass < TreeNodeClass
        % ----------------------------------------------------------------------------------        
        function nbytes = MemoryRequired(obj, option)
            if ~exist('option','var')
                option = 'memory';
            end
            nbytes = obj.procStream.MemoryRequired();
            for ii=1:length(obj.runs)
                nbytes = nbytes + obj.runs(ii).MemoryRequired(option);
                option = 'disk';
            end
            nbytes = obj.procStream.MemoryRequired() + length(obj.runs) * obj.runs(1).MemoryRequired(option);
        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} = '18';  % Major sub-version #
vrnnum{3} = '4';   % Minor version #
vrnnum{3} = '5';   % Minor version #
vrnnum{4} = '0';   % Minor sub-version # or patch #: 'p1', 'p2', etc