Commit 9cc9b9bb authored by Meryem Ayse Yucel's avatar Meryem Ayse Yucel
Browse files

dc offset for negative intensity (optional)

Added the following warning (/option): "Intensity signal has negative values. If you would like to add a dc offset, please click YES. If you would like to proceed with negative values, hit CANCEL."
parent 081d0149
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -23,6 +23,30 @@ dod = DataClass().empty();
for ii=1:length(intensity)
    dod(ii) = DataClass();
    d = intensity(ii).GetDataTimeSeries();
    
    % Optional (user prompt): Adding dc offset if intensity (d) has negative values
    if ~isempty(d<=0)
        quest = {'Intensity signal has negative values. If you would like to add a dc offset, please click YES. If you would like to proceed with negative values, hit CANCEL.'};
        dlgtitle = 'Warning';
        btn1 = 'YES';
        btn2 = 'CANCEL';
        detbtn = btn1;
        answer = questdlg(quest,dlgtitle,btn1,btn2,detbtn)
        switch answer
            case 'YES'
                for j = 1:size(d,2)
                    foo = d(:,j);
                    if ~isempty(foo<0)
                        d(:,j) = foo + abs(min(foo));
                        foo = d(:,j);
                    end
                    if ~isempty(foo == 0)
                        d(:,j) = foo + min(foo(foo > 0));
                    end
                end
        end
    end
    
    dm = mean(abs(d),1);
    nTpts = size(d,1);
    dod(ii).SetTime(intensity(ii).GetTime());