diff --git a/Eurobench_format_code/Dockerfile b/Eurobench_format_code/Dockerfile index a0ab23b..a60e6f2 100644 --- a/Eurobench_format_code/Dockerfile +++ b/Eurobench_format_code/Dockerfile @@ -9,7 +9,11 @@ RUN apt-get update \ RUN wget -O signal-1.4.1.tar.gz https://octave.sourceforge.io/download.php?package=signal-1.4.1.tar.gz \ && wget -O control-3.2.0.tar.gz https://octave.sourceforge.io/download.php?package=control-3.2.0.tar.gz \ && wget -O io-2.4.12.tar.gz https://octave.sourceforge.io/download.php?package=io-2.4.12.tar.gz \ - && wget -O statistics-1.4.1.tar.gz https://octave.sourceforge.io/download.php?package=statistics-1.4.1.tar.gz + && wget -O statistics-1.4.1.tar.gz https://octave.sourceforge.io/download.php?package=statistics-1.4.1.tar.gz \ + && wget -O mapping-1.4.1.tar.gz https://octave.sourceforge.io/download.php?package=mapping-1.4.1.tar.gz \ + && wget -O matgeom-1.2.2.tar.gz https://octave.sourceforge.io/download.php?package=matgeom-1.2.2.tar.gz \ + && wget -O geometry-4.0.0.tar.gz https://octave.sourceforge.io/download.php?package=geometry-4.0.0.tar.gz + ADD Eurobench_format_code/package_install.m package_install.m RUN pwd; ls diff --git a/Eurobench_format_code/package_install.m b/Eurobench_format_code/package_install.m index ca8ebe2..57e592e 100755 --- a/Eurobench_format_code/package_install.m +++ b/Eurobench_format_code/package_install.m @@ -4,3 +4,6 @@ pkg install io-2.4.12.tar.gz; pkg install statistics-1.4.1.tar.gz; pkg install signal-1.4.1.tar.gz; +pkg install matgeom-1.2.2.tar.gz +pkg install geometry-4.0.0.tar.gz; +pkg install mapping-1.4.1.tar.gz; diff --git a/Eurobench_format_code/run_bench_5sts_pi b/Eurobench_format_code/run_bench_5sts_pi index bff174a..e202130 100755 --- a/Eurobench_format_code/run_bench_5sts_pi +++ b/Eurobench_format_code/run_bench_5sts_pi @@ -19,8 +19,8 @@ is_ok = 0; try computePI_5sts(arg_list{1}, arg_list{2}, arg_list{3}); -catch err - warning(err.identifier, err.message); +catch + printf("Error: %s\n", lasterr); is_ok = 1; end_try_catch diff --git a/Eurobench_format_code/src/computePI_30sts.m b/Eurobench_format_code/src/computePI_30sts.m index 0d6280d..1fb30ad 100644 --- a/Eurobench_format_code/src/computePI_30sts.m +++ b/Eurobench_format_code/src/computePI_30sts.m @@ -55,41 +55,40 @@ protocol = false; - + disp("so far so good") %computes the PIs sts_metrics = calculate_sts_metrics(data, kinematics, fsamp, protocol); + sts_metrics types = {"scalar\n", "array of scalars\n", "vector\n"}; - labels = strcat("",'\n'); filename = strcat(result_dir, "/", "30sSTS_repetitions", ".yaml") - store_vector(filename, sts_metrics{1}, labels, types{1}); + store_scalar(filename, sts_metrics{1}); - labels = strcat("{Flexion Momentum, Momentum Transfer, Extension}",'\n'); + labels = "[Flexion Momentum, Momentum Transfer, Extension]" filename = strcat(result_dir, "/", "subphases_duration", ".yaml") - store_vector(filename, sts_metrics{2}, labels, types{2}); + store_vector(filename, sts_metrics{2}, labels); - labels = strcat("",'\n'); + labels = ""; filename = strcat(result_dir, "/", "CoP_stability", ".yaml") - store_vector(filename, sts_metrics{3}, labels, types{1}); + reshape(sts_metrics{3}, 1, 2) + store_vector(filename, reshape(sts_metrics{3}, 1, 2), labels); - labels = strcat("",'\n'); filename = strcat(result_dir, "/", "ult_time", ".yaml") - store_vector(filename, sts_metrics{4}, labels, types{1}); + store_scalar(filename, sts_metrics{4}); - labels = strcat("{antero-posterior, medio-lateral}",'\n'); + labels = "[antero-posterior, medio-lateral]"; filename = strcat(result_dir, "/", "ult_overshoot", ".yaml") - store_vector(filename, sts_metrics{5}, labels, types{2}); + store_vector(filename, sts_metrics{5}, labels); - labels = strcat("{Ankle, Knee, Hip, Trunk}",'\n'); + labels = "[Ankle, Knee, Hip, Trunk]"; filename = strcat(result_dir, "/", "kinematic_repeatability", ".yaml") - store_vector(filename, sts_metrics{6}, labels, types{2}); + store_vector(filename, sts_metrics{6}, labels); - labels = strcat("",'\n'); filename = strcat(result_dir, "/", "CoM_work", ".yaml") - store_vector(filename, sts_metrics{7}, labels, types{1}); + store_scalar(filename, sts_metrics{7}); PI = sts_metrics; diff --git a/Eurobench_format_code/src/computePI_5sts.m b/Eurobench_format_code/src/computePI_5sts.m index 680fa71..9ee180b 100644 --- a/Eurobench_format_code/src/computePI_5sts.m +++ b/Eurobench_format_code/src/computePI_5sts.m @@ -22,7 +22,6 @@ else disp('Using Matlab') end - % get the csv data and calculate kinematics calib = csv2cell(csv_calib_file); @@ -55,40 +54,39 @@ protocol = true; - - %computes the PIs - sts_metrics = calculate_sts_metrics(data, kinematics, fsamp, protocol); - + sts_metrics + typeinfo(sts_metrics) types = {"scalar\n", "array of scalars\n", "vector\n"}; - labels = strcat("",'\n'); filename = strcat(result_dir, "/", "5STS_duration", ".yaml") - store_vector(filename, sts_metrics{1}, labels, types{1}); + store_scalar(filename, sts_metrics{1}); - labels = strcat("{Flexion Momentum, Momentum Transfer, Extension}",'\n'); + labels = "[Flexion Momentum, Momentum Transfer, Extension]"; filename = strcat(result_dir, "/", "subphases_duration", ".yaml") - store_vector(filename, sts_metrics{2}, labels, types{2}); + typeinfo(sts_metrics{2}) + store_vector(filename, sts_metrics{2}, labels); - labels = strcat("",'\n'); + labels = "" filename = strcat(result_dir, "/", "CoP_stability", ".yaml") - store_vector(filename, sts_metrics{3}, labels, types{1}); + typeinfo(sts_metrics{3}) + sts_metrics{3} + reshape(sts_metrics{3}, 1, 2) + store_vector(filename, reshape(sts_metrics{3}, 1, 2), labels); - labels = strcat("",'\n'); filename = strcat(result_dir, "/", "ult_time", ".yaml") - store_vector(filename, sts_metrics{4}, labels, types{1}); + store_scalar(filename, sts_metrics{4}, labels); - labels = strcat("{antero-posterior, medio-lateral}",'\n'); + labels = "[antero-posterior, medio-lateral]"; filename = strcat(result_dir, "/", "ult_overshoot", ".yaml") - store_vector(filename, sts_metrics{5}, labels, types{2}); + store_vector(filename, sts_metrics{5}, labels); - labels = strcat("{Ankle, Knee, Hip, Trunk}",'\n'); + labels = "[Ankle, Knee, Hip, Trunk]"; filename = strcat(result_dir, "/", "kinematic_repeatability", ".yaml") - store_vector(filename, sts_metrics{6}, labels, types{2}); - - labels = strcat("",'\n'); + store_vector(filename, sts_metrics{6}, labels); + filename = strcat(result_dir, "/", "CoM_work", ".yaml") - store_vector(filename, sts_metrics{7}, labels, types{1}); + store_scalar(filename, sts_metrics{7}); PI = sts_metrics; diff --git a/Eurobench_format_code/src/store_scalar.m b/Eurobench_format_code/src/store_scalar.m new file mode 100644 index 0000000..c763be5 --- /dev/null +++ b/Eurobench_format_code/src/store_scalar.m @@ -0,0 +1,19 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% store_scalar.m +% +% Store a scalar into yaml file +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function is_ok = store_scalar(filename, data) + + file_id = fopen(filename, "w"); + + fprintf(file_id, "type: \'scalar\'\n"); + + value_str = sprintf("value: %.5f\n", data); + + fprintf(file_id, value_str); + fclose(file_id); + is_ok = true; +end diff --git a/Eurobench_format_code/src/store_vector.m b/Eurobench_format_code/src/store_vector.m index 716706e..6adc60f 100644 --- a/Eurobench_format_code/src/store_vector.m +++ b/Eurobench_format_code/src/store_vector.m @@ -1,18 +1,21 @@ -function is_ok = store_vector(filename, data, labels, type) +function is_ok = store_vector(filename, data, labels) %taken from https://github.com/eurobench/pi_octave_csic/blob/master/src/store_vector.m file_id = fopen(filename, "w"); - fprintf(file_id, type); - fprintf(file_id, labels); - value_str = "value: "; + fprintf(file_id, "type: \'vector\'\n"); + + if size(labels) != 0 + fprintf(file_id, "label: %s\n", labels); + endif + value_str = "value: ["; for i = 1:size(data)(2) value_str = sprintf("%s%.5f", value_str, data(i)); if (i != size(data)(2)) value_str = sprintf("%s, ", value_str); endif endfor - value_str = sprintf("%s\n", value_str); + value_str = sprintf("%s]\n", value_str); fprintf(file_id, value_str); fclose(file_id); is_ok = true; diff --git a/Eurobench_format_code/test/output/subject_01_30sts/CoM_work.yaml b/Eurobench_format_code/test/output/subject_01_30sts/CoM_work.yaml index f60a06a..86b62bc 100644 --- a/Eurobench_format_code/test/output/subject_01_30sts/CoM_work.yaml +++ b/Eurobench_format_code/test/output/subject_01_30sts/CoM_work.yaml @@ -1,2 +1,2 @@ -type: 'vector' -value: [24.11805, 58.74444] +type: 'scalar' +value: 678.03756 diff --git a/Eurobench_format_code/test/output/subject_01_30sts/CoP_stability.yaml b/Eurobench_format_code/test/output/subject_01_30sts/CoP_stability.yaml index d904881..40976c9 100644 --- a/Eurobench_format_code/test/output/subject_01_30sts/CoP_stability.yaml +++ b/Eurobench_format_code/test/output/subject_01_30sts/CoP_stability.yaml @@ -1,2 +1,2 @@ -type: 'scalar' -value: 0.11515 +type: 'vector' +value: [0.37768, 0.04183] diff --git a/Eurobench_format_code/test/output/subject_01_30sts/kinematic_repeatability.yaml b/Eurobench_format_code/test/output/subject_01_30sts/kinematic_repeatability.yaml index cdbe789..6408abb 100644 --- a/Eurobench_format_code/test/output/subject_01_30sts/kinematic_repeatability.yaml +++ b/Eurobench_format_code/test/output/subject_01_30sts/kinematic_repeatability.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [Ankle, Knee, Hip, Trunk] -value: [0.78648, 0.99112, 0.98944, 0.94391] +value: [0.78648, 0.99112, 0.98944, 0.94836] diff --git a/Eurobench_format_code/test/output/subject_01_30sts/subphases_duration.yaml b/Eurobench_format_code/test/output/subject_01_30sts/subphases_duration.yaml index 10a4e42..88ae822 100644 --- a/Eurobench_format_code/test/output/subject_01_30sts/subphases_duration.yaml +++ b/Eurobench_format_code/test/output/subject_01_30sts/subphases_duration.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [Flexion Momentum, Momentum Transfer, Extension] -value: [0.21656, 0.19256, 0.62234] +value: [0.19089, 0.21824, 0.62234] diff --git a/Eurobench_format_code/test/output/subject_01_30sts/ult_overshoot.yaml b/Eurobench_format_code/test/output/subject_01_30sts/ult_overshoot.yaml index 2b454bc..9ba223e 100644 --- a/Eurobench_format_code/test/output/subject_01_30sts/ult_overshoot.yaml +++ b/Eurobench_format_code/test/output/subject_01_30sts/ult_overshoot.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [antero-posterior, medio-lateral] -value: [0.01238, 0.01215] +value: [0.04233, 0.00340] diff --git a/Eurobench_format_code/test/output/subject_01_30sts/ult_time.yaml b/Eurobench_format_code/test/output/subject_01_30sts/ult_time.yaml index 3703171..a5f0a5a 100644 --- a/Eurobench_format_code/test/output/subject_01_30sts/ult_time.yaml +++ b/Eurobench_format_code/test/output/subject_01_30sts/ult_time.yaml @@ -1,2 +1,2 @@ type: 'scalar' -value: 0.80038 +value: 0.75294 diff --git a/Eurobench_format_code/test/output/subject_01_5sts/CoM_work.yaml b/Eurobench_format_code/test/output/subject_01_5sts/CoM_work.yaml index 0fadd1a..edda4a6 100644 --- a/Eurobench_format_code/test/output/subject_01_5sts/CoM_work.yaml +++ b/Eurobench_format_code/test/output/subject_01_5sts/CoM_work.yaml @@ -1,2 +1,2 @@ -type: 'vector' -value: [9.84384, 12.28107] +type: 'scalar' +value: 221.31481 diff --git a/Eurobench_format_code/test/output/subject_01_5sts/CoP_stability.yaml b/Eurobench_format_code/test/output/subject_01_5sts/CoP_stability.yaml index 73c0ab3..7c6e258 100644 --- a/Eurobench_format_code/test/output/subject_01_5sts/CoP_stability.yaml +++ b/Eurobench_format_code/test/output/subject_01_5sts/CoP_stability.yaml @@ -1,2 +1,2 @@ -type: 'scalar' -value: 0.11301 +type: 'vector' +value: [0.40186, 0.04002] diff --git a/Eurobench_format_code/test/output/subject_01_5sts/subphases_duration.yaml b/Eurobench_format_code/test/output/subject_01_5sts/subphases_duration.yaml index 1e9fc07..f993270 100644 --- a/Eurobench_format_code/test/output/subject_01_5sts/subphases_duration.yaml +++ b/Eurobench_format_code/test/output/subject_01_5sts/subphases_duration.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [Flexion Momentum, Momentum Transfer, Extension] -value: [0.20790, 0.22040, 0.60494] +value: [0.18289, 0.24541, 0.60494] diff --git a/Eurobench_format_code/test/output/subject_01_5sts/ult_overshoot.yaml b/Eurobench_format_code/test/output/subject_01_5sts/ult_overshoot.yaml index c2f6826..b3bec83 100644 --- a/Eurobench_format_code/test/output/subject_01_5sts/ult_overshoot.yaml +++ b/Eurobench_format_code/test/output/subject_01_5sts/ult_overshoot.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [antero-posterior, medio-lateral] -value: [0.01413, 0.01007] +value: [0.04413, 0.00419] diff --git a/Eurobench_format_code/test/output/subject_01_5sts/ult_time.yaml b/Eurobench_format_code/test/output/subject_01_5sts/ult_time.yaml index bb35a64..d70f01a 100644 --- a/Eurobench_format_code/test/output/subject_01_5sts/ult_time.yaml +++ b/Eurobench_format_code/test/output/subject_01_5sts/ult_time.yaml @@ -1,2 +1,2 @@ type: 'scalar' -value: 0.95196 +value: 0.88161 diff --git a/Eurobench_format_code/test/output/subject_02_5sts/CoM_work.yaml b/Eurobench_format_code/test/output/subject_02_5sts/CoM_work.yaml index 4290c2e..5dc54bd 100644 --- a/Eurobench_format_code/test/output/subject_02_5sts/CoM_work.yaml +++ b/Eurobench_format_code/test/output/subject_02_5sts/CoM_work.yaml @@ -1,2 +1,2 @@ -type: 'vector' -value: [3.40741, 343.27661] +type: 'scalar' +value: -1862.09669 diff --git a/Eurobench_format_code/test/output/subject_02_5sts/CoP_stability.yaml b/Eurobench_format_code/test/output/subject_02_5sts/CoP_stability.yaml index 4c1f21d..526718b 100644 --- a/Eurobench_format_code/test/output/subject_02_5sts/CoP_stability.yaml +++ b/Eurobench_format_code/test/output/subject_02_5sts/CoP_stability.yaml @@ -1,2 +1,2 @@ -type: 'scalar' -value: 0.12424 +type: 'vector' +value: [0.41141, 0.02398] diff --git a/Eurobench_format_code/test/output/subject_02_5sts/subphases_duration.yaml b/Eurobench_format_code/test/output/subject_02_5sts/subphases_duration.yaml index bf525ae..5c33a37 100644 --- a/Eurobench_format_code/test/output/subject_02_5sts/subphases_duration.yaml +++ b/Eurobench_format_code/test/output/subject_02_5sts/subphases_duration.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [Flexion Momentum, Momentum Transfer, Extension] -value: [0.18292, 0.16103, 0.47527] +value: [0.16415, 0.17979, 0.47527] diff --git a/Eurobench_format_code/test/output/subject_02_5sts/ult_overshoot.yaml b/Eurobench_format_code/test/output/subject_02_5sts/ult_overshoot.yaml index 5a085e3..b655051 100644 --- a/Eurobench_format_code/test/output/subject_02_5sts/ult_overshoot.yaml +++ b/Eurobench_format_code/test/output/subject_02_5sts/ult_overshoot.yaml @@ -1,3 +1,3 @@ type: 'vector' label: [antero-posterior, medio-lateral] -value: [0.01333, 0.01131] +value: [0.06211, 0.00319] diff --git a/Eurobench_format_code/test/output/subject_02_5sts/ult_time.yaml b/Eurobench_format_code/test/output/subject_02_5sts/ult_time.yaml index 426ccd6..70cb0f8 100644 --- a/Eurobench_format_code/test/output/subject_02_5sts/ult_time.yaml +++ b/Eurobench_format_code/test/output/subject_02_5sts/ult_time.yaml @@ -1,2 +1,2 @@ type: 'scalar' -value: 0.67225 +value: 0.47839