1% =========================================================================== %
2%> @brief combines multiple JUMP sensor data structures into one
4%> This function combines the data from multiple jumps into a single dataset.
5%> It takes in the data from each jump as input and returns a combined dataset.
7%> @param data : array of JUMP sensor data structures (see @ref
jumpReadData)
8%> @param options.max_t_gap : maximum time gap between two data structures
9%> to be combined,
if the time gap is larger, the data structures are not
10%> combined. must be given as duration or in seconds. (
default: 10 seconds)
12%> @retval data_combined : combined JUMP sensor data structure
13%> @retval join_times : array of times when the data structures were combined
22%> @note The data structures must have the same header information.
28%> @copyright see the file @ref LICENSE in the root directory of the repository
29% =========================================================================== %
35 options.max_t_gap (1,1) {mustBeA(options.max_t_gap, [
"duration",
"numeric"])} = seconds(10);
38% check the data structure
41 assert(valid,
"Data structure %d is not valid", i);
44% check
if the max time gap is a duration, otherwise convert
45if ~isa(options.max_t_gap,
"duration")
46 options.max_t_gap = seconds(options.max_t_gap);
50% check if the structures have the same header information, the header contains
51% ID, UID, name, sw_version, hw_version, acc_range, gyro_range, mpu_cal,
52% act_thrs, inact_dur, mpu_rate, adxl_rate, pres_rate, magn_en, sync,
53% ble_address. the t_start is not checked, as this must be different
55 assert(length(unique([data.ID])) == 1, "ID");
56 assert(length(unique([data.UID])) == 1, "UID");
57 assert(length(unique([data.name])) == 1, "name");
58 assert(length(unique([data.sw_version])) == 1, "sw_version");
59 assert(length(unique([data.hw_version])) == 1, "hw_version");
60 assert(length(unique([data.acc_range])) == 1, "acc_range");
61 assert(length(unique([data.gyro_range])) == 1, "gyro_range");
62 assert(length(unique([data.mpu_cal])) == 1, "mpu_cal");
63 assert(length(unique([data.act_thrs])) == 1, "act_thrs");
64 assert(length(unique([data.inact_dur])) == 1, "inact_dur");
65 assert(length(unique([data.mpu_rate])) == 1, "mpu_rate");
66 assert(length(unique([data.adxl_rate])) == 1, "adxl_rate");
67 assert(length(unique([data.pres_rate])) == 1, "pres_rate");
68 assert(length(unique([data.magn_en])) == 1, "magn_en");
69 assert(length(unique([data.sync])) == 1, "sync");
70 assert(length(unique([data.ble_address])) == 1, "ble_address");
72 error("The data structures must have compatible headers. At least the field %s is not the same.", ME.message);
75% sort the data structures by time
76[~, idx] = sort([data.t_start]);
78% check the time gaps between the data structures
81 % check that the data is not overlapping
82 if data(idx(i)).tt.t(end) > data(idx(i+1)).tt.t(1)
83 error("Data structures %d and %d are overlapping", idx(i), idx(i+1));
87 t_gap = data(idx(i+1)).tt.t(1) - data(idx(i)).tt.t(end);
88 if t_gap > options.max_t_gap
89 error("Time gap between data structures %d and %d is too large. It is %.1f s and is allowed to be %.1f s", idx(i), idx(i+1), seconds(t_gap), seconds(options.max_t_gap));
93% combine the data structures
94data_combined = data(idx(1));
95join_times = NaT(numel(idx)-1, 1);
97 join_times(i-1) = data(idx(i)).t_start;
98 data_combined.tt = [data_combined.tt; data(idx(i)).tt];
102data_combined.t_start = data_combined.tt.t(1);
105data_combined.tt = retime(data_combined.tt, 'regular', 'nearest', 'TimeStep', seconds(1/data_combined.mpu_rate));
function jumpCheckData(in data)
function jumpCombineData(in data, in options)
function jumpReadData(in filePath, in options)