diff --git a/src/batdetect2/cli/data.py b/src/batdetect2/cli/data.py index cf0698c..4b13224 100644 --- a/src/batdetect2/cli/data.py +++ b/src/batdetect2/cli/data.py @@ -137,6 +137,22 @@ def summary( "matching names will be excluded from the output." ), ) +@click.option( + "--apply-transforms/--no-apply-transforms", + default=True, + help=( + "Apply any configured sound event transforms to the annotations. " + "Defaults to True." + ), +) +@click.option( + "--apply-filters/--no-apply-filters", + default=True, + help=( + "Apply any configured sound event filters to the annotations. " + "Defaults to True." + ), +) def convert( dataset_config: Path, field: str | None = None, @@ -146,6 +162,8 @@ def convert( add_source_tag: bool = True, include_sources: list[str] | None = None, exclude_sources: list[str] | None = None, + apply_transforms: bool = True, + apply_filters: bool = True, ): """Convert a dataset config into soundevent annotation-set format. @@ -166,6 +184,8 @@ def convert( add_source_tag=add_source_tag, include_sources=include_sources, exclude_sources=exclude_sources, + apply_transforms=apply_transforms, + apply_filters=apply_filters, ) annotation_set = data.AnnotationSet( diff --git a/src/batdetect2/data/datasets.py b/src/batdetect2/data/datasets.py index 7f8ce7b..438c3e5 100644 --- a/src/batdetect2/data/datasets.py +++ b/src/batdetect2/data/datasets.py @@ -81,6 +81,8 @@ def load_dataset( add_source_tag: bool = True, include_sources: list[str] | None = None, exclude_sources: list[str] | None = None, + apply_transforms: bool = True, + apply_filters: bool = True, ) -> Dataset: """Load all clip annotations from the sources defined in a DatasetConfig.""" clip_annotations = [] @@ -121,13 +123,13 @@ def load_dataset( if add_source_tag: clip_annotation = insert_source_tag(clip_annotation, source) - if condition is not None: + if condition is not None and apply_filters: clip_annotation = filter_clip_annotation( clip_annotation, condition, ) - if transform is not None: + if transform is not None and apply_transforms: clip_annotation = transform_clip_annotation( clip_annotation, transform,