Giter Site home page Giter Site logo

oofullwave's Introduction

Object oriented tools for Fullwave simulations

This repository contains an object-oriented wrapper for Fullwave and a demo script for usage. Fullwave is written by Gianmarco Pinton.

Setup

  • fwObj() - Initialize simulation object by setting parameters keywords-style

Methods

  • make_xdc() - Initialize transducer properties
  • focus_xdc() - Calculate transmit focal delays and sets up initial conditions
  • add_wall() - Add abdominal wall in nearfield
  • add_speckle() - Add scatterers to field, with option to include cysts of tunable size and scattering properties
  • add_points() - Add point targets to field with varying impedance contrast
  • add_fii_phantom() - Add Field II phantom using phantom output from ultratrack
  • preview_sim() - Preview acoustic map, focusing delays, and transmitted pulse
  • do_sim() - Perform simulation, with option to save channel data or field pressure distribution
  • make_acq_params() - Convert simulation parameters to acq_params, necessary for use with beamforming tools

Helper scripts

Workflow

  • Call fwObj() to initialize the simulation object-oriented
  • Set transducer properties and call make_xdc()
  • Define the focus and call focus_linear()
  • If desired, change the field maps via add_wall(), make_speckle(), make_points(), or add_fii_phantom()
  • Run the simulation with do_sim()

Example set up

  • setup_example.m - Example usage with varying focal configurations and simple field map changes
%%% Create fwObj %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c0 = 1540;                                  % Homogeneous speed of sound
f0 = 2e6;                                   % Transmit center frequency (Hz)
wZ = 8e-2;                                  % Axial extent (m)
wY = 6e-2;                                  % Lateral extent (m)
td =(wZ+1e-2)/c0;                           % Time duration of simulation (s)
sim = fwObj('c0',c0,'f0',f0,'wY',wY,'wZ',wZ,'td',td);

First, we will call fwObj() to initialize the simulation object. In this example, we have specified the homogeneous speed of sound, transmit center frequency, axial and lateral extents of the field, and the time duration of simulation.

%%% Specify transducer and transmit parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%
sim.xdc.type = 'linear';                    % Curvilinear or linear
sim.xdc.pitch = 0.000412;                   % Center-to-center element spacing
sim.xdc.n = 64;                             % Number of elements
sim.make_xdc();                             % Call make_xdc to set up transducer

Next, we will set transducer properties and call make_xdc() to configure the remaining properties. The transducer type, pitch, kerf, and number of elements is required.

%%% Focused transmit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
focus = [0 0.03];                           % Focal point in [y z] (m)
sim.focus_xdc(focus);                       % Call focus_linear to calculate icmat

%%% Plane transmit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
th = 15;                                    % Angle for plane wave transmit (degrees)
focus = 10*[sind(th) cosd(th)];             % Very far focus to flatten delays
sim.focus_xdc(focus);                       % Call focus_linear to calculate icmat

%%% Diverging transmit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
focus = [0 -0.03];                          % Negative focus for diverging in [y z] (m)
sim.focus_xdc(focus);                       % Call focus_linear to calculate icmat

focus_xdc() is called to calculate focal delays in transmit and set up the initial condition matrix (icmat). Plane wave transmit is achieved with a large focal distance relative to the field extent; diverging wave transmit is achieved with a negative focal depth. The corresponding icmat and element-wise focal delays can be seen here: alt text

%%% 2-cycle pulse %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
focus = [0 0.03];                           % Focal point in [y z] (m)
sim.focus_xdc(focus);                       % Call focus_linear to calculate icmat

%%% 10-cycle pulse %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sim.input_vars.ncycles = 10;
sim.make_xdc();                             % Call make_xdc to set up transducer
focus = [0 0.03];                           % Focal point in [y z] (m)
sim.focus_xdc(focus);                       % Call focus_linear to calculate icmat

%%% Chirp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
flow = 1e6; fhigh = 3e6;
t = 0:sim.grid_vars.dT:6e-6; 
k = (pi/max(t))*(fhigh-flow);
phi = k*t.^2;
excitation = sin(2*pi*flow*t+phi);
sim.focus_xdc(focus,[],[],excitation); 

The excitation may be altered by changing the ncycles input variable or manually defining an excitation sequence prior to calling focus_linear(). Here, the default 2-cycle pulse is shown with a 10-cycle and chirp variant: alt text

%%% Add abdominal wall with lateral offset %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wall_name = 'r75hi';                        % Mast abdominal wall name
offset = 0.01;                              % Lateral offset from center (m)
sim.add_wall(wall_name,offset);

A Mast abdominal wall can be added in the nearfield using add_wall(). Here, we add one with a lateral offset of 1 cm.

%%% Add speckle and cysts of varying impedance contrasts %%%%%%%%%%%%%%%%%%
cC = 1e-3*[-15 50; -5 50; 5 50; 15 50];    % Locations of cyst centers in [y z] (m)
rC = 0.004*ones(size(cC,1),1);             % Radii of cysts (m)
zC = [0 0.025 0.075 0.1]';                 % Cyst relative impedance contrast
sim.add_speckle('nscat',50,'csr',0.05,'nC',length(rC),'cC',cC,'rC',rC,'zC',zC);

Scattering and cyst targets can be added by calling make_speckle(). The impedance mismatch, scattering density, and cyst size and location can be adjusted. Combining the scatterers with the abdominal wall, we arrive at the following cmap: alt text

%%% Collect single transmit channel data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t = tic;
rf_data = double(sim.do_sim());
fprintf('   Channel data generated in %1.2f seconds \n',toc(t))

Finally, the simulation is run by calling do_sim(). Here, we collect single transmit channel data.

Demo

A simple demo for a 1 MHz pulse focused at 4 cm through an abdominal wall can be found in demo.m.

References

oofullwave's People

Contributors

nbottenus avatar jameslong12 avatar

Stargazers

 avatar Guokr avatar Yuxin Zhang avatar yl642 avatar Sean Huver avatar  avatar  avatar Walter Simson avatar Leo avatar Mark Palmeri avatar Suyash Kumar avatar David Bradway avatar Ouwen Huang avatar Yuanguo Wang avatar

oofullwave's Issues

lack of abdominal wall

Hi James,

I'm very interested in your repositry, and I'm trying the script 'demo.m'. But it seems like the file of abdominal wall does not exists, so I cannot run it .
Could you please provide the needed files for this step below:?

%% 4. Add abdominal wall and speckle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sim.add_wall('r75hi'); % Mast abdominal wall name
sim.add_speckle('nscat',25); % Add 25 scat/res cell

Best regards,
yuxin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.