MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ analyze_implementation()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = Eigen::VectorXd>
output_type MayaFlux::Yantra::EnergyAnalyzer< InputType, OutputType >::analyze_implementation ( const input_type input)
inlineoverrideprotectedvirtual

Core analysis implementation - creates analysis result AND pipeline output.

Parameters
inputInput data wrapped in IO container
Returns
Pipeline output (data flow for chaining operations)

Implements MayaFlux::Yantra::UniversalAnalyzer< InputType, OutputType >.

Definition at line 301 of file EnergyAnalyzer.hpp.

302 {
303 try {
304 auto [data_span, structure_info] = OperationHelper::extract_structured_double(
305 const_cast<input_type&>(input));
306
307 std::vector<std::span<const double>> channel_spans;
308 for (auto& span : data_span)
309 channel_spans.emplace_back(span.data(), span.size());
310
311 for (const auto& channel_span : channel_spans) {
312 if (channel_span.size() < m_window_size) {
313 throw std::runtime_error("One or more channels in input data are smaller than window size (" + std::to_string(m_window_size) + ")");
314 }
315 }
316
317 std::vector<std::vector<double>> energy_values;
318 energy_values.reserve(channel_spans.size());
319 for (const auto& channel_span : channel_spans) {
320 energy_values.push_back(compute_energy_values(channel_span, m_method));
321 }
322
323 EnergyAnalysis analysis_result = create_analysis_result(
324 energy_values, channel_spans, structure_info);
325
326 this->store_current_analysis(analysis_result);
327
328 return create_pipeline_output(input, analysis_result, structure_info);
329 } catch (const std::exception& e) {
330 std::cerr << "Energy analysis failed: " << e.what() << '\n';
331 output_type error_result;
332 error_result.metadata = input.metadata;
333 error_result.metadata["error"] = std::string("Analysis failed: ") + e.what();
334 return error_result;
335 }
336 }
output_type create_pipeline_output(const input_type &input, const EnergyAnalysis &analysis_result, DataStructureInfo &info)
Create pipeline output from input and energy values.
EnergyAnalysis create_analysis_result(const std::vector< std::vector< double > > &energy_values, std::vector< std::span< const double > > original_data, const DataStructureInfo &) const
Create comprehensive analysis result from energy computation.
std::vector< double > compute_energy_values(std::span< const double > data, EnergyMethod method) const
Compute energy values using span (zero-copy processing)
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from IO container or direct ComputeData with automatic container handl...
void store_current_analysis(AnalysisResultType &&result) const
std::unordered_map< std::string, std::any > metadata
Associated metadata.
Definition DataIO.hpp:28

References MayaFlux::Yantra::IO< T >::metadata.