Commit 849792e9 authored by jayd1860's avatar jayd1860
Browse files

Merge branch 'development'

# Conflicts:
#	DataTree/AcquiredData/Snirf/ProbeClass.m
#	DataTree/GroupClass.m
#	DataTree/ProcStream/ProcStreamClass.m
#	DataTree/SubjClass.m
#	DataTree/TreeNodeClass.m
#	Version.txt
parents 8782c519 3021b497
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -157,10 +157,8 @@ classdef ProbeClass < FileLoadSaveClass
            
            if isempty(obj.sourcePos2D) && isempty(obj.detectorPos2D)
                if isempty(obj.landmarkPos3D) || ~obj.isValidLandmarkLabels()
                    optodePos3D = [];
                    nSource = 0;
                    nSource = size(obj.sourcePos3D,1);
                    optodePos3D = [obj.sourcePos3D; obj.detectorPos3D];
                    nSource = size(optodePos3D,1);
                    
                    optodePos2D = project_3D_to_2D(optodePos3D);
                    if ~isempty(optodePos2D)
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ No
don't ask again

% Output Folder Name # 
homerOutput
derivatives/homer

% Output File Name # 
groupResults.mat
+70 −47
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ classdef GroupClass < TreeNodeClass
    
    properties % (Access = private)
        outputFilename
        oldDerivedPaths
        derivedPathBidsCompliant
    end
    
    
@@ -21,6 +23,8 @@ classdef GroupClass < TreeNodeClass
            obj@TreeNodeClass(varargin);

            obj.InitVersion();
            obj.oldDerivedPaths = {obj.path, [obj.path, 'homerOutput']};
            obj.derivedPathBidsCompliant = 'derivatives/homer';
            
            if nargin<3 || ~strcmp(varargin{3}, 'noprint')
                obj.logger.Write('Current GroupClass version %s\n', obj.GetVersionStr());
@@ -865,15 +869,6 @@ classdef GroupClass < TreeNodeClass
        end
        
        
        % ----------------------------------------------------------------------------------
        function ch = GetMeasList(obj, iBlk)
            if ~exist('iBlk','var')
                iBlk=1;
            end
            ch = obj.subjs(1).GetMeasList(iBlk);
        end

        
        % ----------------------------------------------------------------------------------
        function wls = GetWls(obj)
            wls = obj.subjs(1).GetWls();
@@ -1071,10 +1066,12 @@ classdef GroupClass < TreeNodeClass

        % ----------------------------------------------------------------------------------
        function BackwardCompatability(obj)
            if ispathvalid([obj.path, 'groupResults.mat'])
            for jj = 1:length(obj.oldDerivedPaths)
                oldDerivedPath = filesepStandard(obj.oldDerivedPaths{jj});
                if ispathvalid([oldDerivedPath, 'groupResults.mat'])
                    try
                    g = load([obj.path, 'groupResults.mat']);
                catch ME
                        g = load([oldDerivedPath, 'groupResults.mat']);
                    catch
                        g = [];
                    end
                    
