-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
362 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Features are computed by hctsa but not used | ||
|
||
# These are not relevant for stationary processes, but may be relevant for characterizing shorter series | ||
# (for a dataset containing time series all of the same length, these will be identical to the original features | ||
# (that do not have 'norm' appended to their names)) | ||
SB_BinaryStats_mean.longstretch1norm SB_BinaryStats_mean_longstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_mean.meanstretch1norm SB_BinaryStats_mean_meanstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_mean.stdstretch1norm SB_BinaryStats_mean_stdstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_mean.longstretch0norm SB_BinaryStats_mean_longstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_mean.meanstretch0norm SB_BinaryStats_mean_meanstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_mean.stdstretch0norm SB_BinaryStats_mean_stdstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_diff.longstretch1norm SB_BinaryStats_diff_longstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_diff.longstretch0norm SB_BinaryStats_diff_longstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_diff.meanstretch1norm SB_BinaryStats_diff_meanstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_diff.meanstretch0norm SB_BinaryStats_diff_meanstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_diff.stdstretch1norm SB_BinaryStats_diff_stdstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_diff.stdstretch0norm SB_BinaryStats_diff_stdstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_iqr.longstretch1norm SB_BinaryStats_iqr_longstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_iqr.longstretch0norm SB_BinaryStats_iqr_longstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_iqr.meanstretch1norm SB_BinaryStats_iqr_meanstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_iqr.meanstretch0norm SB_BinaryStats_iqr_meanstretch0norm symbolic,distribution,correlation | ||
SB_BinaryStats_iqr.stdstretch1norm SB_BinaryStats_iqr_stdstretch1norm symbolic,distribution,correlation | ||
SB_BinaryStats_iqr.stdstretch0norm SB_BinaryStats_iqr_stdstretch0norm symbolic,distribution,correlation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
% corrFun, the self-correlation function to measure: | ||
% (i) 'ac': normal linear autocorrelation function. Uses CO_AutoCorr to | ||
% calculate autocorrelations. | ||
% threshold, to cross: e.g., 0, 1/exp(1). | ||
% threshold, to cross. Examples: 0 [first zero crossing], 1/exp(1) [first 1/e crossing]. | ||
|
||
% ------------------------------------------------------------------------------ | ||
% Copyright (C) 2020, Ben D. Fulcher <[email protected]>, | ||
|
@@ -60,6 +60,8 @@ | |
switch corrFun | ||
case 'ac' | ||
% Autocorrelation at all time lags | ||
% (a little inefficient to not do it incrementally, but maybe Fourier method) | ||
% (does it anyway...) | ||
corrs = CO_AutoCorr(y,[],'Fourier'); | ||
otherwise | ||
error('Unknown correlation function ''%s''',corrFun); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ | |
% y -- should be the z-scored time series (Nx1 vector) | ||
% taus -- should be a vector of the time delays as above (mx1 vector) | ||
% e.g., [2] computes <x_i x_{i-2}> | ||
% e.g., [1,2] computes <x_i x_{i-1} x{i-2}> | ||
% e.g., [1,1,3] computes <x_i x_{i-1}^2 x{i-3}> | ||
% e.g., [1,2] computes <x_i x_{i-1} x_{i-2}> | ||
% e.g., [1,1,3] computes <x_i x_{i-1}^2 x_{i-3}> | ||
% e.g., [0,0,1] computes <x_i^3 x_{i-1}> | ||
% doAbs [opt] -- a boolean (0,1) -- if one, takes an absolute value before | ||
% taking the final mean -- useful for an odd number of | ||
% contributions to the sum. Default is to do this for odd | ||
|
@@ -27,10 +28,10 @@ | |
% taus vectors) the result will be near zero due to fluctuations | ||
% below the mean; even for highly-correlated signals. (doAbs) | ||
% | ||
% (*) doAbs = 1 is really a different operation that can't be compared with | ||
% the values obtained from taking doAbs = 0 (i.e., for odd lengths | ||
% (*) doAbs = true is really a different operation that can't be compared with | ||
% the values obtained from taking doAbs = false (i.e., for odd lengths | ||
% of taus) | ||
% (*) It can be helpful to look at nlac at each iteration. | ||
% (*) It can be helpful to look at nonlinearAC at each iteration. | ||
|
||
% ------------------------------------------------------------------------------ | ||
% Copyright (C) 2020, Ben D. Fulcher <[email protected]>, | ||
|
@@ -66,27 +67,29 @@ | |
% ------------------------------------------------------------------------------ | ||
if nargin < 3 || isempty(doAbs) % use default settings for doAbs | ||
if rem(length(taus),2) == 1 | ||
doAbs = 0; | ||
doAbs = false; | ||
else | ||
% Even number of time-lags | ||
doAbs = 1; % take abs, otherwise will be a very small number | ||
doAbs = true; % take abs, otherwise will be a very small number | ||
end | ||
end | ||
%------------------------------------------------------------------------------- | ||
|
||
N = length(y); % time-series length | ||
tmax = max(taus); % the maximum delay time | ||
tMax = max(taus); % the maximum delay time | ||
|
||
% Compute the autocorrelation sum iteratively | ||
nlac = y(tmax+1:N); | ||
nonlinearAC = y(tMax+1:N); | ||
for i = 1:length(taus) | ||
nlac = nlac.*y(tmax-taus(i)+1:N-taus(i)); | ||
nonlinearAC = nonlinearAC .* y(tMax-taus(i)+1:N-taus(i)); | ||
end | ||
|
||
%------------------------------------------------------------------------------- | ||
% Compute output | ||
if doAbs | ||
out = mean(abs(nlac)); | ||
out = mean(abs(nonlinearAC)); | ||
else | ||
out = mean(nlac); | ||
out = mean(nonlinearAC); | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function out = DN_HistogramAsymmetry(y,numBins,doSimple) | ||
% DN_HistogramAsymmetry Measures of distributional asymmetry | ||
% | ||
% Measures the asymmetry of the histogram distribution of the input data vector. | ||
% | ||
%---INPUTS: | ||
% | ||
% y, the input data vector. | ||
% numBins, the number of bins to use in the histogram. | ||
% doSimple, whether to use a simple binning method (linearly spaced bins). | ||
|
||
% ------------------------------------------------------------------------------ | ||
% Copyright (C) 2020, Ben D. Fulcher <[email protected]>, | ||
% <http://www.benfulcher.com> | ||
% | ||
% If you use this code for your research, please cite the following two papers: | ||
% | ||
% (1) B.D. Fulcher and N.S. Jones, "hctsa: A Computational Framework for Automated | ||
% Time-Series Phenotyping Using Massive Feature Extraction, Cell Systems 5: 527 (2017). | ||
% DOI: 10.1016/j.cels.2017.10.001 | ||
% | ||
% (2) B.D. Fulcher, M.A. Little, N.S. Jones, "Highly comparative time-series | ||
% analysis: the empirical structure of time series and their methods", | ||
% J. Roy. Soc. Interface 10(83) 20130048 (2013). | ||
% DOI: 10.1098/rsif.2013.0048 | ||
% | ||
% This function is free software: you can redistribute it and/or modify it under | ||
% the terms of the GNU General Public License as published by the Free Software | ||
% Foundation, either version 3 of the License, or (at your option) any later | ||
% version. | ||
% | ||
% This program is distributed in the hope that it will be useful, but WITHOUT | ||
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
% FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
% details. | ||
% | ||
% You should have received a copy of the GNU General Public License along with | ||
% this program. If not, see <http://www.gnu.org/licenses/>. | ||
% ------------------------------------------------------------------------------ | ||
|
||
%------------------------------------------------------------------------------- | ||
% Check inputs and set defaults: | ||
%------------------------------------------------------------------------------- | ||
if nargin < 2 | ||
numBins = 10; | ||
end | ||
if nargin < 3 | ||
doSimple = true; | ||
end | ||
|
||
%------------------------------------------------------------------------------- | ||
% Check z-score standardization (since it is assumed that positive and negative | ||
% values can be treated separately): | ||
iszscored = BF_iszscored(y); | ||
if ~iszscored | ||
warning('DN_HistogramAsymmetry assumes a z-scored (or standardized) input') | ||
end | ||
|
||
%------------------------------------------------------------------------------- | ||
% Compute the histogram separately from positive and negative values in the data: | ||
yPos = y(y > 0); | ||
yNeg = y(y < 0); | ||
if doSimple | ||
[countsPos,binEdgesPos] = BF_SimpleBinner(yPos,numBins); | ||
[countsNeg,binEdgesNeg] = BF_SimpleBinner(yNeg,numBins); | ||
else | ||
[countsPos,binEdgesPos] = histcounts(yPos,numBins); | ||
[countsNeg,binEdgesNeg] = histcounts(yNeg,numBins); | ||
end | ||
|
||
% Normalize by total counts: | ||
NnonZero = sum(y~=0); | ||
pPos = countsPos/NnonZero; | ||
pNeg = countsNeg/NnonZero; | ||
|
||
% Compute bin centers from bin edges: | ||
binCentersPos = mean([binEdgesPos(1:end-1); binEdgesPos(2:end)]); | ||
binCentersNeg = mean([binEdgesNeg(1:end-1); binEdgesNeg(2:end)]); | ||
|
||
% Histogram counts and overall density differences: | ||
out.densityDiff = sum(y > 0) - sum(y < 0); % measure of asymmetry about the mean | ||
out.modeProbPos = max(pPos); | ||
out.modeProbNeg = max(pNeg); | ||
out.modeDiff = out.modeProbPos - out.modeProbNeg; | ||
|
||
% Mean position of maximums (if multiple): | ||
out.posMode = mean(binCentersPos(pPos == out.modeProbPos)); | ||
out.negMode = mean(binCentersNeg(pNeg == out.modeProbNeg)); | ||
out.modeAsymmetry = out.posMode + out.negMode; | ||
|
||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.