Slicing (Stage A1)

Slice continuous song recordings into fixed-length syllable spectrograms (Stage A1).

This is an optional alternative to Stage A (song_phenotyping.ingestion) that cuts audio into equal-duration windows of slice_length milliseconds rather than segmenting by detected syllable boundaries. The output HDF5 files are compatible with Stage B (song_phenotyping.flattening).

Public API

song_phenotyping.slicing.main()[source]

Main slicing pipeline with configurable parameters.

song_phenotyping.slicing.process_slicing_pipeline(pipeline_name, settings)[source]

Process a single slicing pipeline (evsonganaly or wseg).

Parameters:
  • pipeline_name (str)

  • settings (dict)

song_phenotyping.slicing.slice_syllable_files_from_evsonganaly(wav_directory=None, save_path=None, batch_file_naming='batch.txt.labeled', params=None, verbose=False, slice_length=None, overwrite=False, songs_per_bird=20, bird_subset=None, copy_locally=False, prefer_local=True, preferred_subdirs=None)[source]

Slice evsonganaly recordings into fixed-length spectrogram windows.

Discovers audio and metadata files via song_phenotyping.ingestion.filepaths_from_evsonganaly(), then cuts each recording into windows of slice_length milliseconds and saves the result as HDF5 files under <save_path>/<bird>/syllable_data/slice_specs/.

Parameters:
  • wav_directory (str or None, optional) – Root directory containing evsonganaly-format WAV and metadata files.

  • save_path (str or None, optional) – Output root directory where bird subdirectories are created.

  • batch_file_naming (str, optional) – Filename suffix for evsonganaly batch files. Default is 'batch.txt.labeled'.

  • params (SpectrogramParams or None, optional) – Spectrogram computation parameters. Uses defaults when None.

  • verbose (bool, optional) – Enable verbose per-file logging. Default is False.

  • slice_length (float or None, optional) – Window length in milliseconds. Overrides params.slice_length when provided.

  • overwrite (bool, optional) – When True, reprocess files even if output already exists. Default is False.

  • songs_per_bird (int, optional) – Maximum number of songs to process per bird. Default is 20.

  • bird_subset (list of str or None, optional) – Process only these bird IDs. All birds are processed when None.

  • copy_locally (bool, optional) – Copy audio files to local cache before processing. Default is False.

  • prefer_local (bool, optional) – Prefer locally-cached copies of files. Default is True.

  • preferred_subdirs (list of str or None, optional) – Preferred subdirectory names when searching for audio files.

song_phenotyping.slicing.slice_syllable_files_from_wseg(seg_directory=None, save_path=None, file_ext='.wav.not.mat', params=None, verbose=False, songs_per_bird=20, bird_subset=None, song_or_call='song', copy_locally=False, prefer_local=True)[source]

Slice wseg-segmented recordings into fixed-length spectrogram windows.

Discovers segmentation and audio files via song_phenotyping.ingestion.filepaths_from_wseg(), then cuts each recording into windows of params.slice_length milliseconds.

Parameters:
  • seg_directory (str or None, optional) – Root directory containing wseg segmentation files (<bird>/song/<file>.wav.not.mat).

  • save_path (str or None, optional) – Output root directory where bird subdirectories are created.

  • file_ext (str, optional) – Extension of wseg segmentation files. Default is '.wav.not.mat'.

  • params (SpectrogramParams or None, optional) – Spectrogram computation parameters. Uses defaults when None.

  • verbose (bool, optional) – Enable verbose per-file logging. Default is False.

  • songs_per_bird (int, optional) – Maximum number of songs to process per bird. Default is 20.

  • bird_subset (list of str or None, optional) – Process only these bird IDs. All birds are processed when None.

  • song_or_call ({'song', 'call'}, optional) – Whether to process song or call recordings. Default is 'song'.

  • copy_locally (bool, optional) – Copy audio files to local cache before processing. Default is False.

  • prefer_local (bool, optional) – Prefer locally-cached copies of files. Default is True.