Hi developers and members,
I'm new to K-wave, and I have recently started dealing with acoustic simulation for FUS. I'm starting with an example of Prof. Treeby in FUN22. I have some basic questions about the code shown in his presentation.
1) Loading
%Prof. Treeby
ct_3D = load_nii('scct_unsmooth.nii');
ct_2D = ct_3D.img(2:end, 2:end, 70);
%My code
ct_2D = dicomread("24291");
A) Why use NIfTI files? Is there a downside to using DICOM?
B) I also didn't understand the command "ct_2D = ct_3D.img(2:end, 2:end, 70)". It seems that Prof. Treeby chooses slice 70 (and that's why it's a ct_2D) from the .nii file, but I don't understand the "2:end" options.
C) Prof. Treeby said that when doing simulations, it's better to do them in 3D rather than 2D. What would be the advantage of that?
2) Attenuation coefficient
%Prof. Treeby
alpha_coeff = 0.6 + 7.4*skull_mask;
alpha_power = ones(Nx, Ny);
medium.alpha_coeff = fitPowerLawParamsMulti(alpha_coeff, alpha_power, medium.sound_speed, freq, 2, true)
medium.alpha_power = 2;
%My code
alpha_coeff = 0.6 + 7.4*skull_mask;
alpha_power = ones(Nx, Ny);
medium.alpha_coeff = 0.11;
medium.alpha_power = 2;
A) MATLAB couldn't run line 3 of this code on my computer. I am trying to understand why it wasn't possible, but Prof. Treeby said that this line had something different and he could provide a document for it. So to eliminate the error, I simply assigned a test value to medium.alpha_coeff. But how do I make it work properly?
3) Grid, transducer, signal, and simulation
%Prof. Treeby
%Grid
kgrid = kWaveGrid(Nx, dx, Ny, dx);
cfl = 0.3;
t_end = 150e-6;
kgrid.makeTime(medium.sound_speed, cfl, t_end);
%Transducer
karray = kWaveArray;
position = [5e-3, -0.11];
radius = 64e-3;
diameter = 64e-3;
focus_pos = [5e-3, 0];
karray.addArcElement(position, radius, diameter, focus_pos);
%Signal
amp = 100e3;
input_signal = createCWSignals(kgrid.t_array, freq, amp, 0);
%Command conversion
source.p_mask = karray.getArrayBinaryMask(kgrid);
% source.p = karray.getDistributedSourceSignal(kgrid, input_signal);
%Signal detection
sensor.record = ('p_max_all');
%Simulation
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, ...
'PMLInside', false, ...
'PMLSize', 'auto', ...
'PlotPML', false, ...
'PlotScale', amp * [-1, 1], ...
'DisplayMask', edge(skull_mask, 'Canny'), ...
'DataCast', 'single');
A) This is where most errors appear in my simulation. I get:
Unrecognized function or variable 'tolStar'.
Error in offGridPoints (line 264)
[ind, is, js] = tolStar(bli_tolerance, kgrid, point);
Error in kWaveArray/getElementGridWeights (line 931)
grid_weights = offGridPoints(kgrid, integration_points, scale, ...
Error in kWaveArray/getArrayBinaryMask (line 968)
grid_weights = obj.getElementGridWeights(kgrid, ind);
Error in dicomtest1 (line 57)
source.p_mask = karray.getArrayBinaryMask(kgrid);
I would like to ask you for some tips on how to handle these errors. Also, since my transducer is pulsed, what is the best practice for modifying the transducer from continuous to pulsed?
I would appreciate any help!
Regars,
Renan