Skip to content

Commit fdeb04e

Browse files
authored
Merge branch 'ucl-bug:main' into sp/4-bug_line_elements
2 parents bc22c02 + 0a4fcbf commit fdeb04e

93 files changed

Lines changed: 1195 additions & 546 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/unit_tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Run unit tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
unit-tests:
13+
name: Run unit tests
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up MATLAB
20+
uses: matlab-actions/setup-matlab@v2
21+
with:
22+
products: Signal_Processing_Toolbox
23+
cache: true
24+
25+
- name: Run unit tests
26+
uses: matlab-actions/run-command@v2
27+
with:
28+
command: |
29+
addpath("${{ github.workspace }}/k-Wave");
30+
cd("${{ github.workspace }}/k-Wave/testing/unit");
31+
test_struct = runUnitTests("",false);
32+
save('test_struct.mat', 'test_struct');
33+
startup-options: -nojvm -logfile output.log
34+
35+
- name: Show test results & create artifact
36+
uses: matlab-actions/run-command@v2
37+
with:
38+
command: |
39+
addpath("${{ github.workspace }}/k-Wave");
40+
cd("${{ github.workspace }}/k-Wave/testing/unit");
41+
load('test_struct.mat', 'test_struct');
42+
runUnitTests_show_results(test_struct);
43+
runUnitTests_artifact(test_struct);
44+
startup-options: -nojvm
45+
46+
- name: Upload artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: unit_test_results
50+
path: ${{ github.workspace }}/k-Wave/testing/unit/test_results.json

k-Wave/acousticFieldPropagator.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
%#ok<*UNRCH>
116116

117117
% start the timer
118-
start_time = clock;
118+
start_time = datetime('now');
119119

120120
% =========================================================================
121121
% DEFINE LITERALS
@@ -436,7 +436,7 @@
436436
end
437437

438438
% update command line status
439-
disp([' computation completed in ' scaleTime(etime(clock, start_time))]);
439+
disp([' computation completed in ' scaleTime(seconds(datetime('now') - start_time))]);
440440

441441
% stop evaluation
442442
return
@@ -555,7 +555,7 @@
555555
end
556556

557557
% update command line status
558-
disp([' computation completed in ' scaleTime(etime(clock, start_time))]);
558+
disp([' computation completed in ' scaleTime(seconds(datetime('now') - start_time))]);
559559

560560
% plot the propagator
561561
if plot_propagator

k-Wave/acousticFieldPropagatorC.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
%#ok<*AGROW>
6767

6868
% start time
69-
global_start_time = clock;
69+
global_start_time = datetime('now');
7070

7171
% check the inputs are 3D
7272
if numDim(amp_in) ~= 3
@@ -224,10 +224,10 @@
224224
acousticFieldPropagator(amp_in, phase_in, dx, f0, c0, 'SaveToDisk', input_filename, input_args{:});
225225

226226
% store time to save input
227-
compute_time.save_input = etime(clock, global_start_time);
227+
compute_time.save_input = seconds(datetime('now') - global_start_time);
228228

229229
% start timer
230-
compute_start_time = clock;
230+
compute_start_time = datetime('now');
231231

232232
% run the simulation in C++ and print outputs to the MATLAB command line
233233
if isunix
@@ -250,10 +250,10 @@
250250
end
251251

252252
% store time to run simulation
253-
compute_time.simulation = etime(clock, compute_start_time);
253+
compute_time.simulation = seconds(datetime('now') - compute_start_time);
254254

255255
% start timer
256-
load_start_time = clock;
256+
load_start_time = datetime('now');
257257

258258
% load the C++ data back from disk using h5read
259259
pressure = h5read(output_filename, '/pressure_out');
@@ -274,10 +274,10 @@
274274
end
275275

276276
% store time to load output
277-
compute_time.load_output = etime(clock, load_start_time);
277+
compute_time.load_output = seconds(datetime('now') - load_start_time);
278278

279279
% store total time
280-
compute_time.total = etime(clock, global_start_time);
280+
compute_time.total = seconds(datetime('now') - global_start_time);
281281

282282
% assign outputs
283283
switch nargout

k-Wave/angularSpectrum.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
% along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
135135

136136
% start timer
137-
start_time = clock;
137+
start_time = datetime('now');
138138

139139
% =========================================================================
140140
% INPUT CHECKING
@@ -278,7 +278,7 @@
278278

279279
% update command line status
280280
disp('Running angular spectrum projection...');
281-
disp([' start time: ' datestr(start_time)]);
281+
disp([' start time: ' char(start_time)]);
282282
disp([' input plane size: ' num2str(Nx) ' by ' num2str(Ny) ' grid points (' num2str(scale * Nx * dx) ' by ' num2str(scale * Ny * dx) prefix 'm)']);
283283
disp([' grid expansion: ' num2str(grid_expansion) ' grid points']);
284284

