Commit c4126bb7 authored by jayd1860's avatar jayd1860
Browse files

v1.34.1

-- Fix Stim saving not working properly because of HDF5's not allowing to overwrite string data. Instead of saving only stim, have to save whole file.
-- Add LoadTime method to DataTree to fix bug related to incorrectly displaying active conditions in MainGUI (to reproduce have first run in subject not have all conditions while the rest of the runs have all conditions and for condition that first runs doesn't have the subject display of conditions in MainGUI will also think the condition is not active when selecting it in the listbox even though other runs have that condition so on the subject level it should be active).
parent 1f599d14
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -185,6 +185,13 @@ classdef NirsClass < AcqDataClass & FileLoadSaveClass
        
        % ---------------------------------------------------------
        function err = LoadTime(obj, fdata, err)
            if nargin == 1
                fdata.t = load(obj.GetFilename(),'-mat', 't');
                err = 0;
            elseif nargin == 2
                err = 0;                
            end
            
            if isproperty(fdata,'t')
                obj.t = fdata.t;
                if ~isempty(obj.t)
+56 −1
Original line number Diff line number Diff line
@@ -164,6 +164,50 @@ classdef DataClass < FileLoadSaveClass
        end
        
        
        % -------------------------------------------------------
        function err = LoadTime(obj, fileobj, location)
            err = 0;
                       
            % Arg 1
            if ~exist('fileobj','var') || (ischar(fileobj) && ~exist(fileobj,'file'))
                fileobj = '';
            end
                      
            % Arg 2
            if ~exist('location', 'var') || isempty(location)
                location = '/nirs/data1';
            elseif location(1)~='/'
                location = ['/',location];
            end
                      
            % Error checking            
            if ~isempty(fileobj) && ischar(fileobj)
                obj.SetFilename(fileobj);
            elseif isempty(fileobj)
                fileobj = obj.GetFilename();
            end
            if isempty(fileobj)
               err = -1;
               return;
            end
            
            
            try
                % Open group
                [gid, fid] = HDF5_GroupOpen(fileobj, location);
                
                obj.time = HDF5_DatasetLoad(gid, 'time');
                                   
                % Close group
                HDF5_GroupClose(fileobj, gid, fid);
            catch ME
                err = -1;
            end
            
            err = ErrorCheck(obj, err, {'time'});
        end
        
        
        % -------------------------------------------------------
        function SaveHdf5(obj, fileobj, location)
            if ~exist('fileobj', 'var') || isempty(fileobj)
@@ -207,7 +251,11 @@ classdef DataClass < FileLoadSaveClass
        
        
        % ----------------------------------------------------------------------
        function err = ErrorCheck(obj, err)
        function err = ErrorCheck(obj, err, params)
            if ~exist('params','var')
                params = propnames(obj);
            end
            if ismember('dataTimeSeries',params)
            if obj.IsEmpty()
                err = -1;
            end
@@ -218,6 +266,12 @@ classdef DataClass < FileLoadSaveClass
                err = -1;
            end
        end
            if ismember('time',params)
                if isempty(obj.time)
                    err = -1;
                end
            end
        end
        
    end
    
@@ -302,6 +356,7 @@ classdef DataClass < FileLoadSaveClass
        
        % ---------------------------------------------------------
        function t = GetTime(obj)
            
            t = obj.time;
        end
        
+4 −8
Original line number Diff line number Diff line
@@ -227,15 +227,11 @@ classdef ProbeClass < FileLoadSaveClass
            end     
            hdf5write_safe(fileobj, [location, '/wavelengths'], obj.wavelengths);
            hdf5write_safe(fileobj, [location, '/wavelengthsEmission'], obj.wavelengthsEmission);
            if ~isempty(obj.sourcePos2D)
            hdf5write_safe(fileobj, [location, '/sourcePos2D'], obj.sourcePos2D(:,1:2), 'rw:2D');
            hdf5write_safe(fileobj, [location, '/detectorPos2D'], obj.detectorPos2D(:,1:2), 'rw:2D');
            end
            hdf5write_safe(fileobj, [location, '/landmarkPos2D'], obj.landmarkPos2D, 'rw:2D');
            if ~isempty(obj.sourcePos3D)
            hdf5write_safe(fileobj, [location, '/sourcePos3D'], obj.sourcePos3D, 'rw:3D');
            hdf5write_safe(fileobj, [location, '/detectorPos3D'], obj.detectorPos3D, 'rw:3D');
            end
            hdf5write_safe(fileobj, [location, '/landmarkPos3D'], obj.landmarkPos3D, 'rw:3D');
            hdf5write_safe(fileobj, [location, '/frequencies'], obj.frequencies);
            hdf5write_safe(fileobj, [location, '/timeDelays'], obj.timeDelays);
+13 −3
Original line number Diff line number Diff line
@@ -387,6 +387,17 @@ classdef SnirfClass < AcqDataClass & FileLoadSaveClass
        
        
        
        % -------------------------------------------------------
        function err = LoadTime(obj)
            err = 0;
            if isempty(obj.data)
                obj.data = DataClass();
                err = obj.data.LoadTime(obj.GetFilename(), [obj.location, '/data1']);
            end
        end
        
        
        
        % -------------------------------------------------------
        function err = LoadData(obj, fileobj)
            err = 0;
@@ -671,8 +682,7 @@ classdef SnirfClass < AcqDataClass & FileLoadSaveClass
            flags = zeros(length(obj.stim), 1);
            
            % Load stim from file and update it
            snirfFile = SnirfClass();
            snirfFile.LoadStim(fileobj);
            snirfFile = SnirfClass(fileobj);
            
            % Update stims from file with edited stims
            for ii = 1:length(obj.stim)
@@ -697,7 +707,7 @@ classdef SnirfClass < AcqDataClass & FileLoadSaveClass
            % If stims were edited then update snirf file with new stims
            changes = sum(flags);
            if changes > 0
                snirfFile.SaveStim(fileobj);
                snirfFile.Save();
            end
            stimFromFile = snirfFile.stim;
        end
+6 −2
Original line number Diff line number Diff line
@@ -768,7 +768,7 @@ classdef GroupClass < TreeNodeClass
            
            % Create ExportTable initialized with the filled in 2D TableCell array. 
            % ExportTable object is what actually does the exporting to a file. 
            ExportTable(obj.name, 'HRF mean', tblcells);
            ExportTable([obj.path, obj.outputDirname, obj.name], 'HRF mean', tblcells);
        end
        
        
@@ -1061,7 +1061,11 @@ classdef GroupClass < TreeNodeClass
        % ----------------------------------------------------------------------------------
        function BackwardCompatability(obj)
            if ispathvalid([obj.path, 'groupResults.mat'])
                try
                    g = load([obj.path, 'groupResults.mat']);
                catch ME
                    g = [];
                end
                
                % Do not try to restore old data older than Homer3
                if isempty(g)
Loading