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

v1.35.11 - Clearly display in MainGUI and DataTree the data files that were...

v1.35.11 - Clearly display in MainGUI and DataTree the data files that were NOT loaded because of errors (#128)

* v1.35.8

-- Clearly display in MainGUI and DataTree the data files that were NOT loaded because of errors and more clearly display in the logging the ones that were loaded and the ones. In MainGUI display data files NOT loaded in separate listbox window with red font. Clicking on any one of the error files displays error that kept it from loading.

-- Replace version number display for shared libraries with last revision date/time.

-- Improve and clean up code in syncSubmodules tool:
   a) Use last revision date/time instead of version number to sync shared libs.
   b) Warn user of uncommitted changes when syncing files in syncSubmodules.m
   c) Do a general code clean up

* v1.35.9

-- Get rid of version numbers and version files from shared libraries. Instead generate last rev date on the fly and display that (this only applies to git repos, for unzipped code just display lib name).

* v1.35.10

-- Fix error loading SNIRF aux.name field in AuxClass because of changes to MATLAB's HDF5 library. (It seems for string there is no need to transpose the data.)

* v1.35.11

-- Fix minor display issue on MAC where the file search window does NOT display title showing the purpose of the window ("Load Processing Options File"). Use alternative file search GUI (only on MAC) which displays Window title and allows user to select *.cfg file.
parent 247a02c7
Loading
Loading
Loading
Loading
+48 −5
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@ classdef DataFilesClass < handle
    
    
    properties
    properties
        files;
        files;
        filesErr;
        filetype;
        filetype;
        dirFormats;
        dirFormats;
        err;
        err;
@@ -21,6 +22,7 @@ classdef DataFilesClass < handle
        % ----------------------------------------------------
        % ----------------------------------------------------
        function obj = DataFilesClass(varargin)            
        function obj = DataFilesClass(varargin)            
            obj.files = FileClass.empty();
            obj.files = FileClass.empty();
            obj.filesErr = FileClass.empty();
            obj.filetype = '';
            obj.filetype = '';
            obj.rootdir = pwd;
            obj.rootdir = pwd;
            obj.nfiles = 0;
            obj.nfiles = 0;
@@ -116,15 +118,15 @@ classdef DataFilesClass < handle
                obj.InitLookupTable();
                obj.InitLookupTable();
                obj.FindDataSet(ii);
                obj.FindDataSet(ii);
                
                
                % Remove any files that cannot pass the basic test of loading
                % its data
                obj.ErrorCheck();
                obj.ErrorCheck();
                if ~isempty(obj.files)
                if ~isempty(obj.files)
                    break
                    break
                end
                end
            end
            end
            
            
            % Remove any files that cannot pass the basic test of loading
            obj.ErrorCheckFinal();
            % its data
            obj.ErrorCheckName();
        end
        end


        
        
@@ -290,6 +292,41 @@ classdef DataFilesClass < handle
        
        
        
        
        
        
        % ----------------------------------------------------
        function ErrorCheckFinal(obj)
            obj.ErrorCheckName();
            
            % Find all acquisition files in group folder
            fileNames = findTypeFiles(obj.rootdir, ['.', obj.filetype]);
            
            % Make alist of all files excluded from current data set  
            for ii = 1:length(fileNames)
                filefound = false;
                
                for jj = 1:length(obj.files)
                    if pathscompare(fileNames{ii}, [obj.rootdir, obj.files(jj).name])
                        filefound = true;
                        break;
                    end
                end
                
                for jj = 1:length(obj.filesErr)
                    if pathscompare(fileNames{ii}, [obj.rootdir, obj.filesErr(jj).name])
                        filefound = true;
                        break;
                    end
                end
                
                if ~filefound
                    obj.filesErr(end+1) = FileClass(fileNames{ii});
                    obj.filesErr(end).SetError('Invalid File Name');
                end
            end
        
        end
        
        
        
        % --------------------------------------------------------------------------
        % --------------------------------------------------------------------------
        function answer = AskToFixNameConflicts(obj, ii)
        function answer = AskToFixNameConflicts(obj, ii)
            global cfg
            global cfg
@@ -426,7 +463,7 @@ classdef DataFilesClass < handle
                filename = [obj.files(ii).rootdir, obj.files(ii).name];
                filename = [obj.files(ii).rootdir, obj.files(ii).name];
                eval( sprintf('o = %s(filename);', constructor) );
                eval( sprintf('o = %s(filename);', constructor) );
                if o.GetError()<0
                if o.GetError()<0
                    obj.logger.Write('FAILED error check:   %s will not be added to data set\n', filename);
                    obj.logger.Write('DataFilesClass.ErrorCheck:   FAILED error check - %s will not be added to data set\n', filename);
                    errorIdxs = [errorIdxs, ii]; %#ok<AGROW>
                    errorIdxs = [errorIdxs, ii]; %#ok<AGROW>
                else
                else
                    dataflag = true;
                    dataflag = true;
