|
| 1 | +# Ssm |
| 2 | + |
| 3 | +> Auto-generated documentation for [musicalgestures._ssm](https://github.com/fourMs/MGT-python/blob/master/musicalgestures/_ssm.py) module. |
| 4 | +
|
| 5 | +- [Mgt-python](../README.md#mgt-python) / [Modules](../MODULES.md#mgt-python-modules) / [Musicalgestures](index.md#musicalgestures) / Ssm |
| 6 | + - [mg_ssm](#mg_ssm) |
| 7 | + - [smooth_downsample_feature_sequence](#smooth_downsample_feature_sequence) |
| 8 | + |
| 9 | +## mg_ssm |
| 10 | + |
| 11 | +[[find in source code]](https://github.com/fourMs/MGT-python/blob/master/musicalgestures/_ssm.py#L43) |
| 12 | + |
| 13 | +```python |
| 14 | +def mg_ssm( |
| 15 | + self, |
| 16 | + features='motiongrams', |
| 17 | + filtertype='Regular', |
| 18 | + thresh=0.05, |
| 19 | + blur='None', |
| 20 | + norm=np.inf, |
| 21 | + threshold=0.001, |
| 22 | + cmap='gray_r', |
| 23 | + use_median=False, |
| 24 | + kernel_size=5, |
| 25 | + target_name=None, |
| 26 | + overwrite=False, |
| 27 | +): |
| 28 | +``` |
| 29 | + |
| 30 | +Compute Self-Similarity Matrix (SSM) by converting the input signal into a suitable feature sequence and comparing each element of the feature sequence with all other elements of the sequence. |
| 31 | +SSMs can be computed over different input features such as 'motiongrams', 'spectrogram', 'chromagram' and 'tempogram'. |
| 32 | + |
| 33 | +#### Arguments |
| 34 | + |
| 35 | +- `features` *str, optional* - Defines the type of features on which to compute SSM. Possible to compute SSM on 'motiongrams', 'spectrogram', 'chromagram' and 'tempogram'. Defaults to 'motiongrams'. |
| 36 | +- `filtertype` *str, optional* - 'Regular' turns all values below `thresh` to 0. 'Binary' turns all values below `thresh` to 0, above `thresh` to 1. 'Blob' removes individual pixels with erosion method. Defaults to 'Regular'. |
| 37 | +- `thresh` *float, optional* - Eliminates pixel values less than given threshold. Ranges from 0 to 1. Defaults to 0.05. |
| 38 | +- `blur` *str, optional* - 'Average' to apply a 10px * 10px blurring filter, 'None' otherwise. Defaults to 'None'. |
| 39 | +- `norm` *int, optional* - Normalize the columns of the feature sequence. Possible to compute Manhattan norm (1), Euclidean norm (2), Minimum norm (-np.inf), Maximum norm (np.inf), etc. Defaults to np.inf. |
| 40 | +- `threshold` *float, optional* - Only the columns with norm at least the amount of `threshold` indicated are normalized. Defaults to 0.001. |
| 41 | +- `cmap` *str, optional* - A Colormap instance or registered colormap name. The colormap maps the C values to colors. Defaults to 'gray_r'. |
| 42 | +- `use_median` *bool, optional* - If True the algorithm applies a median filter on the thresholded frame-difference stream. Defaults to False. |
| 43 | +- `kernel_size` *int, optional* - Size of the median filter (if `use_median=True`) or the erosion filter (if `filtertype='blob'`). Defaults to 5. |
| 44 | +- `target_name` *[type], optional* - Target output name for the SSM. Defaults to None. |
| 45 | +- `overwrite` *bool, optional* - Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False. |
| 46 | + |
| 47 | +#### Returns |
| 48 | + |
| 49 | +# if features='motiongrams': |
| 50 | +- `MgList` - An MgList pointing to the output SSM images (as MgImages). |
| 51 | +# else: |
| 52 | +- `MgImage` - An MgImage to the output SSM. |
| 53 | + |
| 54 | +## smooth_downsample_feature_sequence |
| 55 | + |
| 56 | +[[find in source code]](https://github.com/fourMs/MGT-python/blob/master/musicalgestures/_ssm.py#L16) |
| 57 | + |
| 58 | +```python |
| 59 | +def smooth_downsample_feature_sequence( |
| 60 | + X, |
| 61 | + sr, |
| 62 | + filt_len=41, |
| 63 | + down_sampling=10, |
| 64 | + w_type='boxcar', |
| 65 | +): |
| 66 | +``` |
| 67 | + |
| 68 | +Smoothes and downsamples a feature sequence. Smoothing is achieved by convolution with a filter kernel |
| 69 | + |
| 70 | +#### Arguments |
| 71 | + |
| 72 | +- `X` *np.ndarray* - Feature sequence. |
| 73 | +- `sr` *int* - Sampling rate. |
| 74 | +- `filt_len` *int, optional* - Length of smoothing filter. Defaults to 41. |
| 75 | +- `down_sampling` *int, optional* - Downsampling factor. Defaults to 10. |
| 76 | +- `w_type` *str, optional* - Window type of smoothing filter. Defaults to 'boxcar'. |
| 77 | + |
| 78 | +#### Returns |
| 79 | + |
| 80 | +- `X_smooth` *np.ndarray* - Smoothed and downsampled feature sequence. |
| 81 | +- `sr_feature` *scalar* - Sampling rate of `X_smooth`. |
0 commit comments