pyhctsa.operations.medical.porta¶
-
pyhctsa.operations.medical.porta(x, num_levels=
6, tau=1)¶ Compute Porta’s symbolic-dynamics word-type indices.
Quantizes the time series into a small number of levels and classifies consecutive length-3 “words” of symbols by their pattern of variation:
0V: no variation (all three symbols equal)1V: one variation (exactly one of the two transitions is flat)2LV: two like variations (both transitions move the same direction)2UV: two unlike variations (transitions move in opposite directions)
Originally developed for heart-rate-variability analysis, quantifying the complexity/regularity of the symbolic dynamics of RR interval sequences.
The levels are equal-width bins one robust standard deviation wide (for six levels),
s = IQR_TO_SIGMA * IQR(IQR_TO_SIGMA = 1/(2 Phi^{-1}(3/4))), centred on the median: the spanmedian +/- 3 sis divided intonum_levelsbins and values beyond it fall in the end bins. Porta et al. divide the full range[min, max]into equal bins [2], after replacing ectopic beats, artifacts and jumps of more than 30% in the RR series. Without that cleaning one outlier widens every range bin: a single 10-SD spike in 1000 samples moves the word-type percentages by 25-55 points, and the percentages then also track the shape of the value distribution. The robust span is the analogue of the original for uncleaned data: unchanged by a few outliers, and (for Gaussian data) about as wide as the range bins of a series of about 1000 samples.References
- Parameters:¶
- x : array-like¶
The input time series.
- num_levels : int, optional¶
The number of quantization levels spanning
median +/- 3 s. Default is 6, as in the original papers.- tau : int or str, optional¶
The step between the symbols of a word, in samples: an integer, or a rule for
get_tau()(e.g.'ac1e'). The words are(s_t, s_{t+tau}, s_{t+2 tau})at everyt, with the levels set from the whole series, which pools thetauphases of the series sampled everytausamples. Default 1. All outputs are NaN when a rule cannot set the delay.
- Returns:¶
Dictionary containing the percentage of length-3 words of each type:
’pV0’ : percentage of 0V words
’pV1’ : percentage of 1V words
’pV2LV’ : percentage of 2LV words
’pV2UV’ : percentage of 2UV words
- Return type:¶
dict