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

paulmthompson / WhiskerToolbox / 18008514883

25 Sep 2025 01:08PM UTC coverage: 68.869% (-0.05%) from 68.919%
18008514883

push

github

paulmthompson
dlc loader for csv files

92 of 102 new or added lines in 3 files covered. (90.2%)

680 existing lines in 10 files now uncovered.

41941 of 60900 relevant lines covered (68.87%)

1139.5 hits per line

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

66.67
/src/DataManager/Points/IO/JSON/Point_Data_JSON.cpp
1

2
#include "Point_Data_JSON.hpp"
3

4
#include "Points/Point_Data.hpp"
5
#include "Points/IO/CSV/Point_Data_CSV.hpp"
6

7
#include "loaders/loading_utils.hpp"
8

9
#include <iostream>
10

11
std::shared_ptr<PointData> load_into_PointData(std::string const & file_path, nlohmann::basic_json<> const & item) {
1✔
12

13
    // Check if this is a DLC CSV format
14
    if (item.contains("format") && item["format"] == "dlc_csv") {
1✔
15
        // For DLC CSV, we need to return the first bodypart as the main PointData
16
        // The caller (DataManager) will need to handle multiple bodyparts differently
17
        
18
        int const frame_column = item.value("frame_column", 0);
1✔
19
        float const likelihood_threshold = item.value("likelihood_threshold", 0.0f);
1✔
20

21
        auto opts = DLCPointLoaderOptions{
1✔
22
            .filename = file_path,
23
            .frame_column = frame_column,
24
            .likelihood_threshold = likelihood_threshold
25
        };
1✔
26

27
        auto dlc_data = load_dlc_csv(opts);
1✔
28

29
        if (dlc_data.empty()) {
1✔
NEW
30
            std::cerr << "Warning: No data loaded from DLC CSV file" << std::endl;
×
NEW
31
            return std::make_shared<PointData>();
×
32
        }
33

34
        // Return the first bodypart data (for backward compatibility with single PointData return)
35
        auto first_bodypart_data = dlc_data.begin()->second;
1✔
36
        auto point_data = std::make_shared<PointData>(first_bodypart_data);
1✔
37

38
        change_image_size_json(point_data, item);
1✔
39

40
        return point_data;
1✔
41
    }
1✔
42

43
    // Original CSV loading logic
44
    int const frame_column = item["frame_column"];
×
45
    int const x_column = item["x_column"];
×
46
    int const y_column = item["y_column"];
×
47

48
    std::string const delim = item.value("delim", " ");
×
49

50
    auto opts = CSVPointLoaderOptions{.filename = file_path,
×
51
                                      .frame_column = frame_column,
52
                                      .x_column = x_column,
53
                                      .y_column = y_column,
54
                                      .column_delim = delim.c_str()[0]};
×
55

56
    auto keypoints = load(opts);
×
57

58
    std::cout << "There are " << keypoints.size() << " keypoints " << std::endl;
×
59

60
    auto point_data = std::make_shared<PointData>(keypoints);
×
61

62
    change_image_size_json(point_data, item);
×
63

64
    return point_data;
×
65
}
×
66

67
std::map<std::string, std::shared_ptr<PointData>> load_multiple_PointData_from_dlc(std::string const & file_path, nlohmann::basic_json<> const & item) {
4✔
68
    
69
    int const frame_column = item.value("frame_column", 0);
4✔
70
    float const likelihood_threshold = item.value("likelihood_threshold", 0.0f);
4✔
71

72
    auto opts = DLCPointLoaderOptions{
4✔
73
        .filename = file_path,
74
        .frame_column = frame_column,
75
        .likelihood_threshold = likelihood_threshold
76
    };
4✔
77

78
    auto dlc_data = load_dlc_csv(opts);
4✔
79

80
    std::map<std::string, std::shared_ptr<PointData>> result;
4✔
81
    
82
    for (auto const& [bodypart, points] : dlc_data) {
43✔
83
        auto point_data = std::make_shared<PointData>(points);
39✔
84
        change_image_size_json(point_data, item);
39✔
85
        result[bodypart] = point_data;
39✔
86
    }
39✔
87
    
88
    std::cout << "Created " << result.size() << " PointData objects from DLC CSV" << std::endl;
4✔
89
    
90
    return result;
8✔
91
}
4✔
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