Commit 89347440 authored by sstucker's avatar sstucker
Browse files

hmrR_MotionArtifact and hmrR_MotionArtifactByChannel now take previously...

hmrR_MotionArtifact and hmrR_MotionArtifactByChannel now take previously excluded or pruned channels into account
parent 05e09985
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
% SYNTAX:
% tInc = hmrR_MotionArtifact(data, probe, mlActMan, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
% tInc = hmrR_MotionArtifact(data, probe, mlActMan, mlActAuto, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
%
% UI NAME:
% Motion_Artifacts
@@ -15,6 +15,8 @@
% probe:   SNIRF data structure probe, containing probe source/detector geometry
% mlActMan: Cell array of vectors, one for each time base in data, specifying 
%        active/inactive channels with 1 meaning active, 0 meaning inactive
% mlActAuto: Cell array of vectors, one for each time base in data, specifying 
%        active/inactive channels with 1 meaning active, 0 meaning inactive
% tIncMan: Cell array of vectors corresponding to the number of time bases in data. 
%          tIncMan has been manually excluded. 0-excluded. 1-included. Vector same length as d.
% tMotion: Check for signal change indicative of a motion artifact over
@@ -42,7 +44,7 @@
%       with 1's indicating data included and 0's indicate motion artifact
%
% USAGE OPTIONS:
% Motion_Artifacts:  tIncAuto = hmrR_MotionArtifact(dod, probe, mlActMan, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
% Motion_Artifacts:  tIncAuto = hmrR_MotionArtifact(dod, probe, mlActMan, mlActAuto, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
%
% PARAMETERS:
% tMotion: 0.5
@@ -60,7 +62,7 @@
% JDUBB 3/18/2019 Adapted to SNIRF format
%
%
function tInc = hmrR_MotionArtifact(data, probe, mlActMan, tIncMan, tMotion, tMask, std_thresh, amp_thresh)
function tInc = hmrR_MotionArtifact(data, probe, mlActMan, mlActAuto, tIncMan, tMotion, tMask, std_thresh, amp_thresh)

% Init output 
tInc = cell(length(data),1);
@@ -81,6 +83,9 @@ end
if isempty(mlActMan)
    mlActMan = cell(length(data),1);
end
if isempty(mlActAuto)
    mlActAuto = cell(length(data),1);
end

for iBlk=1:length(data)

@@ -100,7 +105,10 @@ for iBlk=1:length(data)
    if isempty(mlActMan{iBlk})
        mlActMan{iBlk} = ones(size(MeasList,1),1);
    end
    MeasListAct = mlActMan{iBlk};        
    if isempty(mlActAuto{iBlk})
        mlActAuto{iBlk} = ones(size(MeasList,1),1);
    end
    MeasListAct = mlActMan{iBlk} & mlActAuto{iBlk};        
    
    % Calculate the diff of d to to set the threshold if ncssesary
    diff_d = diff(d);
+12 −4
Original line number Diff line number Diff line
% [tInc,tIncCh] = hmrR_MotionArtifactByChannel(data, probe, mlActMan, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
% [tInc,tIncCh] = hmrR_MotionArtifactByChannel(data, probe, mlActMan, mlActAuto, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
%
% UI NAME:   
% Motion_Artifacts_By_Channel
@@ -19,6 +19,8 @@
%          tIncMan has been manually excluded. 0-excluded. 1-included. Vector same length as d.
% mlActMan: Cell array of vectors, one for each time base in data, specifying 
%        active/inactive channels with 1 meaning active, 0 meaning inactive
% mlActAuto: Cell array of vectors, one for each time base in data, specifying 
%        active/inactive channels with 1 meaning active, 0 meaning inactive
% tMotion: Check for signal change indicative of a motion artifact over
%     time range tMotion. Units of seconds.
% tMask: Mark data over +/- tMask seconds around the identified motion 
@@ -40,7 +42,7 @@
%       channel basis
%
% USAGE OPTIONS:
% Motion_Artifacts_By_Channel:  [tIncAuto, tIncAutoCh] = hmrR_MotionArtifactByChannel(dod, probe, mlActMan, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
% Motion_Artifacts_By_Channel:  [tIncAuto, tIncAutoCh] = hmrR_MotionArtifactByChannel(dod, probe, mlActMan, mlActAuto, tIncMan, tMotion, tMask, STDEVthresh, AMPthresh)
%
% PARAMETERS:
% tMotion: 0.5
@@ -59,7 +61,7 @@
% TO DO:
% Consider tIncMan

function [tInc, tIncCh] = hmrR_MotionArtifactByChannel(data, probe, mlActMan, tIncMan, tMotion, tMask, std_thresh, amp_thresh)
function [tInc, tIncCh] = hmrR_MotionArtifactByChannel(data, probe, mlActMan, mlActAuto, tIncMan, tMotion, tMask, std_thresh, amp_thresh)

tInc   = cell(length(data), 1);
tIncCh = cell(length(data), 1);
@@ -80,6 +82,9 @@ end
if isempty(mlActMan)
    mlActMan = cell(length(data),1);
end
if isempty(mlActAuto)
    mlActAuto = cell(length(data),1);
end

for iBlk=1:length(data)
    
@@ -102,7 +107,10 @@ for iBlk=1:length(data)
    if isempty(mlActMan{iBlk})
        mlActMan{iBlk} = ones(size(MeasList,1),1);
    end
    MeasListAct = mlActMan{iBlk};
    if isempty(mlActAuto{iBlk})
        mlActAuto{iBlk} = ones(size(MeasList,1),1);
    end
    MeasListAct = mlActMan{iBlk} & mlActAuto{iBlk};      
        
    % Calculate the diff of d to to set the threshold if ncssesary
    diff_d = diff(d);