From bed9c5e616a57696b4d38c9fe2149e84ba2550d4 Mon Sep 17 00:00:00 2001 From: cbender98 Date: Thu, 27 Apr 2023 18:19:38 +0200 Subject: [PATCH 1/3] use process unique file naming for kwave files --- .../acoustic_forward_module/simulate_2D.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m b/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m index e1255e16..d9d68a6b 100644 --- a/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m +++ b/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m @@ -147,11 +147,19 @@ datacast = 'single'; end + +basename = strsplit(optical_path, '/'); +basename = strsplit(basename{end}, '.'); +basename = basename{1}; +date_str = datestr(now, 'HH-MM-SS-FFF'); +pid = feature('GetPid'); +tmp_path_name = ['kwave__' basename '__' date_str '__' num2str(pid)]; + input_args = {'DataCast', datacast, 'PMLInside', settings.pml_inside, ... 'PMLAlpha', settings.pml_alpha, 'PMLSize', 'auto', ... 'PlotPML', settings.plot_pml, 'RecordMovie', settings.record_movie, ... 'MovieName', settings.movie_name, 'PlotScale', [-1, 1], 'LogScale', settings.acoustic_log_scale, ... - 'Smooth', p0_smoothing}; + 'Smooth', p0_smoothing, 'DataName', tmp_path_name}; if settings.gpu == true time_series_data = kspaceFirstOrder2DG(kgrid, medium, source, sensor, input_args{:}); From 5b5afd86542073932301db54f7311be1ff1798a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Hinrich=20N=C3=B6lke?= Date: Fri, 26 Jul 2024 13:58:11 +0200 Subject: [PATCH 2/3] refactor and add comments - use fileparts - use datetime instead of datestr - use sprintf instead of string concatenation --- .../acoustic_forward_module/simulate_2D.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m b/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m index d9d68a6b..55ebd510 100644 --- a/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m +++ b/simpa/core/simulation_modules/acoustic_forward_module/simulate_2D.m @@ -147,13 +147,20 @@ datacast = 'single'; end +% Extract the filename from the optical path, add the current time in milliseconds, +% and add the process id to make the filename unique -basename = strsplit(optical_path, '/'); -basename = strsplit(basename{end}, '.'); -basename = basename{1}; -date_str = datestr(now, 'HH-MM-SS-FFF'); +% Extract basename from the optical path +[~, basename, ~] = fileparts(optical_path); + +% Get current time in HH-mm-ss-SSS format +date_str = char(datetime('now', 'Format', 'HH-mm-ss-SSS')); + +% Get the process id pid = feature('GetPid'); -tmp_path_name = ['kwave__' basename '__' date_str '__' num2str(pid)]; + +% Construct the unique temporary path name +tmp_path_name = sprintf('kwave__%s__%s__%d', basename, date_str, pid); input_args = {'DataCast', datacast, 'PMLInside', settings.pml_inside, ... 'PMLAlpha', settings.pml_alpha, 'PMLSize', 'auto', ... From e6c3a87f0f4f023439ce0d5049c8e317eebca027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Hinrich=20N=C3=B6lke?= Date: Fri, 26 Jul 2024 14:05:16 +0200 Subject: [PATCH 3/3] add the unique file naming for the 3d simulation --- .../acoustic_forward_module/simulate_3D.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/simpa/core/simulation_modules/acoustic_forward_module/simulate_3D.m b/simpa/core/simulation_modules/acoustic_forward_module/simulate_3D.m index 1772c0c8..6b0fe934 100644 --- a/simpa/core/simulation_modules/acoustic_forward_module/simulate_3D.m +++ b/simpa/core/simulation_modules/acoustic_forward_module/simulate_3D.m @@ -148,11 +148,26 @@ datacast = 'single'; end +% Extract the filename from the optical path, add the current time in milliseconds, +% and add the process id to make the filename unique + +% Extract basename from the optical path +[~, basename, ~] = fileparts(optical_path); + +% Get current time in HH-mm-ss-SSS format +date_str = char(datetime('now', 'Format', 'HH-mm-ss-SSS')); + +% Get the process id +pid = feature('GetPid'); + +% Construct the unique temporary path name +tmp_path_name = sprintf('kwave__%s__%s__%d', basename, date_str, pid); + input_args = {'DataCast', datacast, 'PMLInside', settings.pml_inside, ... 'PMLAlpha', double(settings.pml_alpha), 'PMLSize', 'auto', ... 'PlotPML', settings.plot_pml, 'RecordMovie', settings.record_movie, ... 'MovieName', settings.movie_name, 'PlotScale', [-1, 1], 'LogScale', settings.acoustic_log_scale, ... - 'Smooth', p0_smoothing}; + 'Smooth', p0_smoothing, 'DataName', tmp_path_name}; if settings.gpu == true time_series_data = kspaceFirstOrder3DG(kgrid, medium, source, sensor, input_args{:});