22#include "spectrum_types.h"
23#include "spectrum_state.h"
24#include "io/decimal_comma.h"
30#include "filtering/filter.h"
31#include "filtering/filter_fft.h"
32#include "filtering/filter_savgol.h"
34#include "detection/detection_method.h"
35#include "detection/detection_method_localmax.h"
37#include "segmentation/segmentation_method.h"
38#include "segmentation/segmentation_method_localmin.h"
39#include "segmentation/segmentation_method_inflection.h"
41constexpr channel_t spectrum_max_channels = 16;
49 size_t m_samples{ 0 };
50 size_t m_storage{ 0 };
52 spectrum_unit_t* m_indices;
53 spectrum_unit_t* m_wavelengths;
54 spectrum_unit_t* m_intensities[spectrum_max_channels];
56 spectrum_unit_t* m_filtered_intensities[spectrum_max_channels];
57 std::span<complex_t> m_freq[spectrum_max_channels];
58 std::span<derivation_t> m_derivation[spectrum_max_channels];
60 minmax_t m_extremas[spectrum_max_channels];
61 std::vector<peak> m_peaks[spectrum_max_channels];
63 std::unique_ptr<fbgsense::filtering::filter> m_filter;
64 std::unique_ptr<fbgsense::detection::detection_method> m_detection_method;
65 std::unique_ptr<fbgsense::segmentation::segmentation_method> m_segmentation_method;
67 inline static constexpr size_t to_index(channel_t channel)
73 spectrum(
size_t storage,
size_t samples);
163 void filter(channel_t channel, std::initializer_list<parameter_t> params);
168 void detect(channel_t channel, std::initializer_list<parameter_t> params);
173 std::vector<region_t>
segment(channel_t channel, std::initializer_list<parameter_t> params);
184 bool perform(channel_t channel, std::initializer_list<parameter_t> filteringParams, std::initializer_list<parameter_t> detectionParams, std::initializer_list<parameter_t> segmentationParams,
fit_settings_t fitSettings);
189 void perform(std::initializer_list<parameter_t> filteringParams, std::initializer_list<parameter_t> detectionParams, std::initializer_list<parameter_t> segmentationParams,
fit_settings_t fitSettings);
199 void print(std::ostream& s, std::string delimiter =
"\t");
Data structure holding information about peak's properties.
Definition: peak.h:18
Provides support for custom computation implementations.
Definition: processor.h:17
Data structure providing access to the implemented method.
Definition: spectrum.h:47
spectrum_unit_t * get_wavelengths()
Get wavelength array. This array is shared across all intensities in the spectrum.
bool is_noise(channel_t channel)
Checks if the signal intensity is within reasonable range.
void set_detection_method(processor< fbgsense::detection::detection_method > &&type)
Set custom detection method processor.
void set_segmentation_method(segment_type type)
Set the method that will segment the spectrum into peak regions. The default method is segment_type::...
void set_detection_method(processor< fbgsense::segmentation::segmentation_method > &&type)
Set custom segmentation method processor.
void perform(std::initializer_list< parameter_t > filteringParams, std::initializer_list< parameter_t > detectionParams, std::initializer_list< parameter_t > segmentationParams, fit_settings_t fitSettings)
Perform every step of calculation for all channels.
peak fit(channel_t channel, fit_settings_t fitSettings, region_t region)
Fit a function on the specified dataset using least squares technique.
void clean()
Clear found peaks.
minmax_t get_wavelength_bounds()
Get lowest and highest wavelength value.
void recalculate(channel_t channel)
Find global extremas.
std::vector< region_t > segment(channel_t channel, std::initializer_list< parameter_t > params)
Find peak regions of interest (ROI).
std::vector< peak > get_peaks(channel_t channel)
Get peaks of specific channel.
void print(std::ostream &s, std::string delimiter="\t")
Print peaks to the specified stream.
void filter(channel_t channel, std::initializer_list< parameter_t > params)
Filtering process.
spectrum_unit_t * get_filtered_intensities(channel_t channel)
Get filtered intensities array for the specified channel.
size_t get_samples_count()
Get number of samples.
void set_filter(processor< fbgsense::filtering::filter > &&type)
Set custom filtering processor.
bool perform(channel_t channel, std::initializer_list< parameter_t > filteringParams, std::initializer_list< parameter_t > detectionParams, std::initializer_list< parameter_t > segmentationParams, fit_settings_t fitSettings)
Perform every step of calculation on the specific channel.
void detect(channel_t channel, std::initializer_list< parameter_t > params)
Peak detection process.
void set_filter(filter_type type)
Set the filter that will remove noise from the spectrum. The default is filter_type::FFT.
spectrum_unit_t * get_source_intensities(channel_t channel)
Get source intensities array for the specified channel.
void set_detection_method(detection_type type)
Set the detection method that will find potential peaks. The default method is detection_type::LOCAL_...
spectrum_point_t get_spectrum_point(channel_t channel, size_t index)
Get a single point from spectrum channel in form of a tuple.
spectrum_state get_spectrum_state(channel_t channel)
Get internal data structures for the given channel.
std::vector< peak > get_peaks()
Get flattened list of peaks.
size_t get_storage_size()
Get size of physical storage array.
static channel_t get_channel_count()
Get number of channels.
Definition: spectrum_types.h:67
Definition: spectrum_types.h:24
Definition: spectrum_types.h:18
Data structure reflecting spectrum's current state. Used in processors.
Definition: spectrum_state.h:19