| classdef us_resolution < handle |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| properties (SetAccess = public) |
| |
| name |
| author |
| affiliation |
| creation_date |
|
|
| |
| pht |
| scan |
| image |
| score |
| flagDisplay |
| dynamic_range |
| |
| end |
| |
| |
| properties (SetAccess = private) |
| padROI |
| end |
| |
| |
| |
| |
| |
| |
| |
| methods (Access = public) |
| |
| function h = us_resolution(input_name) |
| |
| if exist('input_name') |
| h.name= input_name; |
| else |
| h.name = ' '; |
| end |
| h.creation_date=sprintf('%d/%02d/%d %02d:%02d:%02.2f',clock); |
| h.author = ' '; |
| h.affiliation = ' '; |
| h.dynamic_range = 40; |
| h.padROI = 1.8e-3; |
| h.flagDisplay = 0; |
| h.score = []; |
| |
| end |
| |
| end |
| |
| |
| methods |
| |
| |
| function set.name(h,input) |
| assert(isstr(input), 'Wrong format of the beamformed data name. It should be a string.'); |
| h.name = input; |
| end |
| |
| function set.author(h,input) |
| assert(isstr(input), 'Wrong format of the author. It should be a string.'); |
| h.author = input; |
| end |
| |
| function set.affiliation(h,input) |
| assert(isstr(input), 'Wrong format of the affiliation. It should be a string.'); |
| h.affiliation = input; |
| end |
| |
| function set.creation_date(h,input_date) |
| assert(isstr(input_date), 'Wrong format of the creation date. It should be a string.'); |
| h.creation_date = input_date; |
| end |
| |
| function set.pht(h,input) |
| assert(isa(input,'us_phantom'), 'Wrong format of the phantom. It should be a US_PHANTOM class.'); |
| h.pht = input; |
| end |
| |
| function set.scan(h,input) |
| assert(isa(input,'linear_scan'), 'Wrong format of the scan. It should be a LINEAR_SCAN class.'); |
| h.scan = input; |
| end |
| |
| function set.image(h,input) |
| assert(isa(input,'us_image'), 'Wrong format of the image. It should be a US_IMAGE class.'); |
| h.image = input; |
| end |
| |
| function set.flagDisplay(h,input) |
| assert(numel(input)==1&&isnumeric(input), 'Wrong format of the flag for display. It should be a numeric scalar'); |
| h.flagDisplay = input; |
| end |
| |
| function set.dynamic_range(h,input) |
| assert(numel(input)==1&&isnumeric(input), 'Wrong format of the dynamic range. It should be a numeric scalar'); |
| h.dynamic_range = input; |
| end |
|
|
| end |
| |
| |
| methods (Access = public) |
| |
| function evaluate(h) |
| |
| |
| nb_frames = length(h.image.number_plane_waves); |
| frame_list = 1:nb_frames; |
| h.score = zeros(nb_frames,size(h.pht.sca,1),2); |
| maskROI = zeros(size(h.scan.x_matrix)); |
| for k=1:size(h.pht.sca,1) |
| |
| x = h.pht.sca(k,1); |
| z = h.pht.sca(k,3); |
| |
| mask = k * ( (h.scan.x_matrix > (x-h.padROI)) & ... |
| (h.scan.x_matrix < (x+h.padROI)) & ... |
| (h.scan.z_matrix > (z-h.padROI)) & ... |
| (h.scan.z_matrix < (z+h.padROI)) ); |
| maskROI = maskROI + mask; |
| end |
|
|
| |
| x_lim = [min(h.scan.x_matrix(:)) max(h.scan.x_matrix(:))]*1e3; |
| z_lim = [min(h.scan.z_matrix(:)) max(h.scan.z_matrix(:))]*1e3; |
|
|
| |
| vrange = [-h.dynamic_range 0]; |
|
|
| |
| for f=frame_list |
| |
| |
| env = h.image.data(:,:,f); |
| bmode = 20*log10(env./max(env(:))); |
|
|
| |
| if (h.flagDisplay==1) |
| close all; |
| hid = figure(1); subplot(1,3,1); set(gca,'fontsize',16); |
| imagesc((h.scan.x_axis)*1e3,(h.scan.z_axis)*1e3,bmode); |
| shading flat; colormap gray; caxis(vrange); colorbar; hold on; |
| axis equal manual; xlabel('x [mm]'); ylabel('z [mm]'); axis([x_lim z_lim]); |
| set(gca,'YDir','reverse'); |
| set(gca,'fontsize',16); |
| title(sprintf('%s\n %d plane waves',char(h.image.name),h.image.number_plane_waves(f))); |
| set(hid,'position',[124 175 1142 413]); |
| hold on; contour(h.scan.x_axis*1e3,h.scan.z_axis*1e3,maskROI,[1 1],'b-'); |
| end |
|
|
| |
| for k=1:size(h.pht.sca,1) |
|
|
| |
| patchImg = bmode; |
| patchImg(maskROI~=k) = min(bmode(:)); |
| patchMask = maskROI; |
| patchMask(maskROI~=k) = 0; |
|
|
| |
| [idzz,idxx] = find(patchMask==k); |
| x_lim_patch = [h.scan.x_axis(min(idxx)) h.scan.x_axis(max(idxx))]*1e3; |
| z_lim_patch = [h.scan.z_axis(min(idzz)) h.scan.z_axis(max(idzz))]*1e3; |
| x_patch = h.scan.x_axis(min(idxx):1:max(idxx))*1e3; |
| z_patch = h.scan.z_axis(min(idzz):1:max(idzz))*1e3; |
|
|
| |
| [idz,idx] = find(patchImg==max(patchImg(:))); |
| signalLateral = patchImg(idz,min(idxx):max(idxx)); |
| signalAxial = patchImg(min(idzz):max(idzz),idx); |
|
|
| |
| if (h.flagDisplay==1) |
| pause(1); |
| |
| figure(1); subplot(1,3,1); |
| hold on; plot([x_lim_patch(1) x_lim_patch(end)],[h.scan.z_axis(idz) h.scan.z_axis(idz)]*1e3,'-b','linewidth',1); |
| hold on; plot([h.scan.x_axis(idx) h.scan.x_axis(idx)]*1e3,[z_lim_patch(1) z_lim_patch(end)],'-r','linewidth',1); |
| axis([x_lim_patch z_lim_patch]); |
| end |
|
|
| |
| [res_axial] = h.Compute_6dB_Resolution(z_patch,signalAxial,2,'-r'); |
| [res_lateral] = h.Compute_6dB_Resolution(x_patch,signalLateral,3,'-b'); |
|
|
| |
| h.score(f,k,1) = res_axial; |
| h.score(f,k,2) = res_lateral; |
|
|
| end |
| |
| end |
| end |
| end |
| |
| methods (Access = private) |
| |
| |
| function [res] = Compute_6dB_Resolution(h,x_axis,y_signal,num,color) |
| |
| |
| coeff = 10; |
| nb_sample = length(x_axis); |
| nb_interp = nb_sample * coeff; |
| x_interp = linspace(x_axis(1),x_axis(end),nb_interp); |
| y_interp = interp1(x_axis,y_signal,x_interp); |
| |
| ind = find(y_interp >= (max(y_interp)-6) ); |
| idx1 = min(ind); |
| idx2 = max(ind); |
| res = x_interp(idx2) - x_interp(idx1); |
| |
| |
| if (h.flagDisplay==1) |
| figure(1); subplot(1,3,num); |
| plot(x_interp,y_interp,color,'linewidth',2); |
| hold on; plot([x_interp(idx1) x_interp(idx1)],[-100 0],'-k','linewidth',1); |
| hold on; plot([x_interp(idx2) x_interp(idx2)],[-100 0],'-k','linewidth',1); |
| hold off; ylabel('Amp [dB]'); |
| if (num==2) |
| title(sprintf('Axial res = %02.2f [mm]',res)); |
| xlabel('z [mm]'); |
| else |
| xlabel('x [mm]'); |
| title(sprintf('Lateral res = %02.2f [mm]',res)); |
| end |
| end |
| |
| end |
| |
| end |
| |
| |
| |
| |
|
|
| |
| methods (Access = public) |
| |
| function data = getNumberPlaneWavesList(h) |
| data = h.image.number_plane_waves; |
| end |
| |
| end |
| |
| end |
|
|