@@ -399,8 +399,8 @@
399399
end
400400

401401
% update command line status
402-
loop_start_time = clock;
403-
disp([' precomputation completed in ' scaleTime(etime(loop_start_time, start_time))]);
402+
loop_start_time = datetime('now');
403+
disp([' precomputation completed in ' scaleTime(seconds(loop_start_time-start_time))]);
404404
disp(' starting z-step loop...');
405405

406406
% loop over z-positions
@@ -494,7 +494,7 @@
494494

495495
% update command line status
496496
if z_index == loops_for_time_est
497-
disp([' estimated simulation time ' scaleTime(etime(clock, loop_start_time) * Nz / z_index) '...']);
497+
disp([' estimated simulation time ' scaleTime(seconds(datetime('now') - loop_start_time) * Nz / z_index) '...']);
498498
end
499499

500500
% plot updates
@@ -522,7 +522,7 @@
522522
end
523523

524524
% update command line status
525-
disp([' simulation completed in ' scaleTime(etime(clock, loop_start_time))]);
525+
disp([' simulation completed in ' scaleTime(seconds(datetime('now') - loop_start_time))]);
526526

527527
% =========================================================================
528528
% POST PROCESSING
@@ -576,4 +576,4 @@
576576
end
577577

578578
% update command line status
579-
disp([' total computation time ' scaleTime(etime(clock, start_time))]);
579+
disp([' total computation time ' scaleTime(seconds(datetime('now') - start_time))]);

k-Wave/angularSpectrumCW.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
% along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
107107

108108
% start timer
109-
start_time = clock;
109+
start_time = datetime('now');
110110

111111
% =========================================================================
112112
% INPUT CHECKING
@@ -256,7 +256,7 @@
256256

257257
% update command line status
258258
disp('Running CW angular spectrum projection...');
259-
disp([' start time: ' datestr(start_time)]);
259+
disp([' start time: ' char(start_time)]);
260260
disp([' input plane size: ' num2str(Nx) ' by ' num2str(Ny) ' grid points (' num2str(scale * Nx * dx) ' by ' num2str(scale * Ny * dx) prefix 'm)']);
261261
disp([' grid expansion: ' num2str(grid_expansion) ' grid points']);
262262

@@ -347,8 +347,8 @@
347347
% =========================================================================
348348

349349
% update command line status
350-
loop_start_time = clock;
351-
disp([' precomputation completed in ' scaleTime(etime(loop_start_time, start_time))]);
350+
loop_start_time = datetime('now');
351+
disp([' precomputation completed in ' scaleTime(seconds(loop_start_time - start_time))]);
352352
disp(' starting time loop...');
353353

354354
% loop over z-positions
@@ -395,13 +395,13 @@
395395

396396
% update command line status
397397
if z_index == loops_for_time_est
398-
disp([' estimated simulation time ' scaleTime(etime(clock, loop_start_time) * Nz / z_index) '...']);
398+
disp([' estimated simulation time ' scaleTime(seconds(datetime('now') - loop_start_time) * Nz / z_index) '...']);
399399
end
400400

401401
end
402402

403403
% update command line status
404-
disp([' simulation completed in ' scaleTime(etime(clock, loop_start_time))]);
404+
disp([' simulation completed in ' scaleTime(seconds(datetime('now') - loop_start_time))]);
405405

406406
% =========================================================================
407407
% POST PROCESSING
@@ -427,4 +427,4 @@
427427
end
428428

429429
% update command line status
430-
disp([' total computation time ' scaleTime(etime(clock, start_time))]);
430+
disp([' total computation time ' scaleTime(seconds(datetime('now') - start_time))]);

