• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paulmthompson / WhiskerToolbox / 18914877332

29 Oct 2025 03:47PM UTC coverage: 73.148% (+0.1%) from 73.01%
18914877332

push

github

paulmthompson
added UI for interval peak detection

56798 of 77648 relevant lines covered (73.15%)

44492.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/src/DataManager/transforms/TransformRegistry.cpp
1
#include "TransformRegistry.hpp"
2

3
#include "transforms/AnalogTimeSeries/AnalogFilter/analog_filter.hpp"
4
#include "transforms/AnalogTimeSeries/AnalogHilbertPhase/analog_hilbert_phase.hpp"
5
#include "transforms/AnalogTimeSeries/Analog_Event_Threshold/analog_event_threshold.hpp"
6
#include "transforms/AnalogTimeSeries/Analog_Interval_Peak/analog_interval_peak.hpp"
7
#include "transforms/AnalogTimeSeries/Analog_Interval_Threshold/analog_interval_threshold.hpp"
8
#include "transforms/AnalogTimeSeries/Analog_Scaling/analog_scaling.hpp"
9
#include "transforms/DigitalIntervalSeries/Digital_Interval_Group/digital_interval_group.hpp"
10
#include "transforms/DigitalIntervalSeries/Digital_Interval_Boolean/digital_interval_boolean.hpp"
11
#include "transforms/Lines/Line_Alignment/line_alignment.hpp"
12
#include "transforms/Lines/Line_Angle/line_angle.hpp"
13
#include "transforms/Lines/Line_Base_Flip/line_base_flip.hpp"
14
#include "transforms/Lines/Line_Clip/line_clip.hpp"
15
#include "transforms/Lines/Line_Curvature/line_curvature.hpp"
16
#include "transforms/Lines/Line_Group_To_Intervals/line_group_to_intervals.hpp"
17
#include "transforms/Lines/Line_Index_Grouping/line_index_grouping.hpp"
18
#include "transforms/Lines/Line_Min_Point_Dist/line_min_point_dist.hpp"
19
#include "transforms/Lines/Line_Point_Extraction/line_point_extraction.hpp"
20
#include "transforms/Lines/Line_Proximity_Grouping/line_proximity_grouping.hpp"
21
#include "transforms/Lines/Line_Kalman_Grouping/line_kalman_grouping.hpp"
22
#include "transforms/Lines/Line_Outlier_Detection/line_outlier_detection.hpp"
23
#include "transforms/Lines/Line_Resample/line_resample.hpp"
24
#include "transforms/Lines/Line_Subsegment/line_subsegment.hpp"
25
#include "transforms/Points/Point_Particle_Filter/point_particle_filter.hpp"
26
#include "transforms/Masks/Mask_Area/mask_area.hpp"
27
#include "transforms/Masks/Mask_Centroid/mask_centroid.hpp"
28
#include "transforms/Masks/Mask_Connected_Component/mask_connected_component.hpp"
29
#include "transforms/Masks/Mask_Hole_Filling/mask_hole_filling.hpp"
30
#include "transforms/Masks/Mask_Median_Filter/mask_median_filter.hpp"
31
#include "transforms/Masks/Mask_Principal_Axis/mask_principal_axis.hpp"
32
#include "transforms/Masks/Mask_Skeletonize/mask_skeletonize.hpp"
33
#include "transforms/Masks/Mask_To_Line/mask_to_line.hpp"
34
#include "transforms/Media/whisker_tracing.hpp"
35

36
#include <iostream>// For init messages
37
#include <map>
38
#include <memory>// unique_ptr
39
#include <string>
40
#include <typeindex>
41
#include <variant>// Needed for the public interface
42
#include <vector>
43

44

