Unverified Commit baef6691 authored by Christian Arthur's avatar Christian Arthur Committed by GitHub
Browse files

SNIRF Tools Update - Segment and Down-sample (#28)

* Updated DesignNotes.ppt

* Update 1
Disable Aux Display by default

* Update 2:
Small fix to PlotProbe synchronization issues with the MainGUI
Updated MainGUI plots to include units for x and y axis labels (currently with placeholder names)

* Update 2.1
- Added sampling rate to x axis label

* Update 2.2
- Pushed (actual) possible fix for Plot Probe GUI bug (seems to fail to push in Update 2)

* Update 3
Added SNIRF File Segmentation tool (not connected to the MainGUI yet)
Located in the UserFunctions folder

* Update 3.1
Fixed some texts and descriptions

* Update 3.2
Added SNIRF File Down-sampling Tool (not connected to the MainGUI yet)
Located in the UserFunctions folder

* Update 4
Updated the GLM Function to not include flatMotionCorrect parameter
to avoid confusion

* Update 5
Added proper units to X and Y labels
Possible addition to be worked on..

* Update 6
Moved Segment and Down-sample tool to Utils folder
Attached the tools to the MainGUI

Merged Updates from Master

* Update 7
Added units to the y labels of the plots in the MainGUI
Fixed issues/bugs found in the GLM function

* Update 8
Updated the segment and down-sample tool to have the current element as the default path for the File UI

* Update 8.1
- Updated MainGUI to refresh run list after segmentation or down-sampling
- Tinkered with the resetGroupFolder function (might be useless)
- Updated the segment and down-sample tool to work when run independently and when attached to Homer3 (default data path set to current group directory)

* Update 8.1.1
Git Pull Mistake Fix

* Update 8.2
- Fixed bug for plot labels when changing to Subject/Groups
- Adjusted Segmentation and Down-sample tool to exclude/rewrite the original snirf

* Update 8.2.1
- Updated MainGUI.fig to add the segmentation and down-sampling tool
- Adjusted the plot labels in the MainGUI

* Update 8.2.2
- Updated MainGUI.m for an output that shows on the command window
- Add feature where segment and down-sample tool choose the current element automatically at first

* Update 8.2.3
- Adjusted X-label on MainGUI plot to not display frequency (for now)
- Added a message box to notify user when a new snirf file is created after using the segment and down-sample tool

* Update 8.2.4
- Added more description to the segment tool for better clarity
- Fixed the bug where the segment/down-sampling tool gives an error when the user presses cancel
- Limit the segment and down-sampling tool to non flat file directories to avoid possible error with the current limitations of implementation
parent 99ff8ede
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -601,6 +601,15 @@ classdef DataTreeClass < handle
            b = false;
        end
        
        % ----------------------------------------------------------
        function b = IsFlatFileDir(obj)
            if obj.files(1).isdir
                b = false;
            else
                b = true;
            end
        end

    end
    
end
 No newline at end of file
+1.62 KiB (83.9 KiB)

File changed.

No diff preview for this file type.

+58 −0
Original line number Diff line number Diff line
@@ -967,12 +967,40 @@ for iBlk = iDataBlks
            end
            d = procElem.reshape_y(d, ch.MeasList);
            DisplayDataRawOrOD(t, d, dStd, iWl, iChBlk, chVis, nTrials, condition, linecolors);
            if isa(dataTree.currElem, 'RunClass')
                sRate = 1/mean(diff(dataTree.currElem.acquired.data.time));
                xlabel('Time (s)', 'FontSize', 17);
%                 xlabel(['Time (s) | f_s = ' num2str(sRate) ' Hz'], 'FontSize', 17);
            else
                xlabel('Time (s)', 'FontSize', 17);
            end
            ylabel('');
        elseif datatype == maingui.buttonVals.CONC || datatype == maingui.buttonVals.CONC_HRF
            if  datatype == maingui.buttonVals.CONC_HRF
                d = d(:,:,:,condition);
            end
            d = d * sclConc;
            DisplayDataConc(t, d, dStd, hbType, iChBlk, chVis, nTrials, condition, linecolors);
            if isa(dataTree.currElem, 'RunClass')
                sRate = 1/mean(diff(dataTree.currElem.acquired.data.time));
                xlabel('Time (s)', 'FontSize', 17);
%                 xlabel(['Time(s) | f_s = ' num2str(sRate) ' Hz'], 'FontSize', 17);
            else
                xlabel('Time (s)', 'FontSize', 17);
            end
            procName = {procElem.procStream.fcalls.name};
            idx = contains(procName, 'hmrR_OD2Conc_new');
            if ~isempty(find(idx,1))
                ppf = procElem.procStream.fcalls(idx).paramIn.value;
                if ppf(condition) == 1 && ~isempty(dataTree.currElem.acquired.metaDataTags.tags.LengthUnit)
                    unit = dataTree.currElem.acquired.metaDataTags.tags.LengthUnit;
                    ylabel(['\muM ' unit], 'FontSize', 17);
                else
                ylabel('\muM', 'FontSize', 17);
                end
            else
                ylabel('\muM', 'FontSize', 17);
            end
        end
    end
    iColor = iColor+length(iChBlk);
@@ -1272,6 +1300,7 @@ end
% --------------------------------------------------------------------
function menuItemResetGroupFolder_Callback(hObject, eventdata, handles)
resetGroupFolder();
DisplayGroupTree(handles);



@@ -1715,8 +1744,37 @@ else
    errordlg('Select a run to reset its excluded channels and time points.','No run selected');
end

% --------------------------------------------------------------------
function menuItemSegmentSnirf_Callback(hObject, eventdata, handles)
global maingui;
if maingui.dataTree.IsFlatFileDir()
    MessageBox('Segment Tool does not support flat file directories yet, please change to a deep directory style (using sub-directories for groups and subjects) to use the segment tool via Homer3');
    return;
end
snirfSegment();
maingui.dataTree = DataTreeClass();
for iG = 1:length(maingui.dataTree.groups)
    maingui.dataTree.SetCurrElem(iG,0,0);
    maingui.dataTree.ResetCurrElem();
end
DisplayGroupTree(handles);


% --------------------------------------------------------------------
function menuItemDownsampleSnirf_Callback(hObject, eventdata, handles)
global maingui;
if maingui.dataTree.IsFlatFileDir()
    MessageBox('Downsample Tool does not support flat file directories yet, please change to a deep directory style (using sub-directories for groups and subjects) to use the downsample tool via Homer3');
    return;
end
snirfDownsample();
maingui.dataTree = DataTreeClass();
for iG = 1:length(maingui.dataTree.groups)
    maingui.dataTree.SetCurrElem(iG,0,0);
    maingui.dataTree.ResetCurrElem();
end
DisplayGroupTree(handles);

% --------------------------------------------------------------------
function menuItemExportProcessingStreamScript_Callback(hObject, eventdata, handles)
global maingui
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ if isempty(plotprobe.datatype)
    plotprobe.datatype = plotprobe.datatypeVals.CONC_HRF;
end
if isempty(plotprobe.condition)
    plotprobe.condition = 1;
    plotprobe.condition = maingui.condition;
end


+5 −4
Original line number Diff line number Diff line
function resetGroupFolder(dirname, options)

global maingui;
if ~exist('dirname','var') || isempty(dirname)
    dirname = [pwd,'/'];
end
@@ -12,10 +13,10 @@ if exist([dirname, 'groupResults.mat'],'file')
end

if isempty(findstr(options, 'nodatatree')) %#ok<*FSTR>
    dataTree = DataTreeClass(dirname,'','','files');
    for iG = 1:length(dataTree.groups)
        dataTree.SetCurrElem(iG,0,0)
        dataTree.ResetCurrElem();
    maingui.dataTree = DataTreeClass(dirname,'','','files');
    for iG = 1:length(maingui.dataTree.groups)
        maingui.dataTree.SetCurrElem(iG,0,0)
        maingui.dataTree.ResetCurrElem();
    end
end

Loading