Data Segments and Channels ========================== Time-series segmentation ------------------------ In order to make the algorithm faster, the time-series is divided into smaller segments with a length in seconds set by the ``segment_length`` parameter. The segmentation can also be done such that consecutive segments can overlap, thereby removing filtering artifacts and edge effects during the construction of the power spectral density and the excess power search. The length in seconds by which 2 consecutive segments are separated is set by the ``segment_stride`` parameter. In some part of the algorithm, the parameters will be used in sample units (not seconds). The conversion can be done straightforwardly using the ``sample_rate`` metadata from the ``ts_data`` time-series object as follows:: # Define segment length for PSD estimation in sample unit seg_len = int(segment_length * ts_data.sample_rate) # Define separation between consecutive segments in sample unit seg_stride = int(segment_stride * ts_data.sample_rate) Narrow band channels -------------------- We then check if the maximum frequency in the filter bank is defined, that is the frequency of the last filter from the filter bank. If the value is not defined, we set it to be equal to the Nyquist frequency, that is half the sampling rate, which makes sense as any larger signal would not be identifiable:: # Check if tile maximum frequency is not defined if fmax is None or fmax>sample_rate/2.: # Set the tile maximum frequency equal to the Nyquist frequency fmax = sample_rate / 2.0 Depending whether the bandwidth of the finest filter, ``band``, or the total number of channels, ``nchans``, is defined, one can then determined the filter settings easily as the bandwidth of the finest filter effectively corresponds to the bandwidth of one individual channel. Therefore, if the bandwidth of the finest filter is defined, the total number of channels is set to be equal to the total frequency band divived by a single channel's bandwidth. Conversely, if the channel's bandwidth is not defined but the total number of channels is, the smallest bandwidth will therefore correspond to the frequency band divided by the number of channels:: # Check whether or not tile bandwidth and channel are defined if band is None and nchans is None: # Exit program with error message exit("Either bandwidth or number of channels must be specified...") else: # Check if tile maximum frequency larger than its minimum frequency assert fmax >= fmin # Define spectral band of data data_band = fmax - fmin # Check whether tile bandwidth or channel is defined if band is not None: # Define number of possible filter bands nchans = int(data_band / band) elif nchans is not None: # Define filter bandwidth band = data_band / nchans # Check if number of channels is superior than unity assert nchans > 1 nchans -= 1