k-Wave Toolbox |
![]() ![]() |
On this page… |
---|
This example demonstrates how to save the simulation animations as a movie. It builds on the Heterogeneous Propagation Medium Example.
In the preceeding example, the optional input 'PlotLayout'
was used to change the default behaviour of kspaceFirstOrder2D
. Here several other optional inputs are used to save the simulation animation to a movie file. By setting 'RecordMovie'
to true
, the displayed image frames are saved and exported as a movie with a date and time stamped filename. A user defined filename can also be given by setting the 'MovieName'
input to an arbitrary string. In 2D, the movie frames are captured using im2frame
and converted using movie2avi
thus the size of the movie will depend on the size of the simulation grid (in 1D and 3D the movie frames are captured using getframe
and thus the movie size is independent of the simulation grid).
% set the input arguements input_args = {'PlotLayout', true, 'RecordMovie', true, 'MovieName', 'example_movie'}; % run the simulation sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});
As the movie frames mimic those used for the simulation animation, the output can be controlled by changing the animation settings. The image scaling can be set using 'PlotScale'
, and the number of iterations which must pass before the simulation plot is updated can be controlled via 'PlotFreq'
. Note, the default color map used for the animation has zero set to white (see getColorMap
), thus using a scaling parameter set to [-a, a] will give the best visual results.
% set the input arguements input_args = {..., 'PlotScale', [-2, 2], 'PlotFreq', 5, ...};
Optional inputs can also be passed directly to movie2avi
via 'MovieArgs'
. An example of changing the default frame rate is given below.
% set the input arguements input_args = {..., 'MovieArgs', {'fps', 30}, ...};
Note, by default k-Wave sets 'Compression'
to 'Cinepak'
for 32-bit Windows, and 'None'
for 64-bit Windows and Unix.
![]() |
Heterogeneous Propagation Medium | Modelling A Focussed Detector | ![]() |
© 2009, 2010 Bradley Treeby and Ben Cox.