Commit 3084e2d1 authored by jayd1860's avatar jayd1860
Browse files

Diagnostic code which does not effect main Homer3 operation (so version number stays the same):

-- Change generateSimData.m to include all data files in a group. This function replaces the files real data with fake data that has the channel ID (source idx, detector index, data type idx, condition idx) embedded in the data itself for diagnosing/uncovering channel order issues.
-- Add more sim data user functions
parent c93071f4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,12 @@ for ii = 1:length(dirs)
        if strcmp(obj.config.InclArchivedFunctions, 'Yes')
            userfuncdir{end+1} = fullpath([userfuncdir{1}, 'Archive/']); %#ok<*AGROW>
        end
    elseif strcmp(dirs(ii).name, 'Sim')
        obj.config = struct('InclArchivedFunctions','');
        obj.config.InclArchivedFunctions = cfg.GetValue('Include Archived User Functions');        
        if strcmp(obj.config.InclArchivedFunctions, 'Yes')
            userfuncdir{end+1} = fullpath([userfuncdir{1}, 'Sim/']); %#ok<*AGROW>
        end
    else
        userfuncdir{end+1} = filesepStandard(fullpath([userfuncdir{1}, dirs(ii).name]));
    end
+840 −0

File added.

Preview size limit exceeded, changes collapsed.

+30 −0
Original line number Diff line number Diff line
% SYNTAX:
% dod = hmrR_Intensity2OD_sim( intensity )
%
% UI NAME:
% Intensity_to_Delta_OD
%
% DESCRIPTION:
% Converts intensity data to optical density
%
% INPUT:
% intensity - SNIRF data type where the d matrix is intensity
%
% OUTPUT:
% dod - SNIRF data type where the d matrix is change in optical density
%
% USAGE OPTIONS:
% Intensity_to_Delta_OD: dod = hmrR_Intensity2OD_sim(data)
%
function dod = hmrR_Intensity2OD_sim( intensity )

% convert to dod
dod = DataClass().empty();
for ii=1:length(intensity)
    dod(ii) = DataClass();
    d = intensity(ii).GetDataTimeSeries();
    dod(ii).SetTime(intensity(ii).GetTime());
    dod(ii).SetDataTimeSeries(d);
    dod(ii).SetMl(intensity(ii).GetMl());
    dod(ii).SetDataTypeDod();
end
+55 −0
Original line number Diff line number Diff line
% SYNTAX:
% function data_dc = hmrR_MotionCorrectCbsi_sim(data_dc, mlActAuto, turnon)
%
% UI NAME:
% Cbsi_Motion_Correction
%
% DESCRIPTION:
% Perform a correlation-based signal improvement of the concentration
% changes in order to correct for motion artifacts.
% The algorithm follows the procedure described by
% Cui et al.,NeuroImage, 49(4), 3039-46 (2010).
%
% INPUTS:
% data_dc:   Concentration changes (it works with HbO and HbR)
% mlActAuto: 
% turnon:    Skip this function if turnon=1. Otherwise execute function.
%            Default is to execute function if this does not exist.
%
%
% OUTPUTS:
% data_dc:  dc after correlation-based signal improvement correction, same
%           size as dc (Channels that are not in the active ml remain unchanged)
%
% USAGE OPTIONS:
% Cbsi_Motion_Correction: dc = hmrR_MotionCorrectCbsi_sim(dc, mlActAuto, turnon)
%
% PARAMETERS:
% turnon: 1
%
% PREREQUISITES:
% Delta_OD_to_Conc: dc = hmrR_OD2Conc( dod, probe, ppf )
%
% LOG:
% created 10-17-2012, S. Brigadoi
%

function data_dc = hmrR_MotionCorrectCbsi_sim(data_dc, mlActAuto, turnon)

% Added turn on/off option
if ~exist('turnon','var')
    turnon = 1;
end
if turnon==0
    return;
end
for iBlk = 1:length(data_dc)
    dc0 = data_dc(iBlk).GetDataTimeSeries();
    ml0 = data_dc(iBlk).GetMeasurementList();
    [dc, ~, ~, order] = data_dc(iBlk).GetDataTimeSeries('reshape');
    ml = data_dc(iBlk).GetMeasurementList('matrix','reshape');
    dcCbsi = dc;
    dcCbsi(:,order) = dcCbsi(:,:);
    data_dc(iBlk).SetDataTimeSeries(dcCbsi);
end
+60 −0
Original line number Diff line number Diff line
% SYNTAX:
% data_d = hmrR_MotionCorrectSplineSG_sim(data_d, mlActAuto, p, FrameSize_sec, turnon)
%
% UI NAME:
% SplineSG_Motion_Correction
%
% DESCRIPTION:
% The function first identifies the baseline shifts and spikes in the signal. The baseline shifts are corrected using
% a spline interpolation method. The remaining spikes are corrected by Savitzky-Golay filtering, which is a digital smoothing filter
% that substitutes each value of the signal series with a new value obtained by applying a cubic fitting to a subset of adjacent data points.
% The length of the subset is defined by the parameter FrameSize_sec.
% The method is described in the following paper.
% Citation: Jahani et al., Neurophotonics, 2018; doi: 10.1117/1.NPh.5.1.015003. 
% 
% INPUTS:
% data_d:        SNIRF object containing time course data
% mlActAuto:
% p:             Parameter p used in the spline interpolation. The value
%                recommended in the literature is 0.99. Use -1 if you want to skip this
%                motion correction.
% FrameSize_sec: The step lenght in seconds that a least-squares minimization will be applied using a cubic Savitzky-Golay filter.  
% turnon:        Optional argument to enable/disable this function in a processing stream chain
%
% OUTPUTS:
% data_d:        SNIRF object containing time course data after spline interpolation correction
%
% USAGE OPTIONS:
% SplineSG_Motion_Correction: dod = hmrR_MotionCorrectSplineSG_sim(dod, mlActAuto, p, FrameSize_sec, turnon)
%
% PARAMETERS:
% p: 0.99
% FrameSize_sec: 10
% turnon: 1
%
% 
% PREREQUISITES:
% Intensity_to_Delta_OD: dod = hmrR_Intensity2OD( intensity )
%
% LOG:
% Sahar Jahani, October 2017

function data_d = hmrR_MotionCorrectSplineSG_sim(data_d, mlActAuto, p, FrameSize_sec, turnon)

if ~exist('turnon','var')
   turnon = 1;
end
if turnon==0
    return;
end
if isempty(mlActAuto)
    mlActAuto = cell(length(data_d),1);
end

for iBlk = 1:length(data_d)

    dod = data_d(iBlk).GetDataTimeSeries();               
    data_d(iBlk).SetDataTimeSeries(dod);
    
end
Loading