scatseisnet#

Deep scattering transform clustering on segmented time series.

This package implements the deep scattering transform clustering on segmented time series. The deep scattering transform is a deep learning architecture that can be used to extract features from time series.

Terms of use
Copyright (C) 2023 Léonard Seydoux.

This program 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 <https://www.gnu.org/licenses/>.

Submodules#

Classes#

ScatteringNetwork

Scattering network graph.

Package Contents#

class scatseisnet.ScatteringNetwork(*layer_kwargs: dict, bins: int = 128, sampling_rate: float = 1.0, verbose: bool = False)[source]#

Scattering network graph.

Parameters:
  • layer_kwargs (dict) – The keyword argiments of each filter bank keyword arguments, in the form of a :series of dict objects with the keyword arguments for ComplexMorletBank. The number of network layers is defined by the number of arguments. Please see the ComplexMorletBank documentation for more information about the keyword arguments themselves.

  • bins (int, optional) – Number of time samples per signal windows. By default, this value is 128. Note that once set, the value cannot be changed.

  • sampling_rate (float, optional) – Input data sampling rate in Hertz. This is useful to keep track of physical frequencies in the filterbanks properties. The default value is 1.0 (reduced frequency).

sampling_rate = 1.0#
bins = 128#
verbose = False#
banks#
taper#
__len__() int[source]#

Number of layers (or depth) of the scattering network.

__repr__() str[source]#

String representation of the scattering network.

transform_segment(segment: numpy.ndarray, reduce_type: Callable | None = None) list[source]#

Scattering network transformation.

This function transforms a single segment with the scattering network. The reduce_type parameter defines the pooling operation. It can be either max, avg, or med.

Note

If the reduce_type parameter is not defined, the function returns the scalogram of each layer of the scattering network (i.e. the continuous wavelet transform of the input segment at each layer) without any pooling operation.

Parameters:
  • segment (numpy.ndarray) – The input segment time series to calculate the scattering coefficients from. The shape of the array must be (bins, n_channels), where bins is the number of time samples per segment and n_channels is the number of channels. The number of channels can be 1 or more.

  • reduce_type (callable, optional) – The reduction function (e.g. numpy.mean()). If not defined, the function returns the scalogram of each layer of the scattering network, without any pooling operation.

Returns:

scattering_coefficients – The scattering coefficients per layer of the scattering network.

Return type:

list of array-like

Examples

>>> import numpy as np
>>> from scatseisnet import ScatteringNetwork
>>> layer_kwargs = [
...     {"octaves": 8, "resolution": 8},
...     {"octaves": 12, "resolution": 1},
... ]
>>> network = ScatteringNetwork(*layer_kwargs)
>>> segment = np.random.randn(128)
>>> scattering_coefficients = network.transform_segment(segment, reduce_type=np.max)
>>> len(scattering_coefficients)
2
>>> scattering_coefficients[0].shape
(64,)
>>> scattering_coefficients[1].shape
(64, 12)
transform(segments: numpy.ndarray, taper_alpha=None, reduce_type: Callable | None = None) list[source]#

Transform a set of segments.

This function is a wrapper to loop over a series of segments with the transform_segment() method. Please refer to this method for more information.

Parameters:
  • segments (numpy.ndarray) – The input segment time series to calculate the scattering coefficients from. The shape of the array must be (n_segments, bins, n_channels), where bins is the number of time samples per segment and n_channels is the number of channels. The number of channels can be 1 or more.

  • taper_alpha (float, optional) – Tapering factor for the time domain. If None, no tapering is applied (default None).

  • reduce_type (callable, optional) – The reduction function (e.g. numpy.mean()). If not defined, the function returns the scalogram of each layer of the scattering network, without any pooling operation.

Returns:

scattering_coefficients – The scattering coefficients per layer of the scattering network.

Return type:

list of array-like

Examples

>>> import numpy as np
>>> from scatseisnet import ScatteringNetwork
>>> layer_kwargs = [
...     {"octaves": 8, "resolution": 8},
...     {"octaves": 12, "resolution": 1},
... ]
>>> network = ScatteringNetwork(*layer_kwargs)
>>> segments = np.random.randn(10, 128)
>>> scattering_coefficients = network.transform(segments, np.max)
>>> len(scattering_coefficients)
2
>>> scattering_coefficients[0].shape
(10, 64)
>>> scattering_coefficients[1].shape
(10, 64, 12)