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

BIDS support, tCCA fixes, 3D-to-2D probe projection, proc stream...

BIDS support, tCCA fixes, 3D-to-2D probe projection, proc stream saving/loading bugs fixes, GLM ss fix (#137)

* Snirf writing (#117)

* Rewrote SNIRF writing. Deleted functions no longer in use. Refactored Group creation fn

* Changes to snirf writing clients

* fix to checkForHomerUpdates following GetVernum change

* Export current element to SNIRF (#118)

* Bug in StimEditGUI in no stim conditions

* Removed export to script, add export to SNIRF option in File menu

* added *.asv to gitignore

* GetAllData method for proc result class returns non-empty DataClass properties

* GetAllData returns misc contents

* Don't call save on nonexistant Snirf subobjects

* Remove 'SnirfDraft = '3'' from mdt defaults

* ;

* Add GetProbe interface. TODO add warnings. Remove faulty setter.

* ExportSnirfGUI

* Update ExportSnirfGUI.m

* Avoid crash on empty misc

* v1.35.2

-- Fix not finding .snirf files in Rob Luke's dataset   https://github.com/rob-luke/BIDS-NIRS-Tapping  because the file name pattern does not match any of the available options in DataFilesClass. Updated list of BIDS file name patterns to earch for.
-- Fix some bugs in DataFilesClass file search (change name of isempty method to IsEmpty so that there's no overriding of matlab's built in isempty: this caused DataFilesClass object to be mysteriously empty when executing constructor, also AddParentDirs method assigning incorrect name to FileClass member objects)

* -- Fix some bugs in unit test logging - and displaying call stack in case of error

* v1.35.3

-- Fix Rob Luke's https://github.com/rob-luke/BIDS-NIRS-Tapping dataset not being loaded correctly probe lacks sourcePos2D and detectorPos2D. It has sourcePos3D and detectorPos3D so we project 3D to 2D if the 2D fields are empty. If landmarks are missing then we use crude default 3D-to-2D projection algorithm. If landmarks are available then we use another algorithm that Sreekanth Kura and David Boas are developing

* -- Change syncSubmodules to not use version numbers any more and rely on dates instead

* -- Fix 2 issues with loading Rob Luke's BIDS datasets (#121)

* v1.35.2

-- Fix not finding .snirf files in Rob Luke's dataset   https://github.com/rob-luke/BIDS-NIRS-Tapping  because the file name pattern does not match any of the available options in DataFilesClass. Updated list of BIDS file name patterns to earch for.
-- Fix some bugs in DataFilesClass file search (change name of isempty method to IsEmpty so that there's no overriding of matlab's built in isempty: this caused DataFilesClass object to be mysteriously empty when executing constructor, also AddParentDirs method assigning incorrect name to FileClass member objects)

* -- Fix some bugs in unit test logging - and displaying call stack in case of error

* v1.35.3

-- Fix Rob Luke's https://github.com/rob-luke/BIDS-NIRS-Tapping dataset not

 being loaded correctly probe lacks sourcePos2D and detectorPos2D. It has sourcePos3D and detectorPos3D so we project 3D to 2D if the 2D fields are empty. If landmarks are missing then we use crude default 3D-to-2D projection algorithm. If landmarks are available then we use another algorithm that Sreekanth Kura and David Boas are developing

* -- Change syncSubmodules to not use version numbers any more and rely on dates instead

* v1.35.4

-- Fix SNIRF file probe - which does not have 2D optodes - not loading correctly because 3D-to-2D default projection was not being called due to incorrect condition check.
-- Remove fsolve warnings and print statements from project_3D_to_2D.
-- MainGUI No Sessions view not selcting correct current element when selecting from Group level to Run level in data tree listbox display.
-- Fix issue in StimEditGUI with a dataset that has NO stims or conditions at all and where a) selecting Syncronize Browsing menu option b) switch to another run in MainGUI which atriggers StimEditGUI Update function to display the newly selcted run c) set stim causes error. Fix by adding call to current element Load() method to load the acquired data. This needs to when using distributed storage scheme for DataTree which is the default.

* -- Fix error in syncSubmodules in find date of last rev not working for git added files and add progress bar when find latest rev

* v1.35.5

-- Fix error in ProcStreamEditGUI when saving proc stream in save callback and add progress bar to show occasional delays in proc stream loading.
-- Fix typo cauing error when launching ProcStreamOptionsGUI.

* v1.35.6

-- Fix lack of BIDS support when editing parameter values in ProcStreamOptionsGUI.

* v1.35.7

-- Get latest change from Utils/Shared

* 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.