45
TransformRegistry::TransformRegistry() {
79✔
46

47
    std::cout << "Initializing Operation Registry..." << std::endl;
79✔
48

49
    _registerOperation(std::make_unique<MaskAreaOperation>());
79✔
50
    _registerOperation(std::make_unique<MaskCentroidOperation>());
79✔
51
    _registerOperation(std::make_unique<MaskConnectedComponentOperation>());
79✔
52
    _registerOperation(std::make_unique<MaskHoleFillingOperation>());
79✔
53
    _registerOperation(std::make_unique<MaskMedianFilterOperation>());
79✔
54
    _registerOperation(std::make_unique<MaskPrincipalAxisOperation>());
79✔
55
    _registerOperation(std::make_unique<MaskToLineOperation>());
79✔
56
    _registerOperation(std::make_unique<MaskSkeletonizeOperation>());
79✔
57
    _registerOperation(std::make_unique<EventThresholdOperation>());
79✔
58
    _registerOperation(std::make_unique<IntervalThresholdOperation>());
79✔
59
    _registerOperation(std::make_unique<AnalogIntervalPeakOperation>());
79✔
60
    _registerOperation(std::make_unique<HilbertPhaseOperation>());
79✔
61
    _registerOperation(std::make_unique<AnalogScalingOperation>());
79✔
62
    _registerOperation(std::make_unique<LineAngleOperation>());
79✔
63
    _registerOperation(std::make_unique<LineMinPointDistOperation>());
79✔
64
    _registerOperation(std::make_unique<LineAlignmentOperation>());
79✔
65
    _registerOperation(std::make_unique<LineBaseFlipTransform>());
79✔
66
    _registerOperation(std::make_unique<LineResampleOperation>());
79✔
67
    _registerOperation(std::make_unique<LineCurvatureOperation>());
79✔
68
    _registerOperation(std::make_unique<LineSubsegmentOperation>());
79✔
69
    _registerOperation(std::make_unique<LinePointExtractionOperation>());
79✔
70
    _registerOperation(std::make_unique<LineClipOperation>());
79✔
71
    _registerOperation(std::make_unique<LineProximityGroupingOperation>());
79✔
72
    _registerOperation(std::make_unique<LineKalmanGroupingOperation>());
79✔
73
    _registerOperation(std::make_unique<LineOutlierDetectionOperation>());
79✔
74
    _registerOperation(std::make_unique<LineIndexGroupingOperation>());
79✔
75
    _registerOperation(std::make_unique<LineGroupToIntervalsOperation>());
79✔
76
    _registerOperation(std::make_unique<PointParticleFilterOperation>());
79✔
77
    _registerOperation(std::make_unique<GroupOperation>());
79✔
78
    _registerOperation(std::make_unique<BooleanOperation>());
79✔
79
    _registerOperation(std::make_unique<AnalogFilterOperation>());
79✔
80
    _registerOperation(std::make_unique<WhiskerTracingOperation>());
79✔
81

82
    _computeApplicableOperations();
79✔
83
    std::cout << "Operation Registry Initialized." << std::endl;
79✔
84
}
79✔
85

86
std::vector<std::string> TransformRegistry::getOperationNamesForVariant(DataTypeVariant const & dataVariant) const {
×
87
    // Get the type_index of the type currently stored in the variant.
88
    // Note: std::variant::type() returns the type_index of the *alternative*,
89
    // which in our case IS the std::shared_ptr<T>. This matches what
90
    // getTargetInputTypeIndex() should return.
91
    auto current_type_index = std::visit([](auto & v) -> std::type_index { return typeid(v); }, dataVariant);
×
92

93
    // Look up the type index in the pre-computed map
94
    auto it = type_index_to_op_names_.find(current_type_index);
×
95
    if (it != type_index_to_op_names_.end()) {
×
96
        return it->second;// Return the pre-computed list of names
×
97
    } else {
98
        // No registered operation targets this specific type_index.
99
        // This is normal if a data type has no operations defined for it.
100
        return {};// Return empty vector
×
101
    }
102
}
103

104
TransformOperation * TransformRegistry::findOperationByName(std::string const & operation_name) const {
393✔
105
    auto it = name_to_operation_.find(operation_name);
393✔
106
    if (it != name_to_operation_.end()) {
393✔
107
        return it->second;
393✔
108
    } else {
109
        // std::cerr << "Warning: Requested operation name not found: '" << operation_name << "'" << std::endl;
110
        return nullptr;
×
111
    }
112
}
113

114
void TransformRegistry::_registerOperation(std::unique_ptr<TransformOperation> op) {
2,528✔
115
    if (!op) return;
2,528✔
116
    std::string op_name = op->getName();
2,528✔
117
    if (name_to_operation_.count(op_name)) {
2,528✔
118
        std::cerr << "Warning: Operation with name '" << op_name << "' already registered." << std::endl;
×
119
        return;
×
120
    }
121
    std::cout << "Registering operation: " << op_name
122
              << " (Targets type index: " << op->getTargetInputTypeIndex().name() << ")"// Debug info
7,584✔
123
              << std::endl;
5,056✔
124
    name_to_operation_[op_name] = op.get();
2,528✔
125
    all_operations_.push_back(std::move(op));
2,528✔
126
}
2,528✔
127

128
void TransformRegistry::_computeApplicableOperations() {
79✔
129
    std::cout << "Computing applicable operations based on registered operations..." << std::endl;
79✔
130
    type_index_to_op_names_.clear();// Start fresh
79✔
131

132
    for (auto const & op_ptr: all_operations_) {
2,607✔
133
        if (!op_ptr) continue;
2,528✔
134
        // Get the type index this operation says it targets
135
        std::type_index target_type_index = op_ptr->getTargetInputTypeIndex();
2,528✔
136
        // Get the user-facing name of the operation
137
        std::string op_name = op_ptr->getName();
2,528✔
138

139
        // Add this operation's name to the list for its target type index
140
        type_index_to_op_names_[target_type_index].push_back(op_name);
2,528✔
141
    }
2,528✔
142

143
    std::cout << "Finished computing applicable operations." << std::endl;
79✔
144
// Debug print (optional): shows mangled names for type_index keys internally
145
#ifndef NDEBUG// Example: Only print in debug builds
146
    for (auto const & pair: type_index_to_op_names_) {
553✔
147
        std::cout << "  TypeIndex Hash(" << pair.first.hash_code()
474✔
148
                  << ", Name=" << pair.first.name() << ") supports: ";
474✔
149
        for (auto const & name: pair.second) std::cout << "'" << name << "' ";
3,002✔
150
        std::cout << std::endl;
474✔
151
    }
152
#endif
153
}
79✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc