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

paulmthompson / WhiskerToolbox / 14341775004

08 Apr 2025 07:16PM UTC coverage: 12.927% (+0.02%) from 12.911%
14341775004

push

github

paulmthompson
simplify imagesize struct

0 of 19 new or added lines in 3 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

208 of 1609 relevant lines covered (12.93%)

1.26 hits per line

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

0.0
/src/WhiskerToolbox/DataManager/transforms/data_transforms.cpp
1

2
#include "data_transforms.hpp"
3

4
#include "AnalogTimeSeries/Analog_Time_Series.hpp"
5
#include "Masks/Mask_Data.hpp"
6
#include "Media/Media_Data.hpp"
7
#include "Points/Point_Data.hpp"
8

9
#include <map>
10
#include <numeric>
11

12

NEW
13
std::shared_ptr<AnalogTimeSeries> area(std::shared_ptr<MaskData> const & mask_data) {
×
UNCOV
14
    auto analog_time_series = std::make_shared<AnalogTimeSeries>();
×
15
    std::map<int, float> areas;
×
16

NEW
17
    for (auto const & [timestamp, masks]: mask_data->getData()) {
×
18
        float area = 0.0f;
×
NEW
19
        for (auto const & mask: masks) {
×
NEW
20
            area += static_cast<float>(mask.size());
×
21
        }
22
        areas[timestamp] = area;
×
23
    }
×
24

25
    analog_time_series->setData(areas);
×
26

27
    return analog_time_series;
×
28
}
×
29

NEW
30
void scale(std::shared_ptr<PointData> & point_data, ImageSize const & image_size_media) {
×
UNCOV
31
    auto image_size_point = point_data->getImageSize();
×
32

NEW
33
    auto const media_height = image_size_media.height;
×
NEW
34
    auto const media_width = image_size_media.width;
×
NEW
35
    auto const point_height = image_size_point.height;
×
NEW
36
    auto const point_width = image_size_point.width;
×
37

38
    if (media_width == point_width && media_height == media_width) {
×
39
        return;
×
40
    }
41

42
    if (point_width == -1 || point_height == -1) {
×
43
        return;
×
44
    }
45

NEW
46
    float const height_ratio = static_cast<float>(media_height) / static_cast<float>(point_height);
×
NEW
47
    float const width_ratio = static_cast<float>(media_width) / static_cast<float>(point_width);
×
48

49

NEW
50
    for (auto & [timestamp, points]: point_data->getData()) {
×
51
        auto scaled_points = std::vector<Point2D<float>>();
×
NEW
52
        for (auto & point: points) {
×
53
            scaled_points.push_back(
×
NEW
54
                    {point.x * height_ratio,
×
NEW
55
                     point.y * width_ratio});
×
56
        }
NEW
57
        point_data->overwritePointsAtTime(timestamp, scaled_points);
×
58
    }
×
59

NEW
60
    point_data->setImageSize(ImageSize());
×
61
}
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