From 7c4d08f786df32fdfa46ace2fc60cc9d09ae8e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Tue, 15 Oct 2024 14:33:41 +0200 Subject: [PATCH] Log results of main script in a .csv file --- batch_column_processing.m | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/batch_column_processing.m b/batch_column_processing.m index a6b8d64..2aea0bb 100755 --- a/batch_column_processing.m +++ b/batch_column_processing.m @@ -43,11 +43,14 @@ if (mask == 0) end meter = load_meter(); -if (meter == 0) +if (isequal(meter, 0)) path(oldpath); return end +results_dir = get_last_path(); +results_dir = uigetdir(results_dir, "Select directory for results"); + FileType = '*.png'; % process all directories in cycles @@ -66,7 +69,8 @@ for i=1:nSelectedDirectory path(oldpath); return end - main_wb = waitbar(0, 'Whole processing progress'); + close(); + main_wb = waitbar(0, 'Whole batch progress'); end waitbar((i - 0.5)/nSelectedDirectory, main_wb); @@ -88,11 +92,21 @@ for i=1:nSelectedDirectory intensity = mean(double(Figure), Weights = mask); [water(j), bubble_top(j), bubble_bot(j)] = get_levels(intensity); time(j) = name_to_time(ImageName) - start_time; + if (j == 1) + write_mode = 'overwrite'; + else + write_mode = 'append'; + end + writecell(... + [{FFiles(j).name}, {FFiles(j).date}, ... + {water(j)}, {bubble_top(j)}, {bubble_bot(j)}],... + [results_dir '/' SelectedDirectory{i} '.csv'],... + "WriteMode", write_mode); end close(wait_bar); waitbar(i/nSelectedDirectory, main_wb); - figure + figure() plot(seconds(time), 100 * meter([water; bubble_top; bubble_bot]'), 'LineWidth', 3); legend('Water level', 'Bubble top', 'Bubble bottom','Location', 'north'); xlabel('Time (s)'); -- 2.30.2