{Feature} Core - Decode EMG samples and add a numpy accessor in PAT - #364
Open
SeaOtocinclus wants to merge 1 commit into
Open
{Feature} Core - Decode EMG samples and add a numpy accessor in PAT#364SeaOtocinclus wants to merge 1 commit into
SeaOtocinclus wants to merge 1 commit into
Conversation
Summary:
Explanation:
Project Aria Tools previously exposed each EMG sample only as a raw packed byte blob (`EmgImuSample.packed_channel_data`), forcing every consumer to reimplement the same big-endian / offset-binary / sample-major unpacking. This moves the decode into PAT so callers get decoded samples directly.
- New `decodeEmgSamples(const EmgData&)` in `core/data_provider/players/EmgPlayer.{h,cpp}` returns a `DecodedEmgSamples` struct (row-major `[num_sub_samples, channel_count]` raw ADC counts). It unpacks each `EmgData.emg` blob (big-endian, unsigned 16-bit, offset-binary, sample-major), skips malformed blobs, and throws `std::invalid_argument` for an unsupported bit depth or a non-zero encoding.
- Python: `EmgData.get_emg_samples()` and the module-level `sensor_data.decode_emg_samples(emg_data)` return the decoded batch as a `[num_sub_samples, channel_count]` `uint16` numpy array (`core/python/SensorDataPyBind.h`; stub in `core/python/internal/stubs/sensor_data.pyi`).
No physical-unit (microvolt) conversion is provided: Aria Gen 2 recordings carry no EMG calibration (the EMG stream's configuration calibration field is empty, and the device factory-calibration JSON has no EMG section), so values remain raw ADC counts and must be treated as relative.
Reproducibility:
Build and run the new C++ and Python unit tests (see Test Plan). The decoded array equals an independent big-endian `uint16` reshape of the packed blobs.
Differential Revision: D110117191
Contributor
|
@SeaOtocinclus has exported this pull request. If you are a Meta employee, you can view the originating Diff in D110117191. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Explanation:
Project Aria Tools previously exposed each EMG sample only as a raw packed byte blob (
EmgImuSample.packed_channel_data), forcing every consumer to reimplement the same big-endian / offset-binary / sample-major unpacking. This moves the decode into PAT so callers get decoded samples directly.decodeEmgSamples(const EmgData&)incore/data_provider/players/EmgPlayer.{h,cpp}returns aDecodedEmgSamplesstruct (row-major[num_sub_samples, channel_count]raw ADC counts). It unpacks eachEmgData.emgblob (big-endian, unsigned 16-bit, offset-binary, sample-major), skips malformed blobs, and throwsstd::invalid_argumentfor an unsupported bit depth or a non-zero encoding.EmgData.get_emg_samples()and the module-levelsensor_data.decode_emg_samples(emg_data)return the decoded batch as a[num_sub_samples, channel_count]uint16numpy array (core/python/SensorDataPyBind.h; stub incore/python/internal/stubs/sensor_data.pyi).No physical-unit (microvolt) conversion is provided: Aria Gen 2 recordings carry no EMG calibration (the EMG stream's configuration calibration field is empty, and the device factory-calibration JSON has no EMG section), so values remain raw ADC counts and must be treated as relative.
Reproducibility:
Build and run the new C++ and Python unit tests (see Test Plan). The decoded array equals an independent big-endian
uint16reshape of the packed blobs.Differential Revision: D110117191