src.data_reader package¶
src.data_reader.imu module¶
This module contains the IMU class.
-
class
src.data_reader.imu.
IMU
(data)¶ Bases:
object
An IMU object holds all the data recorded by an actual IMU and offers getter and conversion methods.
-
acc_to_g
()¶ Conversion method for acceleration data from m/s**2 to g.
-
acc_to_meter_per_square_sec
()¶ Conversion method for acceleration data from g to m/s**2.
-
accel
(i=None)¶ Getter method for acceleration.
Depending on if i is specified, this returns either data from timestep i or the whole timeseries data.
- Parameters
i (int) – Optional - index of the data
- Returns
data at the specified timestep i or all data
- Return type
float or np.array
-
accel_variance
()¶ Calculate acceleration variance.
- Returns
variance of acceleration
- Return type
float
-
check_sampling
()¶ Calculate mean and standard deviation of the sampling rate.
- Returns
mean and std. deviation of sampling rate
- Return type
tuple(float, float)
-
crop
(min_time, max_time, inplace=False)¶ Crops data to timeframe between min_time and max_time. Attention: all other data is dropped.
- Parameters
min_time (float) – start time of cropping
max_time (float) – end time of cropping
inplace (bool) – flag if cropping should be performed inplace or on a copy
- Returns
If not inplace, a cropped copy of the IMU object is returned.
- Return type
None or IMU
-
gyro
(i=None)¶ Getter method for gyroscope data.
Depending on if i is specified, this returns either data from timestep i or the whole timeseries data.
- Parameters
i (int) – Optional - index of the data
- Returns
data at the specified timestep i or all data
- Return type
float or np.array
-
gyro_to_degree
()¶ Conversion method for gyroscope data from rad to degree.
-
gyro_to_rad
()¶ Conversion method for gyroscope data from degree to rad.
-
resample
(f)¶ Resample a copy of IMU data to given frequency.
- Parameters
f (float) – target frequency
- Returns
resampled IMU copy
- Return type
-
time
(i=None)¶ Getter method for timestamps.
Depending on if i is specified, this returns either data from timestep i or the whole timeseries data.
- Parameters
i (int) – Optional - index of the data
- Returns
data at the specified timestep i or all data
- Return type
float or np.array
-
time_shift
(time_offset)¶ Shift time by a given offset.
- Parameters
time_offset (float) – offset used to shift time
- Returns
None
-
zero_base_time
()¶ Let timestamps start at zero.
-
src.data_reader.opto_gait_xml_reader module¶
This module contains functionality that reads data from XML files as they can be exported from the OptoGait software. This is only used to initially convert the XML files to CSV files, since the Excal XML format is rather cumbersome.
-
src.data_reader.opto_gait_xml_reader.
read_opto_gait_raw_xml_simple
(input_file)¶ Read OptoGait raw data from the excel xml file. The main information is stored in the spreadsheet “simple”.
- Parameters
input_file (str) – xml input file name.
- Returns
DataFrame with information from the “simple” spreadsheet.
- Return type
(DataFrame)
src.data_reader.zebris_json_reader module¶
This module contains the ZebrisJsonReader.
-
class
src.data_reader.zebris_json_reader.
ZebrisJsonReader
(raw_data_file, step_data_file)¶ Bases:
object
The ZebrisJsonReader can be used to read and load preprocessed Zebris files. Besides the functionality for extracting gait parameters from the data, this class provides functionality for creating images and videos from the data.
-
get_raw_data
()¶ Get raw data. Lazy loading with caching.
- Returns
raw data
- Return type
dict
-
get_step_data
()¶ Get step (aggregated) data. Lazy loading with caching.
- Returns
step data
- Return type
dict
-
read_treadmill_velocity
()¶ Read treadmill velocity.
- Returns
Treadmill velocity for each sample.
- Return type
list[float]
-
read_zebris_raw_json_heel_positions
(generate_images=False, generate_heel_image=False)¶ Zebris does not provide stride length out of the box. Therefore, the positions of heel strikes are measured in order to obtain stride length. This function can also be used to create a series of images that could be later merged into a video or used to inspect the raw data. Also an image of the performed heel detection can be exported.
- Parameters
generate_images (bool) – flag, if a series of images should be created
generate_heel_image (bool) – flag, if an image of the heel detection should be created
- Returns
Positions of heelstrike for the left and right foot.
- Return type
(tuple[list[float], ..])
-
read_zebris_raw_json_ic_fo
()¶ Read the initial contact and foot-off timestamps. Zebris provides this data as part of the aggregated data.
- Returns
DataFrames of IC and FO timestamps for the left and right foot.
- Return type
tuple[DataFrame, ..]
-
read_zebris_raw_json_initial_contact
()¶ The aggregated data from Zebris does not contain the first step. However, the raw data does. Therefore, the initial contact timestamp needs to be extracted from the raw data and is not the start of the first “detected step”.
- Returns
IC timestamp
- Return type
float
-
read_zebris_raw_json_to_video
(out_file)¶ Creates an mp4 video of the raw sensor data. The framerate will be the actual sensor reading rate (some players might have problems with unusual framerates). One pixel is one sensor cell.
- Parameters
out_file (str) – mp4 file name
- Returns
None
-