* Fix error loading SNIRF stim caused by previous fix to aux that broke stim loading (#129)

* v1.36.0

-- Fix issues with building and running Homer3 executable.
-- Add logging of Homer3 input arguments.
-- Fix a performance issue in fullpath.m discovered when loading large data set.

* v1.36.1

-- Fix another issue in executable of not finding data files in subject folder.

* v1.36.2

-- Fix for error loading SNIRF aux.name field didn't work for ALL cases. Added code in HDF5 transpose code to handle all cases.
-- Added error handling in AuxClass

* -- Fix syncSubmodules attempted syncing with empty submodule

* Fix tCCA issues related to new BIDS format support (#130)

* v1.36.0

-- Fix issues with building and running Homer3 executable.
-- Add logging of Homer3 input arguments.
-- Fix a performance issue in fullpath.m discovered when loading large data set.

* v1.36.1

-- Fix another issue in executable of not finding data files in subject folder.

* v1.36.2

-- Fix for error loading SNIRF aux.name field didn't work for ALL cases. Added code in HDF5 transpose code to handle all cases.
-- Added error handling in AuxClass

* -- Fix syncSubmodules attempted syncing with empty submodule

* v1.36.3

-- Sync with latest changes to shared libraries in AV (v2.19.3)

* v1.36.4

-- Fix bug (in FuncCallClass.m) where saved proc stream parameter values not being loaded correctly - instead default values are loaded.
-- Subject level tcca user function hmrS_tCCA.m needs an update to do it's job of moving tcca filter files to subject derived data folder in homerOutput.
-- Fix broken version check in checkForHomerUpdates.m by converting getVernum output to a cell array as expected by the function. Also avoid setCurrentLocation not working on some versions of MacOS
-- Fix occasional failure of data display in MainGUI when clicking on channels in the SDG axes.
-- Minor corrections of comments in ProcStreamEditGUI.m

* v1.36.5

-- Sync datatree with latest changes in AtlasViewer v2.19.5

* v1.36.6

-- Changes to make tCCA processing work with BIDS sessions. Fix bugs in hmrE_CalcAvg.m session level averaging that generated incorrect results in tCCA processing (which requires at least 2 runs per session)
-- Do some code clean up in hmrR_GLM.m, fix error when flagNuisanceRMethod==3 (meaning use tCCA regression) but there's no rcMap, remove obsolete code.
-- Fix another issue with saved parameters in ProcStreamEditGUI.m this time when they are loaded from config file (previous fix was when saving to config file)
-- Fix issue with aux checkbox being disabled in MainGUI (aux is present in run and the first time run is selected aux checkbox is enabled). Aux checkbox becomes disabled after selecting subject processing, then run again.
-- Add another BIDS-like directory structure format in DataFilesClass.m to list of formats recognized and loaded by DataTree.
-- Add IsDataValid method to DataClass.m - used in session level averaging user function.
-- Some minor code formatting in ProcStreamClass.m and FindUserFuncDir.m.
-- Minor GUI changes: pushbutton label changes in ProcStreamEditGUI.fig and slightly different font sizes in setGuiFonts.m for GUI uicontrol objects with non-alphanumeric strings.

* v1.36.7  -- Change to how data set is loaded when no sessions folder are present. Assume runs under subject without session folder are part of the same session instead of each run having its own session. This will avoid problems with tCCA where it is impoertant to have mutiple runs, first being resting state.

* v1.36.8  -- Fix repeatedly running Homer3 with tCCA proc stream works first time but subsequent times generates error in hmrE_CalcAvg.m

* v1.37.0 (#132)

-- Fix errors in hmrR_tCCA and hmrR_GLM when aux channels with different sampling rates and different sampling rates with respect to the data as happened with NIRx data. Change SnirfClass method GetAuxDataMatrix to get all aux channels to be on same time base as the data.
-- Fix some bugs with freeing memory incorrectly when storage scheme is 'memory' (rather than the default 'files') in DataTreeClass and ProcResultClass.
-- Fix logger issue in Homer3.m with logging overwriting current session's earlier log entries when for instance running processing stream.
-- Fix incorrect display of currently selected channels MainGUI. Added function GetSelectedChannelIdxs to update selected channels.
-- Add functionality to unit test to make sure channel order in acquisition files does not generate incorrect processing results.

* Update snirfSegment.m (#136)

Change in SnirfSegment Function: Putting an if check to avoid non-existing stim causing the code to break

* 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

* Development sk (#135)

* Update 3D to 2D projection

* Fix LengthUnit error

* update MetaDataClass Set method

* remove ProbeClass.m.bak file

* fix bugs in MetaDataTagsClass and SnirfClass

* Make circular 2D probe pos range -1 to 1

* Fix merge issues with fig file

* Fix probe3dto2d issue when snirf file has incorrect landmarklabels

* Generate source2D and detector2D positions same time instead of seperately when labelmark3D are not available

* Minor changes to make code clean

Co-authored-by: default avatarstephen scott tucker <sstucker@bu.edu>
Co-authored-by: default avatarMeryem Ayşe Yücel <49535526+mayucel@users.noreply.github.com>
Co-authored-by: default avatarSreekanth kura <sreekanth.kura7@gmail.com>
parent 452d96a2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
LastCheckForUpdates.dat
FuncRegistry/UserFunctions/Registry.mat
*.snirf
*.asv
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -7,4 +7,8 @@ on
% Stim Edit GUI Save Warnings # don't ask again, ask every time
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
+106 −16
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ classdef DataFilesClass < handle
    
    properties
        files;
        filesErr;
        filetype;
        dirFormats;
        err;
@@ -21,6 +22,7 @@ classdef DataFilesClass < handle
        % ----------------------------------------------------
        function obj = DataFilesClass(varargin)            
            obj.files = FileClass.empty();
            obj.filesErr = FileClass.empty();
            obj.filetype = '';
            obj.rootdir = pwd;
            obj.nfiles = 0;
@@ -116,15 +118,15 @@ classdef DataFilesClass < handle
                obj.InitLookupTable();
                obj.FindDataSet(ii);
                
                % Remove any files that cannot pass the basic test of loading
                % its data
                obj.ErrorCheck();
                if ~isempty(obj.files)
                    break
                end
            end
            
            % Remove any files that cannot pass the basic test of loading
            % its data
            obj.ErrorCheckName();
            obj.ErrorCheckFinal();
        end

        
@@ -162,13 +164,39 @@ classdef DataFilesClass < handle
                ['nirs/sub-*_run-*_nirs.', obj.filetype];
                }
                
                %%%% 6. BIDS-like folder structure without file naming restrictions
                %%%% 6. BIDS #3
                {
                'sub-*';
                ['nirs/sub-*_*_nirs.', obj.filetype];
                }
                
                %%%% 7. BIDS #4 
                {
                '*';
                ['nirs/sub-*_*_nirs.', obj.filetype];
                }
                
                %%%% 8. BIDS folder structure
                {
                'sub-*';
                'ses-*';
                ['nirs/sub-*_run-*_nirs.', obj.filetype];
                }
                               
                %%%% 9. BIDS-like folder structure without file naming restrictions
                {
                'sub-*';
                'ses-*';
                ['nirs/*.', obj.filetype];
                }
                                
                %%%% 10. BIDS-like folder structure without nirs sub-folder
                {
                'sub-*';
                'ses-*';
                ['*.', obj.filetype];
                }
                                
                };
        end
        
@@ -196,10 +224,13 @@ classdef DataFilesClass < handle
            parentdir = filesepStandard(parentdir);
            pattern = obj.dirFormats.choices{iFormat}{iPattern};
            
            dirs = mydir([parentdir, pattern]);
            dirs = mydir([parentdir, pattern], obj.rootdir);
            
            dirnamePrev = '';
            for ii = 1:length(dirs)
                if dirs(ii).IsEmpty()
                    continue;
                end
                if dirs(ii).IsFile()
                    if strcmp(pattern, '*')
                        continue
@@ -224,10 +255,9 @@ classdef DataFilesClass < handle

        
        % ----------------------------------------------------
        function AddParentDirs(obj, dir)
            pathrel = getPathRelative([dir.rootdir, dir.name], obj.rootdir);
        function AddParentDirs(obj, dirname)
            pathrel = getPathRelative([dirname.rootdir, dirname.name], obj.rootdir);
            subdirs = str2cell_fast(pathrel, {'/','\'});
            notUnique = false;
            N = length(subdirs);
            for ii = 1:N-1
                if strcmp(subdirs{ii}, 'nirs')
@@ -237,7 +267,7 @@ classdef DataFilesClass < handle
                if obj.SearchLookupTable(pathrel2)
                    continue;
                end
                obj.files(end+1) = FileClass(pathrel2);
                obj.files(end+1) = FileClass([obj.rootdir, '/', pathrel2], obj.rootdir);
                obj.AddLookupTable(obj.files(end).name)
            end
        end
@@ -272,6 +302,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)
            global cfg
@@ -305,7 +370,7 @@ classdef DataFilesClass < handle
            [p2,f2] = fileparts(filesepStandard(obj.files(ii).rootdir,'nameonly:file'));
            [~,f3]  = fileparts(p2);
            if isfile_private(obj.files(ii).GetName())
                filetype = 'file';
                filetype = 'file'; %#ok<*PROPLC>
            else
                filetype = 'folder';
            end
@@ -351,7 +416,7 @@ classdef DataFilesClass < handle
            
        
        % ----------------------------------------------------------
        function b = isempty(obj)
        function b = IsEmpty(obj)
            if isempty(obj.files)
                b = true;
            else
@@ -400,6 +465,8 @@ classdef DataFilesClass < handle
            end
            
            % Try to create object of data filetype and load data into it
            msg = 'Please wait while we check group folder for valid data files ...';
            hwait = waitbar_improved(0, msg);
            dataflag = false;
            for ii = 1:length(obj.files)
                if obj.files(ii).isdir
@@ -408,17 +475,27 @@ classdef DataFilesClass < handle
                filename = [obj.files(ii).rootdir, obj.files(ii).name];
                eval( sprintf('o = %s(filename);', constructor) );
                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>
                elseif  contains(o.GetErrorMsg(), 'WARNING: ''data'' corrupt and unusable')                    
                    obj.logger.Write('DataFilesClass.ErrorCheck:   WARNING data is unusable - %s will not be added to data set\n', filename);
                    errorIdxs = [errorIdxs, ii]; %#ok<AGROW>
                else
                    dataflag = true;
                end
                hwait = waitbar_improved(ii/length(obj.files), hwait, msg);
            end
            if dataflag==false
                obj.files = FileClass.empty();
            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.nfiles = obj.nfiles - length(errorIdxs);
            end
            close(hwait);
        end
        
        
@@ -441,11 +518,23 @@ classdef DataFilesClass < handle
            obj.logger.Write('DataTreeClass - Data Set Folder Structure:\n');
            for ii = 1:length(obj.files)
                k = length(find(obj.files(ii).name=='/'));   
                if ii<10, j=3; elseif ii>9 && ii<100, j=2; else j=3; end
                if ii<10
                    j=3; 
                elseif ii>9 && ii<100
                    j=2;
                else
                    j=3;
                end
                if optionExists(options, 'flat')
                    obj.logger.Write(sprintf('%d.%s%s\n', ii, blanks(j), obj.files(ii).name));
                else
                    if ii<10, j=3; elseif ii>9 && ii<100, j=2; else j=3; end
                    if ii<10
                        j=3; 
                    elseif ii>9 && ii<100
                        j=2; 
                    else 
                        j=3; 
                    end
                    if optionExists(options, 'numbered')
                        n = k*stepsize+stepsize+j;
                        obj.logger.Write(sprintf('%d.%s%s\n', ii, blanks(n), obj.files(ii).filename));
@@ -488,5 +577,6 @@ classdef DataFilesClass < handle
            b = obj.lookupTable(string2hash(str, n));
        end
        
        
    end
end
+560 −539
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ classdef FileClass < matlab.mixin.Copyable
        rootdir
        err
        logger
        errmsgs
    end
    
    methods
@@ -39,6 +40,8 @@ classdef FileClass < matlab.mixin.Copyable
            obj.rootdir    = '';
            obj.err        = -1;          % Assume file is not loadable
            obj.logger     = InitLogger(logger);            
            obj.errmsgs    = {'Invalid Data Format','Invalid File Name'};
            
            
            if nargin==0
                return;
@@ -59,7 +62,7 @@ classdef FileClass < matlab.mixin.Copyable
            else
                file.rootdir = pwd;
            end
            file.rootdir = filesepStandard(file.rootdir);            
            file.rootdir = filesepStandard(file.rootdir, 'full');            
            
            obj.Add(file);
        end
@@ -75,15 +78,15 @@ classdef FileClass < matlab.mixin.Copyable
            end
            
            if isproperty(obj2, 'folder')
                rootdir = [filesepStandard(obj2.folder), obj2.name]; %#ok<*PROPLC>
                rootpath = [filesepStandard(obj2.folder), obj2.name]; %#ok<*PROPLC>
            else
                rootdir = [filesepStandard(obj2.rootdir), obj2.name];                
                rootpath = [filesepStandard(obj2.rootdir), obj2.name];                
            end
            
            obj.idx          = obj.idx+1;
            obj.isdir        = obj2.isdir;
            obj.filename     = obj2.name;
            obj.name         = getPathRelative(rootdir, obj2.rootdir);
            obj.name         = getPathRelative(rootpath, obj2.rootdir);
            obj.rootdir 	 = obj2.rootdir;
            obj.err          = 0;          % Set error to NO ERROR            
        end
@@ -116,7 +119,11 @@ classdef FileClass < matlab.mixin.Copyable
                end
                dirname(k) = '*';
            end
            file = dir(dirname);
            temp = dir(dirname);
            if isempty(temp)
                return;
            end
            file = temp(1);
        end
        
        
@@ -157,7 +164,7 @@ classdef FileClass < matlab.mixin.Copyable
            
            % Consolidate second to last 'nirs' part with last part   
            if strcmp(parts{end-1}, 'nirs')
                parts{end} = [parts{end-1}, parts{end}];
                parts{end} = [parts{end-1}, '/', parts{end}];
                parts(end-1) = [];
            end
        end
@@ -191,8 +198,8 @@ classdef FileClass < matlab.mixin.Copyable
            %       R2.ext          ==>  [G1,  sub_R2,  ses_sub_R2,  R2]
            %       R3.ext          ==>  [G1,  sub_R3,  ses_sub_R3,  R3]
            if obj.IsFile && length(parts)==1 && length(subparts)==1
                subjName = ['sub_', fname];
                sessName = ['ses_', subjName];
                subjName = ['sub-', fname];
                sessName = ['ses-', subjName];
                runName  = obj.name;
            end

@@ -209,7 +216,7 @@ classdef FileClass < matlab.mixin.Copyable
            %       S3_R3.ext       ==>  [G1,  S2,  ses_S2_R3,  R3]
            if obj.IsFile && length(parts)==1 && length(subparts)==2
                subjName = subparts{1};
                sessName = ['ses_', subjName, '_', fname];
                sessName = ['ses-', subjName, '_', subjName];
                runName  = obj.name;
            end
            
@@ -258,7 +265,7 @@ classdef FileClass < matlab.mixin.Copyable
                subjName = obj.name;
            elseif obj.IsFile && length(parts)==2
                subjName = parts{1};
                sessName = [subjName '/ses-',parts{end}];
                sessName = [subjName, '/ses-', subjName];
                runName  = obj.name;
            end
            
@@ -535,6 +542,20 @@ classdef FileClass < matlab.mixin.Copyable
        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
 No newline at end of file
+6 −9
Original line number Diff line number Diff line
@@ -58,17 +58,16 @@ end
% Check files data set for errors. If there are no valid
% nirs files don't attempt to load them.
files = DataFilesClass();
while files.isempty()
while files.IsEmpty()
    switch fmt
        case {'snirf','.snirf'}
            files = DataFilesClass(dirnameGroup, 'snirf');
            filesSrc = DataFilesClass(dirnameGroup, 'nirs', '', false);
            if ~filesSrc.isempty()
            if ~filesSrc.IsEmpty()
                nfolders = length(filesSrc.files)-filesSrc.nfiles;
                if nfolders==0
                    nfolders = 1;
                end
                fprintf('FindFiles: Found %d .nirs data files in %d folders\n', filesSrc.nfiles, nfolders);
            end
            
            % Search for source acquisition files in .nirs format which have not
@@ -77,7 +76,7 @@ while files.isempty()
            if ~all(found)
                q = GetOptionsForIncompleteDataSet(files, filesSrc);
                if q==2
                    if files.isempty()
                    if files.IsEmpty()
                        files = [];
                    end
                    return;
@@ -87,7 +86,7 @@ while files.isempty()
            end
        case {'snirfonly'}
            files = DataFilesClass(dirnameGroup, 'snirf');
            if files.isempty()
            if files.IsEmpty()
                files = [];
                return;
            end
@@ -112,7 +111,7 @@ while files.isempty()
    
    % If no files were found ion the current format then ask user to choose
    % another group folder
    if files.isempty()
    if files.IsEmpty()
        if strcmp(fmt, 'snirfonly')
            files = [];
            return
@@ -134,8 +133,6 @@ while files.isempty()
        cd(dirnameGroup)
    end
    
    fprintf('FindFiles: Found %d %s data files in %d folders\n', files.nfiles, fmt, length(files.files)-files.nfiles);
    
end


@@ -144,7 +141,7 @@ end
function  q = GetOptionsForIncompleteDataSet(files, filesSrc)
if files.config.RegressionTestActive
    q = 1;
elseif  files.isempty()
elseif  files.IsEmpty()
    msg{1} = sprintf('Homer3 did not find any .snirf files in the current folder but did find %d .nirs files. ', filesSrc.nfiles);
    msg{2} = sprintf('Do you want to convert .nirs files to .snirf format and load them?');
    q = MenuBox(msg, {'YES','NO'}, 'center');
Loading