@@ -435,7 +472,12 @@ classdef DataFilesClass < handle
            if dataflag==false
            if dataflag==false
                obj.files = FileClass.empty();
                obj.files = FileClass.empty();
            else
            else
                for jj = 1:length(errorIdxs)
                    obj.filesErr(end+1) = obj.files(errorIdxs(jj)).copy;
                    obj.filesErr(end).SetError('Invalid Data Format');
                end
            	obj.files(errorIdxs) = [];
            	obj.files(errorIdxs) = [];
                obj.nfiles = obj.nfiles - length(errorIdxs);
            end
            end
        end
        end
        
        
@@ -518,5 +560,6 @@ classdef DataFilesClass < handle
            b = obj.lookupTable(string2hash(str, n));
            b = obj.lookupTable(string2hash(str, n));
        end
        end
        
        
        
    end
    end
end
end
+18 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ classdef FileClass < matlab.mixin.Copyable
        rootdir
        rootdir
        err
        err
        logger
        logger
        errmsgs
    end
    end
    
    
    methods
    methods
@@ -39,6 +40,8 @@ classdef FileClass < matlab.mixin.Copyable
            obj.rootdir    = '';
            obj.rootdir    = '';
            obj.err        = -1;          % Assume file is not loadable
            obj.err        = -1;          % Assume file is not loadable
            obj.logger     = InitLogger(logger);            
            obj.logger     = InitLogger(logger);            
            obj.errmsgs    = {'Invalid Data Format','Invalid File Name'};
            
            
            
            if nargin==0
            if nargin==0
                return;
                return;
@@ -535,6 +538,20 @@ classdef FileClass < matlab.mixin.Copyable
        end
        end
        
        
        
        
        % -----------------------------------------------------
        function err = SetError(obj, err)
            if ischar(err)
                err = find(strcmp(obj.errmsgs, err));
            end
            obj.err = err;
        end
        
        
        % -----------------------------------------------------
        function msg = GetErrorMsg(obj)
            msg = obj.errmsgs{abs(obj.err)};
        end
        
    end
    end
  
  
end
end
 No newline at end of file
+0 −3
Original line number Original line Diff line number Diff line
@@ -68,7 +68,6 @@ while files.IsEmpty()
                if nfolders==0
                if nfolders==0
                    nfolders = 1;
                    nfolders = 1;
                end
                end
                fprintf('FindFiles: Found %d .nirs data files in %d folders\n', filesSrc.nfiles, nfolders);
            end
            end
            
            
            % Search for source acquisition files in .nirs format which have not
            % Search for source acquisition files in .nirs format which have not
@@ -134,8 +133,6 @@ while files.IsEmpty()
        cd(dirnameGroup)
        cd(dirnameGroup)
    end
    end
    
    
    fprintf('FindFiles: Found %d %s data files in %d folders\n', files.nfiles, fmt, length(files.files)-files.nfiles);
    
end
end




+2 −2
Original line number Original line Diff line number Diff line
@@ -9,8 +9,8 @@ end
% with the file format's storage order.
% with the file format's storage order.
if ~isrow(val) && ~iscolumn(val)            % Matrices
if ~isrow(val) && ~iscolumn(val)            % Matrices
    val = permute(val, ndims(val):-1:1);
    val = permute(val, ndims(val):-1:1);
elseif ischar(val)                          % 1D char strings 
% elseif ischar(val)                          % 1D char strings 
    val = permute(val, ndims(val):-1:1);
%     val = permute(val, ndims(val):-1:1);
elseif ~isempty(findstr('multidim', options))   % Force multi-dimensional even if vector
elseif ~isempty(findstr('multidim', options))   % Force multi-dimensional even if vector
    val = permute(val, ndims(val):-1:1);
    val = permute(val, ndims(val):-1:1);
elseif ~isempty(findstr('2D', options))         % Force 2D even if vector
elseif ~isempty(findstr('2D', options))         % Force 2D even if vector
+29 −37
Original line number Original line Diff line number Diff line
@@ -261,15 +261,9 @@ classdef DataTreeClass < handle
                        iter = iter+1;
                        iter = iter+1;
                    end                    
                    end                    
                    obj.files = dataInit.files;
                    obj.files = dataInit.files;
                    obj.filesErr = dataInit.filesErr;


                    obj.logger.Write('\n');
                    obj.PrintDatasetFormat(dataInit);

                    % Print file and folder numbers stats
                    nfolders = length(dataInit.files)-dataInit.nfiles;
                    if nfolders==0
                        nfolders = 1;
                    end
                    obj.logger.Write('DataTreeClass.FindAndLoadGroups: Found %d data files in %d folders\n', dataInit.nfiles, nfolders);
                    
                    
                    % Now load group files to data tree
                    % Now load group files to data tree
                    obj.LoadGroup(iGroupNew, procStreamCfgFile, options);
                    obj.LoadGroup(iGroupNew, procStreamCfgFile, options);
