Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and extract cwa from command line #43

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

aidanacquah
Copy link

This PR implements a new feature that is useful for those conducting studies with AX3/AX6 devices.

Currently, actipy is used within python to convert the raw cwa file to a pandas dataframe.
However, it is also desirable to have this data as a csv file, particularly those without experience in python.

This PR therefore allows anyone to convert the raw cwa file to a csv file through command prompt.

To do so, run the command:

$ read_cwa sample.cwa.gz

By default, this will do no preprocessing and save all the extracted data in a csv file in the same location as the input cwa file as "sample.csv".

For specific optional parameters, we can run the command:

$ read_cwa sample.cwa.gz -o outputs -r 50 -l 20 -d -g -c x y z -i -q
  • "-o": Output directory.
  • "-r": Resample rate for output data.
  • "-l": Upper band frequency for lowpass filter.
  • "-d": Detect non-wear.
  • "-g": Calibrate gravity.
  • "-c": Limit the columns of the output csv file to those listed (excluding the time index column)
  • "-i": Alongside csv file, also save info.json file.
  • "-q": Quiet flag to suppress output messages during extraction.

Testing:

  1. image

  2. image

Files created as expected.

Note: An error is reported stating the "data.npy file cannot access the file because it is being used by another process." however this error is not related to this work, and file reading works despite the error. This is reported in #41

@aidendoherty
Copy link
Member

Looks neat!

@aidanacquah
Copy link
Author

Added a progress bar to saving the csv as it is quite slow.

@chanshing
Copy link
Member

chanshing commented Jul 24, 2024

Amazing work @aidanacquah !!! 🚀 💥

I made the following changes:

  • --outdir defaults to "outputs/" similar to the stepcount package
  • Dropped --save-info argument and make the tool always output the info file, saved to {basename}-Info.json (as in stepcount pkg)
  • Dropped chunked file saving because it was x2 slower (might work on it to restore it later)
  • Cosmetic changes: -l (lowpass filter) to -f. -d (detect nonwear) to -w.
  • Squashed all commits.

@chanshing chanshing merged commit f1c1a31 into OxWearables:master Jul 24, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants