├── DICOMnaming.m ├── DisplayImg.m ├── LinearArrayImaging.m ├── Mat_field.mexmaci64 ├── MultipleFrames.m ├── README.md ├── calc_h.m ├── calc_hhp.m ├── calc_hp.m ├── calc_scat.m ├── calc_scat_all.m ├── calc_scat_multi.m ├── cyst_phantom.m ├── ele_apodization.m ├── ele_delay.m ├── ele_waveform.m ├── field_debug.m ├── field_end.m ├── field_guide.m ├── field_info.m ├── field_init.m ├── field_logo.m ├── logo_field.mat ├── set_field.m ├── set_sampling.m ├── users_guide.pdf ├── xdc_2d_array.m ├── xdc_apodization.m ├── xdc_baffle.m ├── xdc_center_focus.m ├── xdc_concave.m ├── xdc_convert.m ├── xdc_convex_array.m ├── xdc_convex_focused_array.m ├── xdc_convex_focused_multirow.m ├── xdc_dynamic_focus.m ├── xdc_excitation.m ├── xdc_focus.m ├── xdc_focus_times.m ├── xdc_focused_array.m ├── xdc_focused_multirow.m ├── xdc_free.m ├── xdc_get.m ├── xdc_impulse.m ├── xdc_line_convert.m ├── xdc_linear_array.m ├── xdc_linear_multirow.m ├── xdc_lines.m ├── xdc_piston.m ├── xdc_quantization.m ├── xdc_rectangles.m ├── xdc_show.m ├── xdc_times_focus.m └── xdc_triangles.m /DICOMnaming.m: -------------------------------------------------------------------------------- 1 | % File to write TIFF (.tif) files into DICOM (.dcm) files 2 | 3 | %write DICOM figure 4 | 5 | for a = 1:1:10 6 | % Finding the TIFF file name 7 | fileName = string(a); 8 | fileName = 'Cyst'+fileName+'.tif' 9 | IMG(a) = fileName; 10 | 11 | % Creating the DICOM file name 12 | DICOMfile = string(a); 13 | DICOMfile = 'DICOM'+DICOMfile+'.dcm'; 14 | dicomwrite(imread(IMG(a)),DICOMfile); 15 | end 16 | -------------------------------------------------------------------------------- /DisplayImg.m: -------------------------------------------------------------------------------- 1 | %% Displaying multipla figures of phantom cyst using MONTAGE 2 | 3 | img1 = imread('Cyst_r(1).fig'); 4 | img2 = imread('Cyst_r(2).fig'); 5 | img3 = imread('Cyst_r(3).fig'); 6 | img4 = imread('Cyst_r(4).fig'); 7 | img5 = imread('Cyst_r(5).fig'); 8 | 9 | multiImg = cat(3, img1, img2, img3, img4, img5, img4, img3, img2, img1); 10 | 11 | montage(multiImg); 12 | -------------------------------------------------------------------------------- /LinearArrayImaging.m: -------------------------------------------------------------------------------- 1 | % Example of use of the new Field II program running under Matlab 2 | % 3 | % This example shows how a linear array B-mode system scans an image 4 | % This script assumes that the field_init procedure has been called 5 | % Example by Joergen Arendt Jensen, Version 2.0, March 22, 2011. 6 | 7 | function [x, depth, env_gray] = LinearArrayImaging(radius) 8 | % Generate the transducer apertures for send and receive 9 | 10 | % Transducer center frequency [Hz] 11 | f0 = 3e6; 12 | 13 | % Sampling frequency [Hz] 14 | fs = 100e6; 15 | 16 | % Speed of sound [m/s] 17 | c = 1540; 18 | 19 | % Wave length [m] 20 | lambda = c/f0; 21 | 22 | % Width of element 23 | width = lambda; 24 | 25 | % Height of element [m] 26 | element_height = 5/1000; 27 | 28 | % Kerf [m] 29 | kerf = width/20; 30 | 31 | % Fixed focal point [m] 32 | focus = [0 0 70]/1000; 33 | 34 | % Number of elements in the transducer 35 | N_elements = 192; 36 | 37 | % Active elements in the transducer 38 | N_active = 64; 39 | 40 | 41 | % Set the sampling frequency 42 | set_sampling(fs); 43 | 44 | % Generate aperture for emission 45 | emit_aperture = xdc_linear_array (N_elements, width, element_height, kerf, 1, 5, focus); 46 | 47 | % Set the impulse response and excitation of the emit aperture 48 | impulse_response = sin(2*pi*f0*(0:1/fs:2/f0)); 49 | impulse_response = impulse_response.*hanning(max(size(impulse_response))).'; 50 | xdc_impulse (emit_aperture, impulse_response); 51 | 52 | excitation = sin(2*pi*f0*(0:1/fs:2/f0)); 53 | xdc_excitation (emit_aperture, excitation); 54 | 55 | % Generate aperture for reception 56 | receive_aperture = xdc_linear_array (N_elements, width, element_height, kerf, 1, 5, focus); 57 | 58 | % Set the impulse response for the receive aperture 59 | xdc_impulse (receive_aperture, impulse_response); 60 | 61 | % Load the computer phantom 62 | [phantom_positions, phantom_amplitudes] = cyst_phantom(10000, radius); 63 | 64 | % Do linear array imaging 65 | % Number of A-lines in image (in this case, 192 - 64 + 1) 66 | no_lines = N_elements - N_active + 1; 67 | 68 | % Increment for image 69 | dx = width; 70 | 71 | z_focus = 50/1000 72 | 73 | % Pre-allocate some storage 74 | image_data=zeros(1,no_lines); 75 | 76 | for i = 1:no_lines 77 | i 78 | % Find position for imaging 79 | x = (i-1-no_lines/2)*dx; 80 | 81 | % Set the focus for this direction 82 | xdc_center_focus (emit_aperture, [x 0 0]); 83 | xdc_focus (emit_aperture, 0, [x 0 z_focus]); 84 | xdc_center_focus (receive_aperture, [x 0 0]); 85 | xdc_focus (receive_aperture, 0, [x 0 z_focus]); 86 | 87 | % Set the active elements using the apodization 88 | apo = [zeros(1, i-1) hamming(N_active).' zeros(1, N_elements-N_active-i+1)]; 89 | xdc_apodization (emit_aperture, 0, apo); 90 | xdc_apodization (receive_aperture, 0, apo); 91 | 92 | % Calculate the received response 93 | [v, t1] = calc_scat(emit_aperture, receive_aperture, phantom_positions, phantom_amplitudes); 94 | % Store the result 95 | image_data(1:max(size(v)),i) = v; 96 | times(i) = t1; 97 | end 98 | 99 | % Free space for apertures 100 | xdc_free (emit_aperture) 101 | xdc_free (receive_aperture) 102 | 103 | % Adjust the data in time and display it as 104 | % a gray scale image 105 | min_sample = min(times)*fs; 106 | for i = 1:no_lines 107 | rf_env = abs(hilbert([zeros(round(times(i)*fs-min_sample),1); 108 | image_data(:,i)])); 109 | env(1:size(rf_env,1),i) = rf_env; 110 | end 111 | 112 | 113 | % make logarithmic compression to a 60 dB dynamic range 114 | % with proper units on the axis 115 | x = ((1:no_lines)-no_lines/2)*dx; 116 | depth = ((0:size(env,1)-1)+min_sample)/fs*c/2; 117 | env_dB = 20*log10(env); 118 | env_dB = env_dB-max(max(env_dB)); 119 | env_gray = 127*(env_dB+60)/60; 120 | 121 | 122 | % image(x*1000, depth*1000, env_gray) 123 | % xlabel('Lateral distance [mm]') 124 | % ylabel('Depth [mm]') 125 | % axis('image') 126 | % colormap(gray(128)) 127 | % title('Image of cyst phantom (60 dB dynamic range)') 128 | end -------------------------------------------------------------------------------- /Mat_field.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreeHand-UltraSound/MatLab-FieldII/7ab7555f6fbe1296fb5187268de21e3682de32cf/Mat_field.mexmaci64 -------------------------------------------------------------------------------- /MultipleFrames.m: -------------------------------------------------------------------------------- 1 | % Function to call LinearArrayImaging N times to create N frames of the phantom cyst. 2 | % Each call will have a different value for the radius, corresponding to a 3 | % displacement made by the probe. 4 | % 5 | % Assumptions: 6 | % - Radius: r = 5/10^3 [m] 7 | % - Displacement: d = 5/10^4 [m] 8 | % - N = r / d 9 | 10 | % Variables in meters 11 | cyst_radius = 5 / 1000; 12 | d = 5 / 10000; 13 | 14 | for m = d:d:(cyst_radius-d) 15 | 16 | r = sqrt((cyst_radius^2) - (m^2)) 17 | 18 | % Call LinearArrayImaging 19 | [x, depth, env_gray] = LinearArrayImaging(r); 20 | 21 | % Create the Ultrsound images, when we obtain the matlab figure 22 | % remember to save them as TIFF files (.tif), after this you can run 23 | % DICOMnaming.m or an edited version of it to conver the TIFF files 24 | % into DICOM (.dcm) 25 | image(x*1000, depth*1000, env_gray) 26 | xlabel('Lateral distance [mm]') 27 | ylabel('Depth [mm]') 28 | axis('image') 29 | colormap(gray(128)) 30 | title('Image of cyst phantom (60 dB dynamic range)') 31 | 32 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MatLab-FieldII 2 | MatLab program based on the package for ultrasound simulation Field II (http://field-ii.dk/). The main objective is to create multiple ultrasound images which correspond to the displacement of the ultrasound probe while scanning an spherical cyst. 3 | *** 4 | ## Get Started 5 | 1. Once you have download the program, make sure to run the file 'field_init.m'. 6 | 2. Check the 'MultipleFrames.m' file and make the necessary changes to the variables you would like to edit. After this, run the file. 7 | 3. MatLab would display each of the ultrasound frames as a figure. Save these figures as a TIFF (.tif) file. 8 | 4. When you have obtain the desired files, make the necessary changes in the 'DICOMnaming.m' file and run it to obtain the saved TIFF files into DICOM (.dcm) files. 9 | -------------------------------------------------------------------------------- /calc_h.m: -------------------------------------------------------------------------------- 1 | % Procedure for calculating the spatial impulse response 2 | % for an aperture. 3 | % 4 | % Calling: [h, start_time] = calc_h(Th,points); 5 | % 6 | % Parameters: Th - Pointer to the transducer aperture. 7 | % points - Field points. Vector with three columns (x,y,z) 8 | % and one row for each field point. 9 | % 10 | % Return: h - Spatial impulse response in m/s. 11 | % start_time - The time for the first sample in h. 12 | % 13 | % Version 1.01, October 4, 1996 by Joergen Arendt Jensen 14 | 15 | function [h, start_time] = calc_h (Th,points) 16 | 17 | % Check the point array 18 | 19 | [m,n]=size(points); 20 | if (n ~= 3) 21 | error ('Points array must have three columns'); 22 | end 23 | 24 | % Call the C-part of the program to show aperture 25 | 26 | [h, start_time] = Mat_field (4001,Th,points); 27 | 28 | 29 | -------------------------------------------------------------------------------- /calc_hhp.m: -------------------------------------------------------------------------------- 1 | % Procedure for calculating the pulse echo field. 2 | % 3 | % Calling: [hhp, start_time] = calc_hhp(Th1, Th2, points); 4 | % 5 | % Parameters: Th1 - Pointer to the transmit aperture. 6 | % Th2 - Pointer to the receive aperture. 7 | % points - Field points. Vector with three columns (x,y,z) 8 | % and one row for each field point. 9 | % 10 | % Return: hhp - Received voltage trace. 11 | % start_time - The time for the first sample in hhp. 12 | % 13 | % Version 1.0, November 22, 1995 by Joergen Arendt Jensen 14 | 15 | function [hhp, start_time] = calc_hhp (Th1, Th2, points) 16 | 17 | % Check the point array 18 | 19 | [m,n]=size(points); 20 | if (n ~= 3) 21 | error ('Points array must have three columns'); 22 | end 23 | 24 | % Call the C-part of the program to show aperture 25 | 26 | [hhp, start_time] = Mat_field (4003,Th1,Th2,points); 27 | 28 | 29 | -------------------------------------------------------------------------------- /calc_hp.m: -------------------------------------------------------------------------------- 1 | % Procedure for calculating the emitted field. 2 | % 3 | % Calling: [hp, start_time] = calc_hp(Th, points); 4 | % 5 | % Parameters: Th - Pointer to the transmit aperture. 6 | % points - Field points. Matrix with three columns (x,y,z) 7 | % and one row for each field point. 8 | % 9 | % Return: hp - Emitted pressure field 10 | % start_time - The time for the first sample in field. 11 | % 12 | % Version 1.01, May 27, 2002 by Joergen Arendt Jensen 13 | 14 | function [hp, start_time] = calc_hp (Th, points) 15 | 16 | % Check the point array 17 | 18 | [m,n]=size(points); 19 | if (n ~= 3) 20 | error ('Points array must have three columns'); 21 | end 22 | 23 | % Call the C-part of the program to show aperture 24 | 25 | [hp, start_time] = Mat_field (4002,Th,points); 26 | 27 | 28 | -------------------------------------------------------------------------------- /calc_scat.m: -------------------------------------------------------------------------------- 1 | % Procedure for calculating the received signal from a collection of scatterers. 2 | % 3 | % Calling: [scat, start_time] = calc_scat(Th1, Th2, points, amplitudes); 4 | % 5 | % Parameters: Th1 - Pointer to the transmit aperture. 6 | % Th2 - Pointer to the receive aperture. 7 | % points - Scatterers. Vector with three columns (x,y,z) 8 | % and one row for each scatterer. 9 | % amplitudes - Scattering amplitudes. Row vector with one 10 | % entry for each scatterer. 11 | % 12 | % Return: scat - Received voltage trace. 13 | % start_time - The time for the first sample in scat. 14 | % 15 | % Version 1.0, November 28, 1995 by Joergen Arendt Jensen 16 | 17 | function [scat, start_time] = calc_scat (Th1, Th2, points, amplitudes) 18 | 19 | % Check the point array 20 | 21 | [m1,n]=size(points); 22 | if (n ~= 3) 23 | error ('Points array must have three columns'); 24 | end 25 | [m2,n]=size(amplitudes); 26 | if (m1 ~= m2) 27 | error ('There must be the same number of rows for points and amplitudes arrays'); 28 | end 29 | 30 | % Call the C-part of the program to show aperture 31 | 32 | [scat, start_time] = Mat_field (4005,Th1,Th2,points, amplitudes); 33 | 34 | 35 | -------------------------------------------------------------------------------- /calc_scat_all.m: -------------------------------------------------------------------------------- 1 | % Procedure for calculating the received signal from a collection 2 | % of scatterers, when transmitting with each individual element 3 | % and receiving with each of the elements in the receiving aperture. 4 | % 5 | % Calling: [scat, start_time] = calc_scat_all (Th1, Th2, points, amplitudes, dec_factor); 6 | % 7 | % Parameters: Th1 - Pointer to the transmitting aperture. 8 | % Th2 - Pointer to the receiving aperture. 9 | % points - Scatterers. Vector with three columns (x,y,z) 10 | % and one row for each scatterer. 11 | % amplitudes - Scattering amplitudes. Row vector with one 12 | % entry for each scatterer. 13 | % dec_factor - Decimation factor for the output sampling rate. 14 | % The sampling frequency is then fs/dec_factor, 15 | % where fs is the sampling frequency set in the program. 16 | % The factor must be an integer. 17 | % 18 | % Return: scat - Received voltage traces. One signal for 19 | % each physical element in the receiving 20 | % aperture for each element in the 21 | % transmitting aperture. The matrix is organized with 22 | % one received signal for each receiving element and this 23 | % is repeated for all transmitting element, so the first 24 | % signal is transmitting with element one and receiving with 25 | % element one. The transmitting with element one receiving with 26 | % element two and so forth. The it is repeated with transmitting 27 | % element 2, etc. 28 | % start_time - The time for the first sample in scat. 29 | % 30 | % Version 1.2, August 17, 2001 by Joergen Arendt Jensen 31 | 32 | function [scat, start_time] = calc_scat_all (Th1, Th2, points, amplitudes, dec_factor) 33 | 34 | % Check the point array 35 | 36 | [m1,n]=size(points); 37 | if (n ~= 3) 38 | error ('Points array must have three columns'); 39 | end 40 | [m2,n]=size(amplitudes); 41 | if (m1 ~= m2) 42 | error ('There must be the same number of rows for points and amplitudes arrays'); 43 | end 44 | dec_factor=round(dec_factor); 45 | if (dec_factor<1) 46 | error ('Illegal decimation factor. Must be one or larger.'); 47 | end 48 | 49 | % Call the C-part of the program to make the calculation 50 | 51 | [scat, start_time] = Mat_field (4007, Th1, Th2, points, amplitudes, dec_factor); 52 | 53 | 54 | -------------------------------------------------------------------------------- /calc_scat_multi.m: -------------------------------------------------------------------------------- 1 | % Procedure for calculating the received signal from a collection of scatterers 2 | % and for each of the elements in the receiving aperture. 3 | % 4 | % Calling: [scat, start_time] = calc_scat_multi (Th1, Th2, points, amplitudes); 5 | % 6 | % Parameters: Th1 - Pointer to the transmit aperture. 7 | % Th2 - Pointer to the receive aperture. 8 | % points - Scatterers. Vector with three columns (x,y,z) 9 | % and one row for each scatterer. 10 | % amplitudes - Scattering amplitudes. Row vector with one 11 | % entry for each scatterer. 12 | % 13 | % Return: scat - Received voltage traces. One signal for 14 | % each physical element in the receiving 15 | % aperture. 16 | % start_time - The time for the first sample in scat. 17 | % 18 | % Version 1.0, May 21, 1999 by Joergen Arendt Jensen 19 | 20 | function [scat, start_time] = calc_scat_multi (Th1, Th2, points, amplitudes) 21 | 22 | % Check the point array 23 | 24 | [m1,n]=size(points); 25 | if (n ~= 3) 26 | error ('Points array must have three columns'); 27 | end 28 | [m2,n]=size(amplitudes); 29 | if (m1 ~= m2) 30 | error ('There must be the same number of rows for points and amplitudes arrays'); 31 | end 32 | 33 | % Call the C-part of the program to show aperture 34 | 35 | [scat, start_time] = Mat_field (4006,Th1,Th2,points, amplitudes); 36 | 37 | 38 | -------------------------------------------------------------------------------- /cyst_phantom.m: -------------------------------------------------------------------------------- 1 | % Create a computer model of a cyst phantom. The phantom contains 2 | % five point targets separated by 5 mm and a 10 mm water filled cyst. 3 | % All scatterers are situated in a box of (x,y,z)=(40,10,50) mm. 4 | 5 | % Calling: [positions, amp] = cyst_phantom (N); % 6 | % Parameters: N- Number of scatterers in the phantom 7 | 8 | % Output: positions - Positions of the scatterers 9 | % amp - Amplitude of the scatterers 10 | 11 | % Version 1.1, March 22, 2011 by Joergen Arendt Jensen 12 | 13 | function [positions, amp] = cyst_phantom (N, radius) 14 | x_size = 40/1000; % Width of phantom [m] 15 | y_size = 10/1000; % Transverse width of phantom [m] 16 | z_size = 50/1000; % Height of phantom [m] 17 | z_start = 30/1000; % Start of phantom surface [m]; 18 | 19 | % Create the general scatterers 20 | x = (rand (N,1)-0.5)*x_size; 21 | y = (rand (N,1)-0.5)*y_size; 22 | z = rand (N,1)*z_size + z_start; 23 | 24 | % Generate the amplitudes with a Gaussian distribution 25 | amp = randn(N,1); 26 | 27 | % Make the cyst and set the amplitudes to zero inside 28 | r = radius; % Radius of cyst [m] 29 | xc = 0/1000; % Place of cyst [m] 30 | zc = 25/1000+z_start; 31 | 32 | inside = ( ((x-xc).^2 + (z-zc).^2) < r^2); 33 | amp = amp .* (1-inside); 34 | 35 | % Place the point scatterers in the phantom 36 | dz = z_size/10; 37 | 38 | for i = N-9:N 39 | x(i) = -15/1000; 40 | y(i) = 0; 41 | z(i) = z_start + (i-N+9)*dz; 42 | amp(i) = 100; 43 | end 44 | 45 | % Return the variables 46 | positions=[x y z]; 47 | end -------------------------------------------------------------------------------- /ele_apodization.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the apodization of individual 2 | % mathematical elements making up the transducer 3 | % 4 | % Calling: ele_apodization (Th, element_no, apo); 5 | % 6 | % Parameters: Th - Pointer to the transducer aperture. 7 | % element_no - Column vector with one integer for each physical 8 | % element to set apodization for. 9 | % apo - Apodization values. Matrix with one row for each 10 | % physical element and a number of columns equal to the 11 | % number of mathematical elements in the aperture. 12 | % 13 | % Return: none. 14 | % 15 | % Version 1.0, June 29, 1998 by Joergen Arendt Jensen 16 | 17 | function res = ele_apodization (Th, element_no, apo) 18 | 19 | % Check the element number vector 20 | 21 | [m1,n]=size(element_no); 22 | if (n ~= 1) 23 | error ('Element_no vector must have one column'); 24 | end 25 | 26 | [m2,n]=size(apo); 27 | 28 | % Check both arrays 29 | 30 | if (m1 ~= m2) 31 | error ('There must be the same number of rows for element_no vector and apo matrix'); 32 | end 33 | 34 | % Call the C-part of the program to insert apodization 35 | 36 | Mat_field (1080, Th, element_no, apo); 37 | 38 | 39 | -------------------------------------------------------------------------------- /ele_delay.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the delay of individual 2 | % mathematical elements making up the transducer 3 | % 4 | % Calling: ele_delay (Th, element_no, delays); 5 | % 6 | % Parameters: Th - Pointer to the transducer aperture. 7 | % element_no - Column vector with one integer for each physical 8 | % element to set delay for. 9 | % delays - Delay values. Matrix with one row for each 10 | % physical element and a number of columns equal to the 11 | % number of mathematical elements in the aperture. 12 | % 13 | % Return: none. 14 | % 15 | % Version 1.0, June 29, 1998 by Joergen Arendt Jensen 16 | 17 | function res = ele_delay (Th, element_no, delays) 18 | 19 | % Check the element number vector 20 | 21 | [m1,n]=size(element_no); 22 | if (n ~= 1) 23 | error ('Element_no vector must have one column'); 24 | end 25 | 26 | [m2,n]=size(delays); 27 | 28 | % Check both arrays 29 | 30 | if (m1 ~= m2) 31 | error ('There must be the same number of rows for element_no vector and delays matrix'); 32 | end 33 | 34 | % Call the C-part of the program to insert apodization 35 | 36 | Mat_field (1081, Th, element_no, delays); 37 | 38 | 39 | -------------------------------------------------------------------------------- /ele_waveform.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the waveform of individual 2 | % physical elements of the transducer 3 | % 4 | % Calling: ele_waveform (Th, element_no, samples); 5 | % 6 | % Parameters: Th - Pointer to the transducer aperture. 7 | % element_no - Column vector with one integer for each physical 8 | % element to set waveform for. 9 | % samples - Sample values for waveform. Matrix with one row for each 10 | % physical element and a number of columns equal to the 11 | % number of samples in the waveforms. 12 | % 13 | % Return: none. 14 | % 15 | % Version 1.0, July 1, 1998 by Joergen Arendt Jensen 16 | 17 | function res = ele_waveform (Th, element_no, samples) 18 | 19 | % Check the element number vector 20 | 21 | [m1,n]=size(element_no); 22 | if (n ~= 1) 23 | error ('Element_no vector must have one column'); 24 | end 25 | 26 | [m2,n]=size(samples); 27 | 28 | % Check both arrays 29 | 30 | if (m1 ~= m2) 31 | error ('There must be the same number of rows for element_no vector and samples matrix'); 32 | end 33 | 34 | % Call the C-part of the program to insert apodization 35 | 36 | Mat_field (1082, Th, element_no, samples); 37 | 38 | 39 | -------------------------------------------------------------------------------- /field_debug.m: -------------------------------------------------------------------------------- 1 | % Procedure for initialize the Field II debugging. This will print 2 | % out various information about the programs inner working. 3 | % 4 | % Calling: field_debug(state) 5 | % 6 | % Parameters: State - 1: debugging, 0: no debugging. 7 | % 8 | % Return: nothing. 9 | % 10 | % Version 1.0, November 20, 1995 by Joergen Arendt Jensen 11 | 12 | function res = field_debug (state) 13 | 14 | % Call the C-part of the program to debug it 15 | 16 | Mat_field (5010,state); 17 | 18 | 19 | -------------------------------------------------------------------------------- /field_end.m: -------------------------------------------------------------------------------- 1 | % Procedure for ending the Field II program system and releasing the storage. 2 | % 3 | % Calling: field_end ; 4 | % 5 | % Return: nothing. 6 | % 7 | % Version 1.0, November 28, 1995 by Joergen Arendt Jensen 8 | 9 | function res = field_end () 10 | 11 | % Call the C-part of the program to initialize it 12 | 13 | Mat_field (5002); 14 | 15 | 16 | -------------------------------------------------------------------------------- /field_guide.m: -------------------------------------------------------------------------------- 1 | % Procedure for displaying the Field II users' guide 2 | % using the acrobat reader 3 | % 4 | % Calling: field_guide 5 | % 6 | % Parameters: None 7 | % 8 | % Return: The Field II guide is displayed in a separate 9 | % window using acrobat reader. This demands that 10 | % acrobat reader is installed and that the 11 | % users guide is available under Matlab as users_guide.pdf 12 | % 13 | % Version 1.01, May 6, 2011 by Joergen Arendt Jensen 14 | 15 | % Call acrobat reader 16 | 17 | guide=which('users_guide.pdf'); 18 | if isempty(guide) 19 | disp('The Field II users guide is not accessible under Matlab') 20 | disp('It should be placed in the same directory as the m-files for Field II') 21 | disp('and it should be called users_guide.pdf. The guide can be obtained') 22 | disp('from http://server.elektro.dtu.dk/personal/jaj/field/?users_guide.html') 23 | else 24 | cmd=['!acroread ',guide,' &']; 25 | eval(cmd) 26 | end 27 | 28 | 29 | -------------------------------------------------------------------------------- /field_info.m: -------------------------------------------------------------------------------- 1 | % Procedure for showing information about the Field II program. 2 | % The information is printed in the Matlab window. 3 | % 4 | % Calling: field_info 5 | % 6 | % Parameters: None. 7 | % 8 | % Return: Information is printed in the Matlab window. 9 | % 10 | % Version 1.0, December 17, 2001 by Joergen Arendt Jensen 11 | 12 | % Call the C-part of the program to print the information 13 | 14 | Mat_field (5051); 15 | 16 | 17 | -------------------------------------------------------------------------------- /field_init.m: -------------------------------------------------------------------------------- 1 | % Procedure for initializing the Field II program system. Must be 2 | % the first routine that is called before using the system. 3 | % 4 | % Calling: field_init (suppress); 5 | % 6 | % Return: nothing. 7 | % 8 | % Input: suppress: An optional argument suppress with a value 9 | % of zero can be given to suppress the 10 | % display of the initial field screen. 11 | % No ACII ouput will be given, if the argument 12 | % is -1. Debug messages will be written if 13 | % enable by field_debug, and all error messages 14 | % will also be printed. 15 | % 16 | % Version 1.2, January 20, 1999 by Joergen Arendt Jensen 17 | 18 | function res = field_init (suppress) 19 | 20 | % Call the C-part of the program to initialize it 21 | 22 | if (nargin==1) 23 | Mat_field (5001,suppress); 24 | else 25 | Mat_field (5001,1); 26 | end 27 | 28 | 29 | -------------------------------------------------------------------------------- /field_logo.m: -------------------------------------------------------------------------------- 1 | % Function to display the logo for field 2 | % 3 | % Version 1.3, August 10, 2007 by Joergen Arendt Jensen 4 | % Error in loading filr fixed 5 | 6 | function res = field_logo 7 | 8 | % Create a window and display the Field II logo 9 | 10 | h=figure; 11 | axes('position',[0 0 1 1]); 12 | place=which ('logo_field.mat'); 13 | eval(['load ',place]) 14 | image(data1); 15 | axis off 16 | colormap(map); 17 | drawnow; 18 | pause(5) 19 | close(h); 20 | 21 | 22 | -------------------------------------------------------------------------------- /logo_field.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreeHand-UltraSound/MatLab-FieldII/7ab7555f6fbe1296fb5187268de21e3682de32cf/logo_field.mat -------------------------------------------------------------------------------- /set_field.m: -------------------------------------------------------------------------------- 1 | % Set options for the program. 2 | % 3 | % Calling: set_field (option_name, value); 4 | % 5 | % Possible options Value 6 | % 7 | % use_att Whether to use attenuation (<> 0 for attenuation) 8 | % att Frequency independent attenuation in dB/m. 9 | % freq_att Frequency dependent attenuation in dB/[m Hz] 10 | % around the center frequency att_f0. 11 | % att_f0 Attenuation center frequency in Hz. 12 | % tau_m The variable tau_m in the attenuation calculation. 13 | % 14 | % debug Whether to print debug information (1 = yes) 15 | % show_times Whether to print information about the time 16 | % taken for the calculation (yes = any positive numer). 17 | % A number large than 2 is taken as the time in seconds 18 | % between the printing of estimates. 19 | % use_rectangles Whether to use rectangles (1) for the apertures 20 | % use_triangles Whether to use triangles (1) for the apertures or rectangles (0) 21 | % use_lines Whether to use lines (1) for the apertures or rectangles (0) 22 | % 23 | % accurate_time_calc Whether to use accurate time calculation for rectangular elements (1) 24 | % or an approximative calculation 25 | % fast_integration Whether to use fast integration (1) of the responses for bound lines 26 | % and triangles 27 | % 28 | % c Set the speed of sound in m/s. 29 | % fs Set the sampling frequency. 30 | % 31 | % Variables used for non-linear imaging: 32 | % 33 | % z Characteristic acoustic impedance of the medium in kg/[m^2 s] 34 | % dz Step for propagating the pulse in m 35 | % BdivA The B/A parameter 36 | % 37 | % Return: nothing. 38 | % 39 | % Example: Set the attenuation to 1.5 dB/cm, 0.5 dB/[MHz cm] around 40 | % 3 MHz and use this: 41 | % 42 | % set_field ('att',1.5*100); 43 | % set_field ('Freq_att',0.5*100/1e6); 44 | % set_field ('att_f0',3e6); 45 | % set_field ('use_att',1); 46 | % 47 | % Note that the frequency independent and frequency dependent attenuation 48 | % should normally agree, so that Freq_att*att_f0 = att. 49 | % 50 | % Version 1.8, August 1, 2002 by Joergen Arendt Jensen 51 | 52 | function res = set_field (option_name, value) 53 | 54 | % Check the option name 55 | 56 | if (~isstr(option_name)) 57 | error ('First argument must be an option name'); 58 | end 59 | 60 | % Call the C-part of the program to set the option 61 | 62 | Mat_field (5050, option_name, value); 63 | 64 | 65 | -------------------------------------------------------------------------------- /set_sampling.m: -------------------------------------------------------------------------------- 1 | % Set the sampling frequency the system uses. 2 | % 3 | % Remember that the pulses used in all apertures must 4 | % be reset for the new sampling frequency to take effect. 5 | % 6 | % Calling: set_sampling (fs); 7 | % 8 | % Parameters: fs - The new sampling frequency. 9 | % 10 | % Return: nothing. 11 | % 12 | % Version 1.0, December 7, 1995 by Joergen Arendt Jensen 13 | 14 | function res = set_sampling(fs) 15 | 16 | % Call the C-part of the program to initialize it 17 | 18 | Mat_field (5020,fs); 19 | 20 | 21 | -------------------------------------------------------------------------------- /users_guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreeHand-UltraSound/MatLab-FieldII/7ab7555f6fbe1296fb5187268de21e3682de32cf/users_guide.pdf -------------------------------------------------------------------------------- /xdc_2d_array.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a 2d (sparse) array transducer 2 | % 3 | % Calling: Th = xdc_2d_array (no_ele_x, no_ele_y, width, height, kerf_x, kerf_y, 4 | % enabled, no_sub_x, no_sub_y, focus); 5 | % 6 | % Parameters: no_ele_x - Number of physical elements in x-direction. 7 | % no_ele_y - Number of physical elements in y-direction. 8 | % width - Width in x-direction of elements. 9 | % height - Width in y-direction of elements. 10 | % kerf_x - Width in x-direction between elements. 11 | % kerf_y - Width in y-direction between elements. 12 | % enabled - Matrix of size (no_ele_x, no_ele_y) indicating 13 | % whether the physical element is used. A 1 indicates 14 | % an enabled element and zero that it is not. 15 | % enable(1,1) determines the state of the 16 | % lower left element of the transducer. 17 | % no_sub_x - Number of sub-divisions in x-direction of elements. 18 | % no_sub_y - Number of sub-divisions in y-direction of elements. 19 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 20 | % 21 | % Return: A handle Th as a pointer to this transducer aperture. 22 | % 23 | % Version 1.0, December 5, 1995 by Joergen Arendt Jensen 24 | 25 | function Th = xdc_2d_array (no_ele_x, no_ele_y, width, height, kerf_x, kerf_y, enabled, no_sub_x, no_sub_y, focus) 26 | 27 | % Check that all parameters are valid 28 | 29 | if (no_ele_x<1) | (no_ele_y<1) 30 | error ('Field error: Illegal number of physical transducer elements') 31 | end 32 | 33 | if (width<=0) | (height<=0) 34 | error ('Field error: Width or height is negativ or zero') 35 | end 36 | 37 | if (kerf_x<0) | (kerf_y<0) 38 | error ('Field error: Kerf is negativ') 39 | end 40 | 41 | [n,m]=size(enabled); 42 | if (n ~= no_ele_x) | (m ~= no_ele_y) 43 | error ('Field error: The enabled array does not have the correct dimension') 44 | end 45 | 46 | if (no_sub_x<1) | (no_sub_y<1) 47 | error ('Field error: Number of mathematical elements must 1 or more') 48 | end 49 | 50 | if (min(size(focus))~=1) | (max(size(focus))~=3) 51 | error ('Field error: Focus must be a vector with three elements') 52 | end 53 | 54 | % Call the C-part of the program to create aperture 55 | 56 | Th = Mat_field (1002,no_ele_x, no_ele_y, width, height, kerf_x, kerf_y, enabled, no_sub_x, no_sub_y, focus); 57 | 58 | 59 | -------------------------------------------------------------------------------- /xdc_apodization.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating an apodization time line for an aperture 2 | % 3 | % Calling: xdc_apodization (Th, times, values); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % times - Time after which the associated apodization is valid. 7 | % values - Apodization values. Matrix with one row for each 8 | % time value and a number of columns equal to the 9 | % number of physical elements in the aperture. At 10 | % least one apodization value in each row must be different 11 | % from zero. 12 | % 13 | % Return: none. 14 | % 15 | % Version 1.01, June 19, 1998 by Joergen Arendt Jensen 16 | % Version 1.1, May 6, 2011 by JAJ - Check of zero apodization added 17 | 18 | 19 | function res = xdc_apodization (Th,times,values) 20 | 21 | % Check the times vector 22 | 23 | [m1,n]=size(times); 24 | if (n ~= 1) 25 | error ('Times vector must have one column'); 26 | end 27 | 28 | [m2,n]=size(values); 29 | 30 | % Check both arrays 31 | 32 | if (m1 ~= m2) 33 | error ('There must be the same number of rows for times and values'); 34 | end 35 | 36 | % Check that there is not one column with only zeros 37 | 38 | for i=1:m1 39 | if (sum(abs(values(i,:)))==0) 40 | error('There must be at least one apodization value different from zero in a column') 41 | end 42 | end 43 | 44 | % Call the C-part of the program to insert apodization 45 | 46 | Mat_field (1070,Th,times,values); 47 | 48 | 49 | -------------------------------------------------------------------------------- /xdc_baffle.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the baffle condition for the aperture. 2 | % 3 | % Calling: xdc_baffle (Th, soft_baffle); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % soft_baffle - Whether to use the soft-baffle condition: 7 | % 1 - using soft baffle 8 | % 0 - using rigid baffle (default for apertures) 9 | % 10 | % Return: None. 11 | % 12 | % Version 1.0, July 10, 1998 by Joergen Arendt Jensen 13 | 14 | function res = xdc_baffle (Th, soft_baffle) 15 | 16 | % Call the C-part of the program to set baffle condition 17 | 18 | Mat_field (1066, Th, soft_baffle); 19 | 20 | -------------------------------------------------------------------------------- /xdc_center_focus.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the center point for the focusing. 2 | % This point is used as a reference for calculating the 3 | % focusing delay times and as a starting point for dynamic 4 | % focusing. 5 | % 6 | % Calling: xdc_center_focus (Th, point); 7 | % 8 | % Parameters: Th - Pointer to the transducer aperture. 9 | % point - Focus center point. 10 | % 11 | % Return: none. 12 | % 13 | % Version 1.0, May 20, 1997 by Joergen Arendt Jensen 14 | 15 | function res = xdc_center_focus (Th,point) 16 | 17 | % Check the point array 18 | 19 | [m2,n]=size(point); 20 | if (n ~= 3) 21 | error ('Point array must have three columns'); 22 | end 23 | 24 | % Check both arrays 25 | 26 | if (m2 ~= 1) 27 | error ('There must only be one row for the center point'); 28 | end 29 | 30 | % Call the C-part of the program to insert focus 31 | 32 | Mat_field (1063,Th,point); 33 | 34 | 35 | -------------------------------------------------------------------------------- /xdc_concave.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a concave transducer 2 | % 3 | % Calling: Th = xdc_concave (radius, focal_radius, ele_size); 4 | % 5 | % Parameters: radius - Radius of aperture. 6 | % focal_radius - Focal radius of aperture. 7 | % ele_size - Size of elements for modeling transducer. 8 | % 9 | % All dimensions are in meters. 10 | % 11 | % Return: A handle Th as a pointer to this transducer aperture. 12 | % 13 | % Version 1.0, August 21, 1996 by Joergen Arendt Jensen 14 | 15 | function Th = xdc_concave (radius, focal_radius, ele_size) 16 | 17 | % Check that all parameters are valid 18 | 19 | if (radius<0) 20 | error ('Field error: Negative radius of physical transducer elements') 21 | end 22 | 23 | if (focal_radius<=0) 24 | error ('Field error: Negativ focal radius') 25 | end 26 | 27 | if (ele_size<=0) | (ele_size>radius) 28 | error ('Field error: Illegal size of mathematical element') 29 | end 30 | 31 | % Call the C-part of the program to create aperture 32 | 33 | Th = Mat_field (1011, radius, focal_radius, ele_size); 34 | 35 | 36 | -------------------------------------------------------------------------------- /xdc_convert.m: -------------------------------------------------------------------------------- 1 | % Procedure for converting an aperture from consisting of rectangles 2 | % to consist of triangles 3 | % 4 | % Calling: xdc_convert (Th); 5 | % 6 | % Parameters: A handle Th as a pointer to this transducer aperture. The 7 | % pointer value will be the same as for the rectangular aperture. 8 | % The rectangles defined in the aperture will be released. 9 | % 10 | % Version 1.0, October 15, 1996 by Joergen Arendt Jensen 11 | 12 | function res = xdc_convert (Th) 13 | 14 | % Call the C-part of the program to convert aperture 15 | 16 | Mat_field (1030, Th); 17 | 18 | 19 | -------------------------------------------------------------------------------- /xdc_convex_array.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a convex array transducer 2 | % 3 | % Calling: Th = xdc_convex_array (no_elements, width, height, kerf, Rconvex, 4 | % no_sub_x, no_sub_y, focus); 5 | % 6 | % Parameters: no_elements - Number of physical elements. 7 | % width - Width in x-direction of elements. 8 | % height - Width in y-direction of elements. 9 | % kerf - Width in x-direction between elements. 10 | % Rconvex - Convex radius. 11 | % no_sub_x - Number of sub-divisions in x-direction of elements. 12 | % no_sub_y - Number of sub-divisions in y-direction of elements. 13 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 14 | % 15 | % Return: A handle Th as a pointer to this transducer aperture. 16 | % 17 | % Version 1.1, March 3, 1998 by Joergen Arendt Jensen 18 | 19 | function Th = xdc_convex_array (no_elements, width, height, kerf, Rconvex, no_sub_x, no_sub_y, focus) 20 | 21 | % Check that all parameters are valid 22 | 23 | if (no_elements<1) 24 | error ('Field error: Illegal number of physical transducer elements') 25 | end 26 | 27 | if (width<=0) | (height<=0) 28 | error ('Field error: Width or height is negativ or zero') 29 | end 30 | 31 | if (kerf<0) 32 | error ('Field error: Kerf is negativ') 33 | end 34 | 35 | if (Rconvex<0) 36 | error ('Field error: Convex radius is negative') 37 | end 38 | 39 | if (no_sub_x<1) | (no_sub_y<1) 40 | error ('Field error: Number of mathematical elements must 1 or more') 41 | end 42 | 43 | if (min(size(focus))~=1) | (max(size(focus))~=3) 44 | error ('Field error: Focus must be a vector with three elements') 45 | end 46 | 47 | % Call the C-part of the program to create aperture 48 | 49 | Th = Mat_field (1004,no_elements, width, height, kerf, Rconvex, no_sub_x, no_sub_y, focus); 50 | 51 | 52 | -------------------------------------------------------------------------------- /xdc_convex_focused_array.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a convex array transducer 2 | % 3 | % Calling: Th = xdc_convex_focused_array (no_elements, width, height, kerf, Rconvex, Rfocus 4 | % no_sub_x, no_sub_y, focus); 5 | % 6 | % Parameters: no_elements - Number of physical elements. 7 | % width - Width in x-direction of elements. 8 | % height - Width in y-direction of elements. 9 | % kerf - Width in x-direction between elements. 10 | % Rconvex - Convex radius. 11 | % Rfocus - Radius of elevation focus. 12 | % no_sub_x - Number of sub-divisions in x-direction of elements. 13 | % no_sub_y - Number of sub-divisions in y-direction of elements. 14 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 15 | % 16 | % Return: A handle Th as a pointer to this transducer aperture. 17 | % 18 | % Version 1.01, June 26, 1998 by Joergen Arendt Jensen 19 | 20 | function Th = xdc_convex_focused_array (no_elements, width, height, kerf, Rconvex, Rfocus, no_sub_x, no_sub_y, focus) 21 | 22 | % Check that all parameters are valid 23 | 24 | if (no_elements<1) 25 | error ('Field error: Illegal number of physical transducer elements') 26 | end 27 | 28 | if (width<=0) | (height<=0) 29 | error ('Field error: Width or height is negativ or zero') 30 | end 31 | 32 | if (kerf<0) 33 | error ('Field error: Kerf is negativ') 34 | end 35 | 36 | if (height > 2*Rfocus) 37 | error ('Field error: Illegal element height for the chosen elevation focus') 38 | end 39 | 40 | if ( (width*no_elements+kerf*(no_elements-1)) > (pi*Rconvex)) 41 | error ('Field error: Illegal element width and kerf for the chosen convex radius') 42 | end 43 | 44 | if (Rconvex<0) 45 | error ('Field error: Convex radius is negative') 46 | end 47 | 48 | if (pi*Rconvex<=(kerf*(no_elements-1)+width*no_elements)) 49 | error ('Field error: Width of elements is to large compared to Rconvex') 50 | end 51 | 52 | if (Rfocus<0) 53 | error ('Field error: Elevation focus radius is negative') 54 | end 55 | 56 | if (no_sub_x<1) 57 | error ('Field error: Number of mathematical elements must 1 or more in x-direction') 58 | end 59 | 60 | if (no_sub_y<2) 61 | error ('Field error: Number of mathematical elements in y-direction must 2 or more to model elevation focusing') 62 | end 63 | 64 | if (min(size(focus))~=1) | (max(size(focus))~=3) 65 | error ('Field error: Focus must be a vector with three elements') 66 | end 67 | 68 | % Call the C-part of the program to create aperture 69 | 70 | Th = Mat_field (1005,no_elements, width, height, kerf, Rconvex, Rfocus, no_sub_x, no_sub_y, focus); 71 | 72 | -------------------------------------------------------------------------------- /xdc_convex_focused_multirow.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a convex, elevation focused array transducer 2 | % with an number of rows (1.5D array) 3 | % 4 | % Calling: Th = xdc_convex_focused_multirow (no_elem_x, width, no_ele_y, heights, kerf_x, kerf_y, 5 | % Rconvex, Rfocus, no_sub_x, no_sub_y, focus); 6 | % 7 | % Parameters: no_elem_x - Number of physical elements in x-direction. 8 | % width - Width in x-direction of elements. 9 | % no_elem_y - Number of physical elements in y-direction. 10 | % heights[] - Heights of the element rows in the y-direction. 11 | % Vector with no_elem_y values. 12 | % kerf_x - Width in x-direction between elements. 13 | % kerf_y - Gap in y-direction between elements. 14 | % Rconvex - Convex radius. 15 | % Rfocus - Radius of mechanical elevation focus. 16 | % no_sub_x - Number of sub-divisions in x-direction of physical elements. 17 | % no_sub_y - Number of sub-divisions in y-direction of physical elements. 18 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 19 | % 20 | % Return: A handle Th as a pointer to this transducer aperture. 21 | % 22 | % Version 1.0, June 26, 1998 by Joergen Arendt Jensen 23 | 24 | function Th = xdc_focused_multirow (no_elem_x, width, no_elem_y, heights, kerf_x, kerf_y, Rconvex, Rfocus, no_sub_x, no_sub_y, focus) 25 | 26 | % Check that all parameters are valid 27 | 28 | if (no_elem_x<1) 29 | error ('Field error: Illegal number of physical transducer elements in x-direction') 30 | end 31 | 32 | if (width<=0) 33 | error ('Field error: Width of elements is negativ or zero') 34 | end 35 | 36 | if (no_elem_y<1) 37 | error ('Field error: Illegal number of physical transducer elements in y-direction') 38 | end 39 | 40 | if (min(heights)<=0) 41 | error ('Field error: Height of elements is negativ or zero') 42 | end 43 | 44 | if (length(heights)~=no_elem_y) 45 | error ('Field error: Number of heights does not equal no_elem_y') 46 | end 47 | 48 | if ((sum(heights)+(no_elem_y-1)*kerf_y)>2*Rfocus) 49 | error ('Field error: Total height of elements is to large') 50 | end 51 | 52 | if (kerf_x<0) 53 | error ('Field error: Kerf in x-direction is negativ') 54 | end 55 | 56 | if (kerf_y<0) 57 | error ('Field error: Kerf in y-direction is negativ') 58 | end 59 | 60 | if (Rconvex<0) 61 | error ('Field error: Convex radius is negative') 62 | end 63 | 64 | if (pi*Rconvex<=(kerf_x*(no_elem_x-1)+width*no_elem_x)) 65 | error ('Field error: Width of elements is to large compared to Rconvex') 66 | end 67 | 68 | if (Rfocus<=0) 69 | error ('Field error: Radius of elevation focus is negativ or zero') 70 | end 71 | 72 | if (no_sub_x<1) | (no_sub_y<1) 73 | error ('Field error: Number of mathematical elements must be 1 or more') 74 | end 75 | 76 | if (min(size(focus))~=1) | (max(size(focus))~=3) 77 | error ('Field error: Focus must be a vector with three elements') 78 | end 79 | 80 | % Call the C-part of the program to create aperture 81 | 82 | Th = Mat_field (1014,no_elem_x, width, no_elem_y, heights, kerf_x, kerf_y, Rconvex, Rfocus, no_sub_x, no_sub_y, focus); 83 | 84 | 85 | -------------------------------------------------------------------------------- /xdc_dynamic_focus.m: -------------------------------------------------------------------------------- 1 | % Procedure for using dynamic focusing for an aperture 2 | % 3 | % Calling: xdc_dynamic_focus (Th, time, dir_zx,dir_zy); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % time - Time after which the dynamic focus is valid. 7 | % dir_zx - Direction (angle) in radians for the dynamic 8 | % focus. The direction is taken from the center for 9 | % the focus of the transducer in the z-x plane. 10 | % dir_zy - Direction (angle) in radians for the dynamic 11 | % focus. The direction is taken from the center for 12 | % the focus of the transducer in the z-y plane. 13 | % 14 | % Return: none. 15 | % 16 | % Version 1.02, March 19, 1998 by Joergen Arendt Jensen 17 | 18 | function res = xdc_dynamic_focus (Th,time,dir_zx,dir_zy) 19 | 20 | % Check the times vector 21 | 22 | [m1,n]=size(time); 23 | if ((n ~= 1) & (m1 ~= 1)) 24 | error ('Time must be a scalar'); 25 | end 26 | 27 | % Check the direction 28 | 29 | [m1,n]=size(dir_zx); 30 | if ((n ~= 1) & (m1 ~= 1)) 31 | error ('Direction must be a scalar'); 32 | end 33 | 34 | % Check the direction 35 | 36 | [m1,n]=size(dir_zy); 37 | if ((n ~= 1) & (m1 ~= 1)) 38 | error ('Direction must be a scalar'); 39 | end 40 | 41 | % Call the C-part of the program to insert focus 42 | 43 | Mat_field (1062,Th,time,dir_zx,dir_zy); 44 | 45 | 46 | -------------------------------------------------------------------------------- /xdc_excitation.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the excitation pulse of an aperture 2 | % 3 | % Calling: xdc_excitation (Th,pulse); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % pulse - Excitation pulse of aperture as row vector 7 | % 8 | % Return: None 9 | % 10 | % Version 1.0, November 27, 1995 by Joergen Arendt Jensen 11 | 12 | function res = xdc_excitation (Th, pulse) 13 | 14 | % Test that pulse is of right dimension 15 | 16 | [n,m]=size(pulse); 17 | if (n ~= 1) 18 | error ('Pulse must be a row vector'); 19 | end 20 | 21 | % Call the C-part of the program to show aperture 22 | 23 | Mat_field (1051,Th,pulse); 24 | 25 | 26 | -------------------------------------------------------------------------------- /xdc_focus.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a focus time line for an aperture 2 | % 3 | % Calling: xdc_focus (Th, times, points); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % times - Time after which the associated focus is valid. 7 | % points - Focus points. Vector with three columns (x,y,z) 8 | % and one row for each field point. 9 | % 10 | % Return: none. 11 | % 12 | % Version 1.0, November 28, 1995 by Joergen Arendt Jensen 13 | 14 | function res = xdc_focus (Th,times,points) 15 | 16 | % Check the times vector 17 | 18 | [m1,n]=size(times); 19 | if (n ~= 1) 20 | error ('Times vectors must have one columns'); 21 | end 22 | 23 | % Check the point array 24 | 25 | [m2,n]=size(points); 26 | if (n ~= 3) 27 | error ('Points array must have three columns'); 28 | end 29 | 30 | % Check both arrays 31 | 32 | if (m1 ~= m2) 33 | error ('There must be the same number of rows for times and focal points'); 34 | end 35 | 36 | % Call the C-part of the program to insert focus 37 | 38 | Mat_field (1060,Th,times,points); 39 | 40 | 41 | -------------------------------------------------------------------------------- /xdc_focus_times.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a focus time line for an aperture 2 | % The user here supplies the delay times for each element 3 | % 4 | % Calling: xdc_times_focus (Th, times, delays); 5 | % 6 | % Parameters: Th - Pointer to the transducer aperture. 7 | % times - Time after which the associated apodization is valid. 8 | % delays - Delay values. Matrix with one row for each 9 | % time value and a number of columns equal to the 10 | % number of physical elements in the aperture. 11 | % 12 | % Return: none. 13 | % 14 | % Version 1.1, March 3, 1998 by Joergen Arendt Jensen 15 | 16 | function res = xdc_focus_times (Th,times,delays) 17 | 18 | % Check the times vector 19 | 20 | [m1,n]=size(times); 21 | if (n ~= 1) 22 | error ('Times vectors must have one columns'); 23 | end 24 | 25 | [m2,n]=size(delays); 26 | 27 | % Check both arrays 28 | 29 | if (m1 ~= m2) 30 | error ('There must be the same number of rows for times and delays'); 31 | end 32 | 33 | % Call the C-part of the program to insert focus 34 | 35 | Mat_field (1061,Th,times,delays); 36 | 37 | 38 | -------------------------------------------------------------------------------- /xdc_focused_array.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating an elevation focused linear array transducer 2 | % 3 | % Calling: Th = xdc_focused_array (no_elements, width, height, kerf, Rfocus, 4 | % no_sub_x, no_sub_y, focus); 5 | % 6 | % Parameters: no_elements - Number of physical elements. 7 | % width - Width in x-direction of elements. 8 | % height - Width in y-direction of elements. 9 | % kerf - Width in x-direction between elements. 10 | % Rfocus - Elevation focus. 11 | % no_sub_x - Number of sub-divisions in x-direction of elements. 12 | % no_sub_y - Number of sub-divisions in y-direction of elements. 13 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 14 | % 15 | % Return: A handle Th as a pointer to this transducer aperture. 16 | % 17 | % Version 1.1, March 3, 1998 by Joergen Arendt Jensen 18 | 19 | function Th = xdc_focused_array (no_elements, width, height, kerf, Rfocus, no_sub_x, no_sub_y, focus) 20 | 21 | % Check that all parameters are valid 22 | 23 | if (no_elements<1) 24 | error ('Field error: Illegal number of physical transducer elements') 25 | end 26 | 27 | if (width<=0) | (height<=0) 28 | error ('Field error: Width or height is negativ or zero') 29 | end 30 | 31 | if (kerf<0) 32 | error ('Field error: Kerf is negativ') 33 | end 34 | 35 | if (Rfocus<0) 36 | error ('Field error: Elevation focus is negativ') 37 | end 38 | 39 | if (no_sub_x<1) 40 | error ('Field error: Number of mathematical elements must 1 or more in x-direction') 41 | end 42 | 43 | if (no_sub_y<2) 44 | error ('Field error: Number of mathematical elements in y-direction must 2 or more to model elevation focusing') 45 | end 46 | 47 | if (min(size(focus))~=1) | (max(size(focus))~=3) 48 | error ('Field error: Focus must be a vector with three elements') 49 | end 50 | 51 | % Call the C-part of the program to create aperture 52 | 53 | Th = Mat_field (1003,no_elements, width, height, kerf, Rfocus, no_sub_x, no_sub_y, focus); 54 | 55 | -------------------------------------------------------------------------------- /xdc_focused_multirow.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a linear, elevation focused array transducer 2 | % with an number of rows (1.5D array) 3 | % 4 | % Calling: Th = xdc_focused_multirow (no_elem_x, width, no_ele_y, heights, kerf_x, kerf_y, 5 | % Rfocus, no_sub_x, no_sub_y, focus); 6 | % 7 | % Parameters: no_elem_x - Number of physical elements in x-direction. 8 | % width - Width in x-direction of elements. 9 | % no_elem_y - Number of physical elements in y-direction. 10 | % heights - Heights of the element rows in the y-direction. 11 | % Vector with no_elem_y values. 12 | % kerf_x - Width in x-direction between elements. 13 | % kerf_y - Gap in y-direction between elements. 14 | % Rfocus - Radius of mechanical elevation focus. 15 | % no_sub_x - Number of sub-divisions in x-direction of physical elements. 16 | % no_sub_y - Number of sub-divisions in y-direction of physical elements. 17 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 18 | % 19 | % Return: A handle Th as a pointer to this transducer aperture. 20 | % 21 | % Version 1.0, June 25, 1998 by Joergen Arendt Jensen 22 | 23 | function Th = xdc_focused_multirow (no_elem_x, width, no_elem_y, heights, kerf_x, kerf_y, Rfocus, no_sub_x, no_sub_y, focus) 24 | 25 | % Check that all parameters are valid 26 | 27 | if (no_elem_x<1) 28 | error ('Field error: Illegal number of physical transducer elements in x-direction') 29 | end 30 | 31 | if (width<=0) 32 | error ('Field error: Width of elements is negativ or zero') 33 | end 34 | 35 | if (no_elem_y<1) 36 | error ('Field error: Illegal number of physical transducer elements in y-direction') 37 | end 38 | 39 | for i=1:no_elem_y 40 | if (heights(i)<=0) 41 | error ('Field error: Height of elements is negativ or zero') 42 | end 43 | end 44 | 45 | if (kerf_x<0) 46 | error ('Field error: Kerf in x-direction is negativ') 47 | end 48 | 49 | if (kerf_y<0) 50 | error ('Field error: Kerf in y-direction is negativ') 51 | end 52 | 53 | if (Rfocus<=0) 54 | error ('Field error: Radius of elevation focus is negativ or zero') 55 | end 56 | 57 | if (no_sub_x<1) | (no_sub_y<1) 58 | error ('Field error: Number of mathematical elements must 1 or more') 59 | end 60 | 61 | if (min(size(focus))~=1) | (max(size(focus))~=3) 62 | error ('Field error: Focus must be a vector with three elements') 63 | end 64 | 65 | % Call the C-part of the program to create aperture 66 | 67 | Th = Mat_field (1013, no_elem_x, width, no_elem_y, heights, kerf_x, kerf_y, Rfocus, no_sub_x, no_sub_y, focus); 68 | 69 | 70 | -------------------------------------------------------------------------------- /xdc_free.m: -------------------------------------------------------------------------------- 1 | % Procedure for freeing the storage occupied by an aperture 2 | % 3 | % Calling: xdc_free(Th); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % 7 | % Return: None 8 | % 9 | % Version 1.0, November 28, 1995 by Joergen Arendt Jensen 10 | 11 | function res = xdc_free (Th) 12 | 13 | 14 | % Call the C-part of the program to show aperture 15 | 16 | Mat_field (1040,Th); 17 | 18 | 19 | -------------------------------------------------------------------------------- /xdc_get.m: -------------------------------------------------------------------------------- 1 | % Procedure for getting data for an aperture 2 | % 3 | % Calling: data = xdc_get(Th, info_type); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % info_type - Which information to get (text string). 7 | % The possibilities are: 8 | % rect - information about rectangular elements 9 | % tri - information about triangular elements 10 | % lin - information about line bounded elements 11 | % focus - focus time line 12 | % apo - apodization time line 13 | % 14 | % Return: data - data about the aperture 15 | % 16 | % Example: data = xdc_get (Th,'focus'); 17 | % 18 | % Returns the delay values for this aperture. See the manual for the 19 | % individual values content in the user's guide. 20 | % 21 | % Version 1.1, November 29, 2001 by Joergen Arendt Jensen 22 | 23 | function data = xdc_get (Th, info_type) 24 | 25 | % Check the type argument 26 | 27 | if nargin < 2 28 | info_type = 'rect'; 29 | end 30 | 31 | if strcmp(info_type, 'rect') 32 | info = 1; 33 | elseif strcmp(info_type, 'tri') 34 | info = 2; 35 | elseif strcmp(info_type, 'lin') 36 | info = 3; 37 | elseif strcmp(info_type, 'focus') 38 | info = 4; 39 | elseif strcmp(info_type, 'apo') 40 | info = 5; 41 | else 42 | info = 1; 43 | end 44 | 45 | % Call the C-part of the program to show aperture 46 | 47 | data = Mat_field (1101,Th,info); 48 | 49 | 50 | -------------------------------------------------------------------------------- /xdc_impulse.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the impulse response of an aperture 2 | % 3 | % Calling: xdc_impulse (Th,pulse); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % pulse - Impulse response of aperture as row vector 7 | % 8 | % Return: None 9 | % 10 | % Version 1.01, May 20, 1997 by Joergen Arendt Jensen 11 | 12 | function res = xdc_impulse (Th, pulse) 13 | 14 | % Test that pulse is of right dimension 15 | 16 | [n,m]=size(pulse); 17 | if n ~= 1 18 | error ('Pulse must be a row vector'); 19 | end 20 | 21 | % Call the C-part of the program to show aperture 22 | 23 | Mat_field (1050,Th,pulse); 24 | 25 | 26 | -------------------------------------------------------------------------------- /xdc_line_convert.m: -------------------------------------------------------------------------------- 1 | % Procedure for converting an aperture from consisting of rectangles 2 | % to consist of triangles 3 | % 4 | % Calling: xdc_line_convert (Th); 5 | % 6 | % Parameters: A handle Th as a pointer to this transducer aperture. The 7 | % pointer value will be the same as for the rectangular aperture. 8 | % The rectangles defined in the aperture will be released. 9 | % 10 | % Version 1.0, August 5, 1999 by Joergen Arendt Jensen 11 | 12 | function res = xdc_line_convert (Th) 13 | 14 | % Call the C-part of the program to convert aperture 15 | 16 | Mat_field (1031, Th); 17 | 18 | 19 | -------------------------------------------------------------------------------- /xdc_linear_array.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a linear array transducer 2 | % 3 | % Calling: Th = xdc_linear_array (no_elements, width, height, kerf, no_sub_x, no_sub_y, focus); 4 | % 5 | % Parameters: no_elements - Number of physical elements. 6 | % width - Width in x-direction of elements. 7 | % height - Width in y-direction of elements. 8 | % kerf - Width in x-direction between elements. 9 | % no_sub_x - Number of sub-divisions in x-direction of elements. 10 | % no_sub_y - Number of sub-divisions in y-direction of elements. 11 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 12 | % 13 | % Return: A handle Th as a pointer to this transducer aperture. 14 | % 15 | % Version 1.0, November 20, 1995 by Joergen Arendt Jensen 16 | 17 | function Th = xdc_linear_array (no_elements, width, height, kerf, no_sub_x, no_sub_y, focus) 18 | 19 | % Check that all parameters are valid 20 | 21 | if (no_elements<1) 22 | error ('Field error: Illegal number of physical transducer elements') 23 | end 24 | 25 | if (width<=0) || (height<=0) 26 | error ('Field error: Width or height is negativ or zero') 27 | end 28 | 29 | if (kerf<0) 30 | error ('Field error: Kerf is negativ') 31 | end 32 | 33 | if (no_sub_x<1) || (no_sub_y<1) 34 | error ('Field error: Number of mathematical elements must 1 or more') 35 | end 36 | 37 | if (min(size(focus))~=1) || (max(size(focus))~=3) 38 | error ('Field error: Focus must be a vector with three elements') 39 | end 40 | 41 | % Call the C-part of the program to create aperture 42 | 43 | Th = Mat_field (1001,no_elements, width, height, kerf, no_sub_x, no_sub_y, focus); 44 | 45 | 46 | -------------------------------------------------------------------------------- /xdc_linear_multirow.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a linear array transducer 2 | % with an number of rows (1.5D array) 3 | % 4 | % Calling: Th = xdc_linear_multirow (no_elem_x, width, no_ele_y, heights, kerf_x, kerf_y, 5 | % no_sub_x, no_sub_y, focus); 6 | % 7 | % Parameters: no_elem_x - Number of physical elements in x-direction. 8 | % width - Width in x-direction of elements. 9 | % no_elem_y - Number of physical elements in y-direction. 10 | % heights - Heights of the element rows in the y-direction. 11 | % Vector with no_elem_y values. 12 | % kerf_x - Width in x-direction between elements. 13 | % kerf_y - Gap in y-direction between elements. 14 | % no_sub_x - Number of sub-divisions in x-direction of physical elements. 15 | % no_sub_y - Number of sub-divisions in y-direction of physical elements. 16 | % focus[] - Fixed focus for array (x,y,z). Vector with three elements. 17 | % 18 | % Return: A handle Th as a pointer to this transducer aperture. 19 | % 20 | % Version 1.0, June 19, 1998 by Joergen Arendt Jensen 21 | 22 | function Th = xdc_linear_multirow (no_elem_x, width, no_elem_y, heights, kerf_x, kerf_y, no_sub_x, no_sub_y, focus) 23 | 24 | % Check that all parameters are valid 25 | 26 | if (no_elem_x<1) 27 | error ('Field error: Illegal number of physical transducer elements in x-direction') 28 | end 29 | 30 | if (width<=0) 31 | error ('Field error: Width of elements is negativ or zero') 32 | end 33 | 34 | if (no_elem_y<1) 35 | error ('Field error: Illegal number of physical transducer elements in y-direction') 36 | end 37 | 38 | for i=1:no_elem_y 39 | if (heights(i)<=0) 40 | error ('Field error: Height of elements is negativ or zero') 41 | end 42 | end 43 | 44 | if (kerf_x<0) 45 | error ('Field error: Kerf in x-direction is negativ') 46 | end 47 | 48 | if (kerf_y<0) 49 | error ('Field error: Kerf in y-direction is negativ') 50 | end 51 | 52 | if (no_sub_x<1) | (no_sub_y<1) 53 | error ('Field error: Number of mathematical elements must 1 or more') 54 | end 55 | 56 | if (min(size(focus))~=1) | (max(size(focus))~=3) 57 | error ('Field error: Focus must be a vector with three elements') 58 | end 59 | 60 | % Call the C-part of the program to create aperture 61 | 62 | Th = Mat_field (1012,no_elem_x, width, no_elem_y, heights, kerf_x, kerf_y, no_sub_x, no_sub_y, focus); 63 | 64 | 65 | -------------------------------------------------------------------------------- /xdc_lines.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating an aperture bounded by a set of lines 2 | % 3 | % Calling: Th = xdc_lines (lines, center, focus); 4 | % 5 | % Parameters: 6 | % 7 | % lines - Information about the lines. One row 8 | % for each line. The contents is: 9 | % 10 | % Index Variable Value 11 | % ------------------------------------------------------------------------------ 12 | % 1 no_phys The number for the physical element starting from one 13 | % 2 no_mat The number for the mathematical element starting from one 14 | % 3 slope Slope of line (NaN is infinity slope) 15 | % 4 infinity True if slope is infinity 16 | % 5 intersect Intersection with y-axis (slope<>NaN) 17 | % or x-axis if slope is infinity 18 | % 6 above Whether the active aperture is above or to 19 | % the left (for infinite slope) of the line 20 | % 21 | % center - The center of the physical elements. One line for 22 | % each physical element starting from 1. 23 | % 24 | % focus - The fixed focus for this aperture. 25 | % 26 | % All dimensions are in meters. 27 | % 28 | % Notice that this procedure will only work for flat element positioned 29 | % in the x-y plane. 30 | % 31 | % Return: A handle Th as a pointer to this transducer aperture. 32 | % 33 | % Version 1.0, August 1, 1997 by Joergen Arendt Jensen 34 | 35 | function Th = xdc_lines (lines, center, focus) 36 | 37 | % Check that all parameters are valid 38 | 39 | [n,m] = size(lines); 40 | if (m~=6) 41 | error ('Field error: Not sufficient coordinates for lines') 42 | end 43 | 44 | [n,m] = size(center); 45 | if (m~=3) 46 | error ('Field error: Not correct size for center points') 47 | end 48 | 49 | [n,m] = size(focus); 50 | if (n~=1) | (m~=3) 51 | error ('Field error: Not correct size for focus point') 52 | end 53 | 54 | % Call the C-part of the program to create aperture 55 | 56 | Th = Mat_field (1022, lines, center, focus); 57 | 58 | 59 | -------------------------------------------------------------------------------- /xdc_piston.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a flat, round piston transducer 2 | % 3 | % Calling: Th = xdc_piston (radius, ele_size); 4 | % 5 | % Parameters: radius - Radius of aperture. 6 | % ele_size - Size of elements for modeling transducer. 7 | % 8 | % All dimensions are in meters. 9 | % 10 | % Return: A handle Th as a pointer to this transducer aperture. 11 | % 12 | % Version 1.0, September 3, 1996 by Joergen Arendt Jensen 13 | 14 | function Th = xdc_piston (radius, ele_size) 15 | 16 | % Check that all parameters are valid 17 | 18 | if (radius<0) 19 | error ('Field error: Negative radius of physical transducer elements') 20 | end 21 | 22 | if (ele_size<=0) | (ele_size>radius) 23 | error ('Field error: Illegal size of mathematical element') 24 | end 25 | 26 | % Call the C-part of the program to create aperture 27 | 28 | Th = Mat_field (1010, radius, ele_size); 29 | 30 | 31 | -------------------------------------------------------------------------------- /xdc_quantization.m: -------------------------------------------------------------------------------- 1 | % Procedure for setting the minimum quantization interval that 2 | % can be used when phasing the transducer. 3 | % 4 | % Remember that the focus time lines must be set again for the 5 | % quantization to take effect. This setting does not affect the 6 | % user calculated delays. 7 | % 8 | % Calling: xdc_quantization (Th, min_delay); 9 | % 10 | % Parameters: Th - Pointer to the transducer aperture. 11 | % min_delay - The smallest delay in seconds that can be 12 | % used by the system. No quantization is used, 13 | % if this delay is set to zero. 14 | % 15 | % Return: None. 16 | % 17 | % Version 1.01, July 10, 1998 by Joergen Arendt Jensen 18 | 19 | function res = xdc_quantization (Th, min_delay) 20 | 21 | % Call the C-part of the program to set quantization 22 | 23 | Mat_field (1065,Th,min_delay); 24 | 25 | 26 | -------------------------------------------------------------------------------- /xdc_rectangles.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating an aperture consisting of rectangles 2 | % 3 | % Calling: Th = xdc_rectangles (rect, center, focus); 4 | % 5 | % Parameters: 6 | % 7 | % rect - Information about the rectangles. One row 8 | % for each rectangle. The contents is: 9 | % 10 | % Index Variable Value 11 | % ----------------------------------------------------------------------- 12 | % 1 no The number for the physical aperture starting from one 13 | % 2-4 x1,y1,z1 First corner coordinate 14 | % 5-7 x2,y2,z2 Second corner coordinate 15 | % 8-10 x3,y3,z3 Third corner coordinate 16 | % 11-13 x4,y4,z4 Fourth corner coordinate 17 | % 14 apo Apodization value for this element. 18 | % 15 width Width of the element (x direction) 19 | % 16 heigth Height of the element (y direction) 20 | % 17-19 c1,c2,c2 Center point of the rectangle 21 | % 22 | % The corner coordiantes points must 23 | % be in a sorted order, so that they are meet in 24 | % counter clockwise order when going from 1 to 2 to 3 to 4. 25 | % The rectangle number given must also be in increasing order. 26 | % 27 | % center - The center of the physical elements. One line for 28 | % each element starting from 1. 29 | % 30 | % focus - The fixed focus for this aperture. 31 | % 32 | % All dimensions are in meters. 33 | % 34 | % Return: A handle Th as a pointer to this transducer aperture. 35 | % 36 | % Version 1.0, August 1, 1997 by Joergen Arendt Jensen 37 | 38 | function Th = xdc_rectangles (rect, center, focus) 39 | 40 | % Check that all parameters are valid 41 | 42 | [n,m] = size(rect); 43 | if (m~=19) 44 | error ('Field error: Not sufficient coordinates for rectangles') 45 | end 46 | 47 | [n,m] = size(center); 48 | if (m~=3) 49 | error ('Field error: Not correct size for center points') 50 | end 51 | 52 | [n,m] = size(focus); 53 | if (n~=1) | (m~=3) 54 | error ('Field error: Not correct size for focus point') 55 | end 56 | 57 | % Call the C-part of the program to create aperture 58 | 59 | Th = Mat_field (1021, rect, center, focus); 60 | 61 | 62 | -------------------------------------------------------------------------------- /xdc_show.m: -------------------------------------------------------------------------------- 1 | % Procedure for showing an aperture 2 | % 3 | % Calling: xdc_show(Th, info_type); 4 | % 5 | % Parameters: Th - Pointer to the transducer aperture. 6 | % info_type - Which information to show (text string). 7 | % The possibilities are: 8 | % elements - information about elements 9 | % focus - focus time line 10 | % apo - apodization time line 11 | % all - all information is shown 12 | % The argument is optional, and by default all 13 | % information is shown. 14 | % 15 | % Return: ASCII output on the screen about the aperture 16 | % 17 | % Version 1.0, November 28, 1995 by Joergen Arendt Jensen 18 | 19 | function res = xdc_show (Th, info_type) 20 | 21 | % Check the type argument 22 | 23 | if nargin < 2 24 | info_type = 'all'; 25 | end 26 | 27 | if strcmp(info_type, 'elements') 28 | info =1; 29 | elseif strcmp(info_type, 'focus') 30 | info = 2; 31 | elseif strcmp(info_type, 'apo') 32 | info = 3; 33 | else 34 | info = 0; 35 | end 36 | 37 | % Call the C-part of the program to show aperture 38 | 39 | Mat_field (1100,Th,info); 40 | 41 | 42 | -------------------------------------------------------------------------------- /xdc_times_focus.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating a focus time line for an aperture 2 | % The user here supplies the delay times for each element 3 | % 4 | % Calling: xdc_times_focus (Th, times, delays); 5 | % 6 | % Parameters: Th - Pointer to the transducer aperture. 7 | % times - Time after which the associated apodization is valid. 8 | % delays - Delay values. Matrix with one row for each 9 | % time value and a number of columns equal to the 10 | % number of physical elements in the aperture. 11 | % 12 | % Return: none. 13 | % 14 | % Version 1.0, November 28, 1995 by Joergen Arendt Jensen 15 | 16 | function res = xdc_focus_times (Th,times,delays) 17 | 18 | % Check the times vector 19 | 20 | [m1,n]=size(times); 21 | if (n ~= 1) 22 | error ('Times vectors must have one columns'); 23 | end 24 | 25 | [m2,n]=size(delays); 26 | 27 | % Check both arrays 28 | 29 | if (m1 ~= m2) 30 | error ('There must be the same number of rows for times and delays'); 31 | end 32 | 33 | % Call the C-part of the program to insert focus 34 | 35 | Mat_field (1061,Th,times,delays); 36 | 37 | 38 | -------------------------------------------------------------------------------- /xdc_triangles.m: -------------------------------------------------------------------------------- 1 | % Procedure for creating an aperture with a number 2 | % of physical elements consisting of triangles 3 | % 4 | % Calling: Th = xdc_triangles (data, center, focus); 5 | % 6 | % data - Information about the triangles. One row 7 | % for each triangle. The contents is: 8 | % 9 | % Index Variable Value 10 | % ----------------------------------------------------------------------- 11 | % 1 no The number for the physical aperture starting from one 12 | % 2-4 x1,y1,z1 First corner coordinate 13 | % 5-7 x2,y2,z2 Second corner coordinate 14 | % 8-10 x3,y3,z3 Third corner coordinate 15 | % 11 apo Apodization value for this element. 16 | % 17 | % The physical triangle number given must be in increasing order. 18 | % 19 | % center - The center of the physical elements. One line for 20 | % each element starting from 1. 21 | % 22 | % focus - The fixed focus for this aperture. 23 | % 24 | % All dimensions are in meters. 25 | % 26 | % Return: A handle Th as a pointer to this transducer aperture. 27 | % 28 | % Version 1.0, January 20, 1999 by Joergen Arendt Jensen 29 | 30 | function Th = xdc_triangles (data, center, focus) 31 | 32 | % Check that all parameters are valid 33 | 34 | [n,m] = size(data); 35 | if (m~=11) 36 | error ('Field error: Not sufficient coordinates for triangles') 37 | end 38 | 39 | [n,m] = size(center); 40 | if (m~=3) 41 | error ('Field error: Not correct size for center points') 42 | end 43 | 44 | [n,m] = size(focus); 45 | if (n~=1) | (m~=3) 46 | error ('Field error: Not correct size for focus point') 47 | end 48 | 49 | % Call the C-part of the program to create aperture 50 | 51 | Th = Mat_field (1023, data, center, focus); 52 | 53 | 54 | --------------------------------------------------------------------------------