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

Merge pull request #10 from jayd1860/master

Merge in changes implementing distributed saving/loading or derived and acquired data as well as various bug fixes loading data.  
parents 54fafe7c 4e3df0b6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -15,9 +15,12 @@ SNIRF
On

% Last Checked For Update
12-Mar-1998 17:03:23
30-Jun-2020 10:48:25

% Check For Updates
on

% Data Storage Scheme
disk

% END
+32 −8
Original line number Diff line number Diff line
@@ -69,6 +69,30 @@ classdef AcqDataClass < matlab.mixin.Copyable
    
    methods
        
        % -------------------------------------------------------
        function b = Error(obj)
            if obj.err<0
                b = true;
            elseif obj.err==0
                b = false;
            else
                b = true;
            end
        end
        
        
        % -------------------------------------------------------
        function FreeMemory(obj, filename)
            if ~exist('filename','var')
                filename = '';
            end
            if isempty(filename)
                return;
            end            
            obj.Initialize();
        end
        
        
        % ---------------------------------------------------------
        function bbox = GetSdgBbox(obj)
            optpos = [obj.GetSrcPos(); obj.GetDetPos()];
+2 −2
Original line number Diff line number Diff line
@@ -39,11 +39,11 @@ classdef FileLoadSaveClass < matlab.mixin.Copyable
            switch(lower(format))
                case obj.supportedFomats.matlab
                    if ismethod(obj, 'LoadMat')
                        obj.LoadMat(filename);
                        obj.err = obj.LoadMat(filename);
                    end
                case obj.supportedFomats.hdf5
                    if ismethod(obj, 'LoadHdf5')
                        obj.LoadHdf5(filename, params);
                        obj.err = obj.LoadHdf5(filename, params);
                    end
            end
        end
+48 −11
Original line number Diff line number Diff line
@@ -46,12 +46,7 @@ classdef NirsClass < AcqDataClass & FileLoadSaveClass
            %
            
            % Initialize Nirs public properties
            obj.SD        = struct([]);
            obj.t         = [];
            obj.s         = [];
            obj.d         = [];
            obj.aux       = [];
            obj.CondNames = {};
            obj.Initialize();

            % Set base class properties not part of NIRS format 
            obj.filename  = '';
@@ -75,6 +70,17 @@ classdef NirsClass < AcqDataClass & FileLoadSaveClass
        end
        
        
        % -------------------------------------------------------
        function Initialize(obj)
            obj.SD        = struct([]);
            obj.t         = [];
            obj.s         = [];
            obj.d         = [];
            obj.aux       = [];
            obj.CondNames = {};
        end
        
        
        % ---------------------------------------------------------
        function SortStims(obj)
            [~,idx] = sort(obj.CondNames);
@@ -98,36 +104,67 @@ classdef NirsClass < AcqDataClass & FileLoadSaveClass
            else
                fname = obj.filename;
            end
            if isempty(fname)
            if exist(fname, 'file') ~= 2
               err = -1;
               return;
            end
            
            % Don't reload if not empty
            if ~obj.IsEmpty()
               return;
            end                        
                        
            warning('off', 'MATLAB:load:variableNotFound');
            fdata = load(fname,'-mat', 'SD','t','d','s','aux','CondNames');
            
            % Mandatory fields
            if isproperty(fdata,'d')
                obj.d = fdata.d;
                if isempty(obj.d)
                    err = -2;
                end
            else
                err = -2;
            end
            if isproperty(fdata,'t')
                obj.t = fdata.t;
                if ~isempty(obj.t)
                    obj.errmargin = min(diff(obj.t))/10;
                else
                    err = -3;                
                end
            else
                err = -3;
            end
            if isproperty(fdata,'SD')
                obj.SetSD(fdata.SD);
                if isempty(obj.SD)
                    err = -4;
                end
            else
                err = -4;
            end
            
            
            % Optional fields
            if isproperty(fdata,'s')
                obj.s = fdata.s;
            else
                obj.s = [];
            end
            if isproperty(fdata,'aux')
                obj.aux = fdata.aux;
            else
                obj.aux = [];
            end
            if isproperty(fdata,'CondNames')
                obj.CondNames = fdata.CondNames;
            else
                obj.InitCondNames();
            end
            if ~isempty(obj.t)
                obj.errmargin = min(diff(obj.t))/10;
            end
            
            % Always sort stimulus conditions and associated stims 
            % to have a predictable order for display
            obj.SortStims();
        end
        
+8 −2
Original line number Diff line number Diff line
@@ -221,7 +221,10 @@ classdef DataClass < FileLoadSaveClass
        
        % ---------------------------------------------------------
        function ml = GetMeasList(obj)
            ml = [];
            % Preallocate for speed 
            ml = ones(length(obj.measurementList), 4);
            
            % Convert obj.measurementList to matrix
            for ii = 1:length(obj.measurementList)
                % If this data contains block average then only get the measurements for first condition. That will
                % contain all the measurement channels
@@ -230,6 +233,9 @@ classdef DataClass < FileLoadSaveClass
                end
                ml(ii,:) = [obj.measurementList(ii).GetSourceIndex(), obj.measurementList(ii).GetDetectorIndex(), 1, obj.measurementList(ii).GetWavelengthIndex()];
            end
            
            % Remove any unused allocated rows that were pre-allocated
            ml(ii+1:end,:) = [];
        end
        
        
Loading