82template <ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = std::vector<std::vector<
double>>>
96 uint32_t hop_size = 256,
113 this->set_parameter(
"scope", config.
scope);
135 return Reflect::get_enum_names_lowercase<ExtractionMethod>();
155 this->set_parameter(
"method", method_name);
216 return Reflect::string_to_enum_or_throw_case_insensitive<ExtractionMethod>(str,
"ExtractionMethod");
226 if (!
input.has_container())
230 if (numeric_data.empty())
232 for (
const auto& span : numeric_data) {
236 }
catch (
const std::exception& e) {
248 return "FeatureExtractor";
263 std::vector<std::span<const double>>
channels;
264 channels.reserve(numeric_data.size());
265 for (
auto& s : numeric_data)
266 channels.emplace_back(s.data(), s.size());
268 std::vector<std::vector<double>> extracted_data;
274 this->
template get_parameter_or_default<double>(
"energy_threshold", 0.1),
280 this->
template get_parameter_or_default<double>(
"threshold", 0.1),
281 this->
template get_parameter_or_default<double>(
"min_distance", 10.0),
282 this->
template get_parameter_or_default<uint32_t>(
"region_size", 256));
287 this->
template get_parameter_or_default<double>(
"std_dev_threshold", 2.0),
293 this->
template get_parameter_or_default<double>(
"spectral_threshold", 0.1),
299 this->
template get_parameter_or_default<double>(
"mean_multiplier", 1.5),
306 this->
template get_parameter_or_default<double>(
"overlap", 0.5));
311 this->
template get_parameter_or_default<double>(
"threshold", 0.0),
312 this->
template get_parameter_or_default<double>(
"min_distance", 1.0),
313 this->
template get_parameter_or_default<uint32_t>(
"region_size", 1));
318 this->
template get_parameter_or_default<double>(
"silence_threshold", 0.01),
319 this->
template get_parameter_or_default<uint32_t>(
"min_duration", 1024),
325 this->
template get_parameter_or_default<double>(
"threshold", 0.3),
326 this->
template get_parameter_or_default<uint32_t>(
"region_size", 512),
327 this->
template get_parameter_or_default<uint32_t>(
"fft_window_size", 1024),
335 output_type output = this->convert_result(extracted_data, structure_info);
337 output.template set_metadata<std::string>(
"extractor_type",
"FeatureExtractor");
339 output.template set_metadata<uint32_t>(
"window_size",
static_cast<uint32_t
>(
m_window_size));
340 output.template set_metadata<uint32_t>(
"hop_size",
static_cast<uint32_t
>(
m_hop_size));
341 output.template set_metadata<size_t>(
"extracted_samples", extracted_data.size());
345 }
catch (
const std::exception& e) {
356 if (
name ==
"method") {
357 if (
auto result = safe_any_cast<std::string>(
value)) {
361 if (
auto result = safe_any_cast<ExtractionMethod>(
value)) {
368 if (
name ==
"window_size") {
369 if (
auto result = safe_any_cast<uint32_t>(
value)) {
375 if (
name ==
"hop_size") {
376 if (
auto result = safe_any_cast<uint32_t>(
value)) {
388 if (
name ==
"method") {
391 if (
name ==
"window_size") {
394 if (
name ==
"hop_size") {
#define MF_ERROR(comp, ctx,...)
Core::GlobalInputConfig input
static std::span< double > extract_numeric_data(const T &compute_data)
extract numeric data from single-variant types
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...
Types that need an associated SignalSourceContainer to extract data.
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
bool validate_window_parameters(uint32_t window_size, uint32_t hop_size, size_t data_size) noexcept
Validate window/hop parameters for windowed processing.
std::vector< Keypoint > extract_peaks(std::span< const float > response, uint32_t w, uint32_t h, float threshold, uint32_t nms_radius)
Extract peaks from a response map via non-maximum suppression.
std::string enum_to_lowercase_string(EnumType value) noexcept
Universal enum to lowercase string converter using magic_enum.
ExtractionType
Categories of extraction operations for discovery and organization.
@ FEATURE_GUIDED
Extract based on feature analysis.
std::vector< std::vector< double > > extract_high_energy(const std::vector< std::span< const double > > &channels, double energy_threshold, uint32_t window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_zero_crossings(const std::vector< std::span< const double > > &channels, double threshold, double min_distance, uint32_t region_size)
std::vector< std::vector< double > > extract_outliers(const std::vector< std::span< const double > > &channels, double std_dev_threshold, uint32_t window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_silence(const std::vector< std::span< const double > > &channels, double silence_threshold, uint32_t min_duration, uint32_t window_size, uint32_t hop_size)
ExtractionMethod
Supported extraction methods for FeatureExtractor.
@ ABOVE_MEAN_DATA
Extract data above statistical mean.
@ SILENCE_DATA
Extract actual silent regions.
@ PEAK_DATA
Extract data around detected peaks.
@ OUTLIER_DATA
Extract data from statistical outlier regions.
@ ZERO_CROSSING_DATA
Extract actual data at zero crossing points.
@ HIGH_ENERGY_DATA
Extract data from high-energy regions.
@ HIGH_SPECTRAL_DATA
Extract data from high spectral energy regions.
@ OVERLAPPING_WINDOWS
Extract overlapping windowed data.
@ ONSET_DATA
Extract actual onset/transient regions.
std::vector< std::vector< double > > extract_onsets(const std::vector< std::span< const double > > &channels, double threshold, uint32_t region_size, uint32_t fft_window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_high_spectral(const std::vector< std::span< const double > > &channels, double spectral_threshold, uint32_t window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_overlapping_windows(const std::vector< std::span< const double > > &channels, uint32_t window_size, double overlap)
std::vector< std::vector< double > > extract_above_mean(const std::vector< std::span< const double > > &channels, double mean_multiplier, uint32_t window_size, uint32_t hop_size)
ExtractionScope
Scope control for extraction operations.
@ FULL_DATA
Extract all available data.
Dimensions, modality, source type, and optional Composite field schema.
Input/Output container for computation pipeline data flow with structure preservation.