@@ -1095,24 +1092,50 @@ classdef GroupClass < TreeNodeClass
                        return;
                    end
                    
                msg = sprintf('Detected derived data in an old Homer3 format.');
                    oldDerivedPathRel = pathsubtract(oldDerivedPath, obj.path);
                    if oldDerivedPathRel(end) == '/' || oldDerivedPathRel(end) == '\'
                        oldDerivedPathRel(end) = '';
                    end
                    msg{1} = sprintf('Detected derived data in older Homer3 folder "%s" ', oldDerivedPathRel);
                    if pathscompare(obj.derivedPathBidsCompliant, obj.outputDirname, 'nameonly')
                        msg{2} = sprintf('The current derived output folder, "%s", is BIDS compliant. ', ...
                            filesepStandard(obj.derivedPathBidsCompliant, 'filesepwide:nameonly'));
                    else
                        msg{2} = '.';
                    end
                    msg = [msg{:}];
                    obj.logger.Write('Backward Compatability:   %s\n', msg);
                    
                    % If we're here it means that old format homer3 data exists
                    % AND NO new homer3 format data exists
                q = MenuBox(sprintf('%s. Do you want to save it in the new format?', msg),{'Yes','No'});
                    q = MenuBox(sprintf('%s Do you want to move %s to the new folder?', msg, oldDerivedPathRel),{'Yes','No'});
                    if q==1
                    obj.BackwardCompatability@TreeNodeClass();
                    for ii = 1:length(obj.subjs)
                        obj.subjs(ii).BackwardCompatability();
                        if ispathvalid([obj.path, obj.outputDirname])
                            try
                                rmdir([obj.path, obj.outputDirname], 's')
                            catch
                                MenuBox(sprintf('ERROR:  Could not remove new derived folder'),{'OK'});
                                return
                            end
                        end
                        obj.logger.Write('Moving %s to %s\n', oldDerivedPath, [obj.path, obj.outputDirname]);
                        movefile(oldDerivedPath, [obj.path, obj.outputDirname])
                        
                    obj.logger.Write('Moving %s to %s\n', 'groupResults.mat', [obj.path, obj.outputDirname, obj.outputFilename]);
                    movefile('groupResults.mat', [obj.path, obj.outputDirname, obj.outputFilename])
                        if ispathvalid([obj.path, obj.outputDirname, obj.outputFilename])
                            if ~strcmp(obj.outputFilename, 'groupResults.mat')
                                obj.logger.Write('Moving %s to %s\n', [obj.path, obj.outputDirname, 'groupResults.mat'], ...
                                    [obj.path, obj.outputDirname, obj.outputFilename])
                                movefile([obj.path, obj.outputDirname, 'groupResults.mat'], [obj.path, obj.outputDirname, obj.outputFilename])
                            end
                        end
                    end
                    break
                end
                
            end            
        end
            
        
    end  % Private methods

end % classdef GroupClass < TreeNodeClass
+11 −8
Original line number Diff line number Diff line
@@ -233,11 +233,14 @@ classdef ProcInputClass < handle
            end
            if isempty(obj.mlActMan)
                obj.mlActMan{iBlk} = ml;
            elseif isempty(obj.mlActMan{iBlk})
               obj.mlActMan{iBlk} = ml; 
            elseif length(obj.mlActMan{iBlk}) == length(ml)
               obj.mlActMan{iBlk} = ml; 
            end
        end

        
        % ----------------------------------------------------------------------------------
        function ml = GetMeasListVis(obj, iBlk)
            if ~exist('iBlk','var')
+36 −11
Original line number Diff line number Diff line
@@ -355,6 +355,27 @@ classdef ProcStreamClass < handle
        end
        
        
        % ----------------------------------------------------------------------------------        
        function mlActMan = CompressMlActMan(obj)
            mlActMan = [];
            if isempty(obj.input.mlActMan)
                return
            end
            mlActMan = compressLogicalArray(obj.input.mlActMan{1});
        end
        
        
        % ----------------------------------------------------------------------------------        
        function tIncMan = CompresstIncMan(obj)
            tIncMan = [];
            if isempty(obj.input.tIncMan)
                return
            end
            tIncMan = compressLogicalArray(obj.input.tIncMan{1});
        end
                
                
                
        % ----------------------------------------------------------------------------------        
        function ExportProcStream(obj, filename, fcalls)
            global logger             
@@ -363,13 +384,17 @@ classdef ProcStreamClass < handle
                return;
            end
            [p,f] = fileparts(temp); 
            fname = [filesepStandard(p), f, '_ProcStream.txt'];
            fname = [filesepStandard(p), f, '_processing.json'];
            if obj.ExportProcStreamFunctions()==true
                fid = fopen(fname, 'w');                
                logger.Write('Saving processing stream  %s:\n', fname);
                for ii = 1:length(fcalls)
                    fprintf(fid, '%s\n', fcalls{ii});
                end
                appname = sprintf('%s, (v%s)', getNamespace(), getVernum(getNamespace()));
                dt      = sprintf('%s', char(datetime(datetime, 'Format','MMMM d, yyyy,   HH:mm:ss')));
                mlActManCompressed = obj.CompressMlActMan();
                tIncManCompressed = obj.CompresstIncMan();
                jsonstruct = struct('ApplicationName',appname, 'DateTime',dt, 'tIncMan',tIncManCompressed, 'mlActMan',mlActManCompressed, 'FunctionsCalls',{fcalls});
                jsonStr = savejson('Processing', jsonstruct);
                fid = fopen(fname, 'w');
                fwrite(fid, jsonStr, 'uint8');
                fclose(fid);
            else
                if ispathvalid(fname)
Loading