@@ -449,7 +443,7 @@ classdef DataTreeClass < handle
                group.SetIndexID(jj);
                group.SetIndexID(jj);
                obj.groups(jj) = group;
                obj.groups(jj) = group;
                obj.groups(jj).SetPath(obj.dirnameGroups{jj})
                obj.groups(jj).SetPath(obj.dirnameGroups{jj})
                obj.logger.Write('Added group %s to dataTree.\n', obj.groups(jj).GetName);
                obj.logger.Write('Added group  "%s"  to dataTree.\n', obj.groups(jj).GetName);
            end
            end


            % Add subj, sess and run to group
            % Add subj, sess and run to group
@@ -459,12 +453,15 @@ classdef DataTreeClass < handle
        
        
        % ----------------------------------------------------------
        % ----------------------------------------------------------
        function ErrorCheckLoadedFiles(obj)
        function ErrorCheckLoadedFiles(obj)
            for iF=length(obj.files):-1:1
            if isempty(obj.filesErr)
                if ~obj.files(iF).Loadable() && obj.files(iF).IsFile()
                return
                    obj.filesErr(end+1) = obj.files(iF).copy;
                    obj.files(iF) = [];
            end
            end
            obj.logger.Write('\n')
            obj.logger.Write('DataTreeClass.ErrorCheckLoadedFiles:   WARNING - The following files in this data set were NOT loaded:\n')
            for iF = 1:length(obj.filesErr)
                obj.logger.Write('   %s\n', obj.filesErr(iF).name)
            end
            end
            obj.logger.Write('\n')
        end
        end
        
        
        
        
@@ -679,29 +676,24 @@ classdef DataTreeClass < handle
        end
        end


        
        
        % ----------------------------------------------------------
        % -----------------------------------------------------------
        function PrintFolderStructure(obj, options)
        function PrintDatasetFormat(obj, dataInit)
            if ~exist('options','var')
            
                options = '';
            % Print file and folder numbers stats
            nfolders = length(dataInit.files)-dataInit.nfiles;
            if nfolders==0
                nfolders = 1;
            end
            end
            stepsize = 3;
            numFilesMsg = sprintf('with %d data files in %d folders\n', dataInit.nfiles, nfolders);
            obj.logger.Write('\n');
            obj.logger.Write('\n');
            obj.logger.Write('DataTreeClass - Data Set Folder Structure:\n');
            if dataInit.nfiles == 0
            for ii = 1:length(obj.files)
                obj.logger.Write('DataTreeClass.FindAndLoadGroups:   Did not find any data0 files %s.\n', numFilesMsg);
                k = length(find(obj.files(ii).name=='/'));   
            elseif dataInit.dirFormats.type > 3 && dataInit.dirFormats.type < 9
                if ii<10, j=3; elseif ii>9 && ii<100, j=2; else j=3; end %#ok<*SEPEX>
                obj.logger.Write('DataTreeClass.FindAndLoadGroups:   Found BIDS data set %s.\n', numFilesMsg);
                if optionExists(options, 'flat')
            elseif dataInit.dirFormats.type < 4
                    obj.logger.Write('%d.%s%s\n', ii, blanks(j), obj.files(ii).name);
                obj.logger.Write('DataTreeClass.FindAndLoadGroups:   Found non-standard format set %s.\n', numFilesMsg);
                else
            elseif dataInit.dirFormats.type > 8
                    if ii<10, j=3; elseif ii>9 && ii<100, j=2; else j=3; end
                obj.logger.Write('DataTreeClass.FindAndLoadGroups:   Found non-standard but BIDS-like data set %s.\n', numFilesMsg);
                    if optionExists(options, 'numbered')
                        n = k*stepsize+stepsize+j;
                        obj.logger.Write('%d.%s%s\n', ii, blanks(n), obj.files(ii).filename);
                    else
                        n = k*stepsize+stepsize;
                        obj.logger.Write('%s%s\n', blanks(n), obj.files(ii).filename);
                    end
                end
            end
            end
            obj.logger.Write('\n');
            obj.logger.Write('\n');
        end
        end
Loading