Working with spirometer data#

Import the worklab module:

import os
import worklab as wl

Import the data with com.load():

filename = os.getcwd()
filename = os.path.join(os.path.split(filename)[0], 'example_data', 'COSMED_example.xlsx')
spiro_data = wl.com.load(filename)
print("Spirometer data is stored in a: ", type(spiro_data))
================================================================================
Initializing loading for C:\Users\rick_\Development\worklab2\example_data\COSMED_example.xlsx ...
File identified as COSMED datafile. Attempting to load ...
Data loaded!
================================================================================

Spirometer data is stored in a:  <class 'pandas.core.frame.DataFrame'>

or use wl.com.load_spiro() which is functionally identical.

You can inspect the data with pandas functions:

spiro_data.head()
time Rf HR power VO2 VCO2 weights
0 7 11.952191 62 101.842014 298.455484 268.382657 0
1 11 9.933775 62 111.407404 330.369515 281.724639 4
2 15 11.757790 63 128.974406 383.662547 322.481225 4
3 18 13.218771 64 141.802001 423.538135 349.306235 3
4 20 14.430014 64 146.172614 436.703091 359.734206 2
spiro_data.tail()
time Rf HR power VO2 VCO2 weights
328 951 23.809524 94 338.510226 995.434028 881.662962 2
329 954 23.237800 93 338.135288 994.712143 879.522871 3
330 956 22.883295 93 348.853419 1029.271752 898.141951 2
331 959 23.382697 93 351.913720 1037.692355 907.881222 3
332 961 23.566379 92 353.994886 1043.260882 914.987154 2

Or plot with Pandas built-in functions or matplotlib:

spiro_data.plot("time", "HR");
../../_images/ex_physio_spiro_10_0.png

That’s basically all there is to it. Handling spirometer data is not very exciting 😃