{"action":"created","issue":{"url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/issues/8","labels_url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/issues/8/comments","events_url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/issues/8/events","html_url":"https://github.com/Biomechanical-ToolKit/BTKCore/issues/8","id":113450604,"number":8,"title":"Question about getting units & data-rate from C3D","user":{"login":"klshrinidhi","id":1181669,"avatar_url":"https://avatars.githubusercontent.com/u/1181669?v=3","gravatar_id":"","url":"https://api.github.com/users/klshrinidhi","html_url":"https://github.com/klshrinidhi","followers_url":"https://api.github.com/users/klshrinidhi/followers","following_url":"https://api.github.com/users/klshrinidhi/following{/other_user}","gists_url":"https://api.github.com/users/klshrinidhi/gists{/gist_id}","starred_url":"https://api.github.com/users/klshrinidhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klshrinidhi/subscriptions","organizations_url":"https://api.github.com/users/klshrinidhi/orgs","repos_url":"https://api.github.com/users/klshrinidhi/repos","events_url":"https://api.github.com/users/klshrinidhi/events{/privacy}","received_events_url":"https://api.github.com/users/klshrinidhi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"Alzathar","id":2211202,"avatar_url":"https://avatars.githubusercontent.com/u/2211202?v=3","gravatar_id":"","url":"https://api.github.com/users/Alzathar","html_url":"https://github.com/Alzathar","followers_url":"https://api.github.com/users/Alzathar/followers","following_url":"https://api.github.com/users/Alzathar/following{/other_user}","gists_url":"https://api.github.com/users/Alzathar/gists{/gist_id}","starred_url":"https://api.github.com/users/Alzathar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alzathar/subscriptions","organizations_url":"https://api.github.com/users/Alzathar/orgs","repos_url":"https://api.github.com/users/Alzathar/repos","events_url":"https://api.github.com/users/Alzathar/events{/privacy}","received_events_url":"https://api.github.com/users/Alzathar/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-10-26T21:01:42Z","updated_at":"2015-11-02T21:12:05Z","closed_at":null,"body":"We are using BTK to read C3D files into OpenSim data-structure. \r\nHere is my understanding so far. In order to get the raw forces, moments and positions from force platforms using BTK, I follow these steps --\r\n* Extract the collection of force platforms from the acquisition.\r\n* For each force platform:\r\n  * Get the calibration matrix, corners and origin for the force platform.\r\n  * Feed the force platform to the ground reaction wrench filter to get the collection of wrenches for that force platform.\r\n  * For each wrench:\r\n    * Get forces, moments and positions from the wrench.\r\n\r\nI am currently using the following snippet to do the above. My questions:\r\n* How to get the units of various physical quantities -- forces, moments, positions, corners, origin ?\r\n* How to get the data-rate for forces, moments & positions ?\r\n\r\n```cpp\r\n    auto reader = btk::AcquisitionFileReader::New();\r\n    reader->SetFilename(fileName);\r\n    reader->Update();\r\n    auto acquisition = reader->GetOutput();\r\n\r\n    auto    marker_pts = btk::PointCollection::New();\r\n    auto usr_force_pts = btk::PointCollection::New();\r\n    for(auto it = acquisition->BeginPoint();\r\n        it != acquisition->EndPoint();\r\n        ++it) {\r\n        auto pt = *it;\r\n        if(pt->GetType() == btk::Point::Marker)\r\n               marker_pts->InsertItem(pt);\r\n        else if(pt->GetType() == btk::Point::Force)\r\n            usr_force_pts->InsertItem(pt);\r\n    }\r\n\r\n    if(marker_pts->GetItemNumber() != 0) {\r\n        auto datarate =  acquisition->GetPointFrequency();\r\n        auto units = acquisition->GetPointUnit();\r\n\r\n        std::vector<std::string> marker_labels{};\r\n        for(auto it = marker_pts->Begin();\r\n            it != marker_pts->End();\r\n            ++it)\r\n            marker_labels.push_back((*it)->GetLabel());\r\n\r\n        double time_step{1.0 / acquisition->GetPointFrequency()};\r\n        for(size_t f = 0;\r\n            f < marker_pts->GetFrontItem()->GetFrameNumber();\r\n            ++f) {\r\n            for(auto it = marker_pts->Begin();\r\n                it != marker_pts->End();\r\n                ++it) {\r\n                auto pt = *it;\r\n                auto x = pt->GetValues().coeff(f, 0);\r\n                auto y = pt->GetValues().coeff(f, 1);\r\n                auto z = pt->GetValues().coeff(f, 2);\r\n            }\r\n        }\r\n    }\r\n\r\n    if(usr_force_pts->GetItemNumber() != 0) {\r\n        std::vector<std::string> force_labels{};\r\n        for(auto it = usr_force_pts->Begin();\r\n            it != usr_force_pts->End();\r\n            ++it) {\r\n            auto pt = *it;\r\n            force_labels.push_back(pt->GetLabel());\r\n        }\r\n\r\n        double time_step{1.0 / acquisition->GetAnalogFrequency()};\r\n        for(size_t f = 0;\r\n            f < usr_force_pts->GetFrontItem()->GetFrameNumber();\r\n            ++f) {\r\n            for(auto it = usr_force_pts->Begin();\r\n                it != usr_force_pts->End();\r\n                ++it) {\r\n                auto pt = *it;\r\n                auto x = pt->GetValues().coeff(f, 0);\r\n                auto y = pt->GetValues().coeff(f, 1);\r\n                auto z = pt->GetValues().coeff(f, 2);\r\n            }\r\n            usr_force_table.appendRow(0 + f * time_step, row);\r\n        }\r\n    }\r\n\r\n    auto force_platforms_extractor = btk::ForcePlatformsExtractor::New();\r\n    force_platforms_extractor->SetInput(acquisition);\r\n    auto force_platform_collection = force_platforms_extractor->GetOutput();\r\n    force_platforms_extractor->Update();\r\n\r\n    std::vector<btk::ForcePlatform::CalMatrix> fp_cal_matrices{};\r\n    std::vector<btk::ForcePlatform::Corners>   fp_corners{};\r\n    std::vector<btk::ForcePlatform::Origin>    fp_origins{};\r\n    std::vector<unsigned>                      fp_types{};\r\n    auto    fp_force_pts = btk::PointCollection::New();\r\n    auto   fp_moment_pts = btk::PointCollection::New();\r\n    auto fp_position_pts = btk::PointCollection::New();\r\n    for(auto platform = force_platform_collection->Begin();\r\n        platform != force_platform_collection->End();\r\n        ++platform) {\r\n        fp_cal_matrices.push_back((*platform)->GetCalMatrix());\r\n        fp_corners.push_back((*platform)->GetCorners());\r\n        fp_origins.push_back((*platform)->GetOrigin());\r\n        fp_types.push_back(static_cast<unsigned>((*platform)->GetType()));\r\n\r\n        auto ground_reaction_wrench_filter =\r\n            btk::GroundReactionWrenchFilter::New();\r\n        ground_reaction_wrench_filter->SetInput(*platform);\r\n        auto wrench_collection = ground_reaction_wrench_filter->GetOutput();\r\n        ground_reaction_wrench_filter->Update();\r\n\r\n        for(auto wrench = wrench_collection->Begin();\r\n            wrench != wrench_collection->End();\r\n            ++wrench) {\r\n            // Forces time series.                                                                                                                                                                                                                                                         \r\n            fp_force_pts->InsertItem((*wrench)->GetForce());\r\n            // Moment time series.                                                                                                                                                                                                                                                         \r\n            fp_moment_pts->InsertItem((*wrench)->GetMoment());\r\n            // Position time series.                                                                                                                                                                                                                                                       \r\n            fp_position_pts->InsertItem((*wrench)->GetPosition());\r\n        }\r\n    }\r\n        double time_step{1.0 / acquisition->GetAnalogFrequency()};\r\n        for(size_t f = 0;\r\n            f < fp_force_pts->GetFrontItem()->GetFrameNumber();\r\n            ++f) {\r\n            for(auto fit = fp_force_pts->Begin(),\r\n                mit =     fp_moment_pts->Begin(),\r\n                pit =   fp_position_pts->Begin();\r\n                fit != fp_force_pts->End();\r\n                ++fit,\r\n                ++mit,\r\n                ++pit) {\r\n                auto fx = (*fit)->GetValues().coeff(f, 0);\r\n                auto fy = (*fit)->GetValues().coeff(f, 1);\r\n                auto fz = (*fit)->GetValues().coeff(f, 2)};\r\n                auto mx = (*mit)->GetValues().coeff(f, 0);\r\n                auto my = (*mit)->GetValues().coeff(f, 1);\r\n                auto mz = (*mit)->GetValues().coeff(f, 2);\r\n                auto px = (*pit)->GetValues().coeff(f, 0);\r\n                auto py = (*pit)->GetValues().coeff(f, 1);\r\n                auto pz = (*pit)->GetValues().coeff(f, 2);\r\n            }\r\n        }\r\n    }\r\n\r\n    auto events = acquisition->GetEvents();\r\n    for(auto it = events->Begin();\r\n        it != events->End();\r\n        ++it) {\r\n        auto et = *it;\r\n        auto label = et->GetLabel();\r\n        auto time = et->GetTime();\r\n        auto frame = et->GetFrame();\r\n        auto description = et->GetDescription();\r\n    }\r\n\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/issues/comments/153157888","html_url":"https://github.com/Biomechanical-ToolKit/BTKCore/issues/8#issuecomment-153157888","issue_url":"https://api.github.com/repos/Biomechanical-ToolKit/BTKCore/issues/8","id":153157888,"user":{"login":"klshrinidhi","id":1181669,"avatar_url":"https://avatars.githubusercontent.com/u/1181669?v=3","gravatar_id":"","url":"https://api.github.com/users/klshrinidhi","html_url":"https://github.com/klshrinidhi","followers_url":"https://api.github.com/users/klshrinidhi/followers","following_url":"https://api.github.com/users/klshrinidhi/following{/other_user}","gists_url":"https://api.github.com/users/klshrinidhi/gists{/gist_id}","starred_url":"https://api.github.com/users/klshrinidhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klshrinidhi/subscriptions","organizations_url":"https://api.github.com/users/klshrinidhi/orgs","repos_url":"https://api.github.com/users/klshrinidhi/repos","events_url":"https://api.github.com/users/klshrinidhi/events{/privacy}","received_events_url":"https://api.github.com/users/klshrinidhi/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T21:12:05Z","updated_at":"2015-11-02T21:12:05Z","body":"Thanks @Alzathar. I think I understand what to do now.\r\nI can close the question if you want."}}