k-Wave/getAffineMatrix.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
% translation - translation given as [dx, dy] in 2D and
1313
% [dx, dy, dz] in 3D
1414
% rotation - rotation angle/s in degrees given as
15-
% [th] in 2D (counter-clockwise) and
15+
% [th] in 2D (counter-clockwise)and
1616
% [x_th, y_th, z_th] in 3D (rotate about x
1717
% then y' then z'') [degrees]
1818
%

k-Wave/getDateString.m

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
%
44
% DESCRIPTION:
55
% getDateString returns a string of the current date and time using
6-
% datestr but replacing the white space and : character with an en
7-
% dash.
6+
% datetime in the following format: 'dd-MMM-yyyy-HH-mm-ss'.
87
%
98
% USAGE:
109
% date_string = getDateString()
@@ -17,8 +16,7 @@
1716
% This function is part of the k-Wave Toolbox (http://www.k-wave.org)
1817
% Copyright (C) 2009-2017 Bradley Treeby
1918
%
20-
% See also clock, date, datestr
21-
19+
% See also: datetime
2220
% This file is part of k-Wave. k-Wave is free software: you can
2321
% redistribute it and/or modify it under the terms of the GNU Lesser
2422
% General Public License as published by the Free Software Foundation,
@@ -33,8 +31,4 @@
3331
% along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
3432

3533
% get the current time
36-
date_string = datestr(clock);
37-
38-
% replace the space and : characters with -
39-
date_string = strrep(date_string, ' ', '-');
40-
date_string = strrep(date_string, ':', '-');
34+
date_string = char(datetime("now", "Format", "dd-MMM-yyyy-HH-mm-ss"));

k-Wave/helpfiles/example_at_array_as_sensor.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
<h1>Defining A Sensor Using An Array Transducer Example</h1>
1313

1414
<p>This example provides a demonstration of using the <code><a href="kWaveArray.html">kWaveArray</a></code> class to define an array transducer with 20 arc-shaped elements which is then used as a receiver array. It builds on the <a href="example_at_array_as_source.html">Defining A Source Using An Array Transducer Example</a>.</p>
15-
<p>
16-
<ul>
17-
<li><a href="matlab:edit([getkWavePath('examples') 'example_at_array_as_sensor.m']);" target="_top">Open the file in the MATLAB Editor</a></li>
18-
<li><a href="matlab:run([getkWavePath('examples') 'example_at_array_as_sensor']);" target="_top">Run the file in MATLAB</a></li>
19-
</ul>
15+
16+
To open the file in MATLAB, enter the following command in the MATLAB Command Window.
17+
<pre class="codeinput">
18+
edit([getkWavePath('examples') 'example_at_array_as_sensor.m']);
19+
</pre>
20+
To run the file, enter the following command in the MATLAB Command Window.
21+
<pre class="codeinput">
22+
run([getkWavePath('examples') 'example_at_array_as_sensor']);
23+
</pre>
2024
</p>
2125

2226
<h2>Contents</h2>

k-Wave/helpfiles/example_at_array_as_source.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
<h1>Defining A Source Using An Array Transducer Example</h1>
1313

1414
<p>This example provides a demonstration of using the <code><a href="kWaveArray.html">kWaveArray</a></code> class to define an array transducer with three arc-shaped elements without staircasing errors.</p>
15-
<p>
16-
<ul>
17-
<li><a href="matlab:edit([getkWavePath('examples') 'example_at_array_as_source.m']);" target="_top">Open the file in the MATLAB Editor</a></li>
18-
<li><a href="matlab:run([getkWavePath('examples') 'example_at_array_as_source']);" target="_top">Run the file in MATLAB</a></li>
19-
</ul>
15+
16+
To open the file in MATLAB, enter the following command in the MATLAB Command Window.
17+
<pre class="codeinput">
18+
edit([getkWavePath('examples') 'example_at_array_as_source.m']);
19+
</pre>
20+
To run the file, enter the following command in the MATLAB Command Window.
21+
<pre class="codeinput">
22+
run([getkWavePath('examples') 'example_at_array_as_source']);
23+
</pre>
2024
</p>
2125

2226
<p>For a more detailed discussion of this example and the underlying techniques, see E. S. Wise, B. T. Cox, J. Jaros, & B. E. Treeby (2019). Representing arbitrary acoustic source and sensor distributions in Fourier collocation methods. <em>The Journal of the Acoustical Society of America</em>, 146(1), 278-288. <a href="https://doi.org/10.1121/1.5116132">https://doi.org/10.1121/1.5116132</a>.</p>

k-Wave/helpfiles/example_at_linear_array_transducer.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
<h1>Modelling A Linear Array Transducer Example</h1>
1313

1414
<p>This example provides a demonstration of using the <code><a href="kWaveArray.html">kWaveArray</a></code> class to define a linear array transducer with 15 rectangular elements. Electronic focusing is then used to transmit an ultrasound pulse. It builds on the <a href="example_at_array_as_source.html">Defining A Source Using An Array Transducer Example</a>.</p>
15-
<p>
16-
<ul>
17-
<li><a href="matlab:edit([getkWavePath('examples') 'example_at_linear_array_transducer.m']);" target="_top">Open the file in the MATLAB Editor</a></li>
18-
<li><a href="matlab:run([getkWavePath('examples') 'example_at_linear_array_transducer']);" target="_top">Run the file in MATLAB</a></li>
19-
</ul>
15+
16+
To open the file in MATLAB, enter the following command in the MATLAB Command Window.
17+
<pre class="codeinput">
18+
edit([getkWavePath('examples') 'example_at_linear_array_transducer.m']);
19+
</pre>
20+
To run the file, enter the following command in the MATLAB Command Window.
21+
<pre class="codeinput">
22+
run([getkWavePath('examples') 'example_at_linear_array_transducer']);
23+
</pre>
2024
</p>
2125

2226
<h2>Contents</h2>

0 commit comments

Comments
 (0)