part 1 lab 8

Upload: goodealsnow

Post on 09-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Part 1 Lab 8

    1/20

    Velez-Colon | EE 454

    Page 1 of 20

    Jose J. Velez-Colon

    Dr. Won

    EE 454

    Tuesday, September 1, 2009

    *There are 2 documents: (1) Transformations on B-Mode 2-D Images and (2) Doppler.

  • 8/8/2019 Part 1 Lab 8

    2/20

    Velez-Colon | EE 454

    Page 2 of 20

    TRANSFORMATIONS ON B-MODE 2-DIMAGES

    Questions.

    1.What variables are stored in the file?The following variables are stored in the file carotid1:

    Name Size Bytes Class Attributes

    bmode_rf 1816x312 4532736 double

    fc 1x1 8 doubleposx_bmode 312x1 2496 double

    2. Which variable is most likely to be the image data itself? Why?

    The bcmode_rf ' variable should be the image because it is the only variable that is 2

    dimensional.

    3.View the image by typing image(bmode_rf). How well are you able to make out anystructures?

    It is nearly impossible to see the structures. Perhaps, a trained eye could see them.

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

  • 8/8/2019 Part 1 Lab 8

    3/20

    Velez-Colon | EE 454

    Page 3 of 20

    4. Obtain the envelope of the raw image data by constructing the analytic signal img. Remember,

    this signal contains the Hilbert transform of the raw data. Use the command hilbert, andpay

    attention to what the output of this function is.

    After using Hilbert and taking the magnitude of the result we get:

    Two examples of the envelope of the image are below:

    Hilbert without normalization

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

  • 8/8/2019 Part 1 Lab 8

    4/20

    Velez-Colon | EE 454

    Page 4 of 20

    Plot the histogram

    Envelope of the image

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.50

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    Gaussian Distribution without logarithmic compression.

    PixelValues

    Histogram

  • 8/8/2019 Part 1 Lab 8

    5/20

    Velez-Colon | EE 454

    Page 5 of 20

    Plot the histogram after logarithmic compression.

    Compute the axial distance and plot spatial map.

    The axial distance = 3.9500e-005

    -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.50

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    Histogram after Logarithmic Compression

  • 8/8/2019 Part 1 Lab 8

    6/20

    Velez-Colon | EE 454

    Page 6 of 20

    spatial map

    0.0376 0.0378 0.038 0.0382 0.0384 0.0386 0.0388

    5

    10

    15

    20

    25

    30

    35

    40

    Spatial Map usign logarithmic compression

    1.125 1.13 1.135 1.14 1.145 1.15 1.155 1.16 1.165 1.17

    x 10-4

    5

    10

    15

    20

    25

    30

    35

    40

  • 8/8/2019 Part 1 Lab 8

    7/20

    Velez-Colon | EE 454

    Page 7 of 20

    Plot of the image using small range.

    range .5 to 15 without logarithmic compression

    20 40 60 80 100 120 140

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    1.1

    1.2

    1.3

    1.4

    1.5

    range .5 to 15 with logarithmic compression

    20 40 60 80 100 120 140

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    1.1

    1.2

    1.3

    1.4

    1.5

  • 8/8/2019 Part 1 Lab 8

    8/20

    Velez-Colon | EE 454

    Page 8 of 20

    Now we will repeat the exercise for carotid5.mat:

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    Hilbert without normalization

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

  • 8/8/2019 Part 1 Lab 8

    9/20

    Velez-Colon | EE 454

    Page 9 of 20

    Envelope of the image

    50 100 150 200 250 300

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.50

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    Gaussian Distribution without logarithmic compression.

    PixelValues

    Histogram

  • 8/8/2019 Part 1 Lab 8

    10/20

    Velez-Colon | EE 454

    Page 10 of 20

    Compute the axial distance and plot:

    The axial distance = 3.9500e-005

    spatial map

    0.04 0.041 0.042 0.043 0.044 0.045 0.046 0.047

    5

    10

    15

    20

    25

    30

    35

    40

  • 8/8/2019 Part 1 Lab 8

    11/20

    Velez-Colon | EE 454

    Page 11 of 20

    Spatial Map usign logarithmic compression

    2 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4

    x 10-4

    5

    10

    15

    20

    25

    30

    35

    40

    -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.50

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    Histogram after Logarithmic Compression

  • 8/8/2019 Part 1 Lab 8

    12/20

    Velez-Colon | EE 454

    Page 12 of 20

    range .5 to 15 without logarithmic compression

    20 40 60 80 100 120 140

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    1.1

    1.2

    1.3

    1.4

    1.5

    range .5 to 15 with logarithmic compression

    20 40 60 80 100 120 140

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    1.1

    1.2

    1.3

    1.4

    1.5

  • 8/8/2019 Part 1 Lab 8

    13/20

    Velez-Colon | EE 454

    Page 13 of 20

    MATLABCODE

    clc; clear; close all;load('carotid5') % just change this to carotid9 to get the other results for

    % part 2 Didnt want to waste paperfigure(1)

    image(bmode_rf);

    %Obtain the envelope of the raw image data by constructing the analytic

    signal img. Remember,%this signal contains the Hilbert transform of the raw data. Use the command

    hilbert, and%pay attention to what the output of this function is.x = hilbert(bmode_rf);figure(2)a=abs(x);imagesc(a)title('Hilbert without normalization')

    % normalizationamax = max(max(a));amin = min(min(a));

    normalizeImage= (a / (amax-amin)) - amin;figure(3)imagesc(normalizeImage)colormap bonetitle('Envelope of the image');

    %plot the histogram of normalizeImagebins= linspace(0,50,50);% 50 equally spaced

    figure(4)hist(normalizeImage, bins)axis([-.5 .5 0 1850]);xlabel('Gaussian Distribution without logarithmic compression.');ylabel('Pixel Values');title('Histogram');

    k=20; % scaling constantc=.5;% compresion constantlogcompression = k * exp( log(normalizeImage) );% what I think is logarithmic

    compression...

    figure(5)

    hist(logcompression, bins)axis([-.5 .5 0 1850]);title('Histogram after Logarithmic Compression');% Axial Distance% lambda = c/f where c is velocity and f is frequency and lambda is axial% distance.c= 1580;%m/s

    f=40e6;

  • 8/8/2019 Part 1 Lab 8

    14/20

    Velez-Colon | EE 454

    Page 14 of 20

    lambda=c/f

    % spatial mapc=c*100;%cm/sT=1/f;%sampling periodspatialMap = a(1,:) * c*T/2;figure(6)

    imagesc(spatialMap,posx_bmode,a)title('spatial map')

    figure(7)spatialMap2 = logcompression(1,:) * c*T/2;imagesc(spatialMap2,posx_bmode,a)title('Spatial Map usign logarithmic compression')

    figure(8)imagesc(a(.5:.1:15));title('range .5 to 15 without logarithmic compression')

    figure(9)imagesc(logcompression(.5:.1:15))title('range .5 to 15 with logarithmic compression')

  • 8/8/2019 Part 1 Lab 8

    15/20

    Velez-Colon | EE 454

    Page 15 of 20

    DOPLER EFFECT

    Questions.

    1. What variables are contained in this file?Name Size Bytes Class Attributes

    bmode_rf 1816x188 2731264 double

    doppler_rf 1816x90x15 19612800 doublefc 1x1 8 double

    fc_dop 1x1 8 doubleposx_bmode 188x1 1504 double

    posx_dop 90x1 720 doubleprf 1x1 8 double

    2.

    Envelope Detection:

    Image after taking the hilbert and magnitude

    20 40 60 80 100 120 140 160 180

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

  • 8/8/2019 Part 1 Lab 8

    16/20

    Velez-Colon | EE 454

    Page 16 of 20

    Logarithmic Compression from .5 to 15

    Doppler Images:

    3. Look through the images over time. Do you see any difference?I look at it at a glance and all the images look alike.

    20 40 60 80 100 120 140 160 180

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    2 4 6 8 10 12 14

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    1.1

    1.2

    1.3

    1.4

    1.5

  • 8/8/2019 Part 1 Lab 8

    17/20

    Velez-Colon | EE 454

    Page 17 of 20

    From left to right, images with respect to time:

    1 2 3

    4 5 6

    You can notice small movements in the images.

    After the filter was applied I looked though the image to get:

    10 20 30 40 50 60 70 80 90

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    10 20 30 40 50 60 70 80 90

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    180010 20 30 40 50 60 70 80 90

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    10 20 30 40 50 60 70 80 90

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    10 20 30 40 50 60 70 80 90

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    10 20 30 40 50 60 70 80 90

    200

    400

    600

    800

    1000

    1200

    1400

    1600

    1800

    image after filtering

    2 4 6 8 10 12 14

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    1.1

    1.2

    1.3

    1.4

    1.5

  • 8/8/2019 Part 1 Lab 8

    18/20

    Velez-Colon | EE 454

    Page 18 of 20

    The sum of all doppler powers together:

    dopplerPower 2.3325e+007

    0 20 40 60 80 100 120 140 160 180 2000

    0.5

    1

    1.5

    2

    2.5

    3x 10

    8 Doppler Power

    Doppler Power Spatial Map

    4.5 5 5.5 6 6.5 7 7.5

    x 104

    -30

    -20

    -10

    0

    10

    20

    30

    40

    50

    60

    70

  • 8/8/2019 Part 1 Lab 8

    19/20

    Velez-Colon | EE 454

    Page 19 of 20

    MATLABCODE

    clc;clear; close all;load('carotid9.mat');x = hilbert(bmode_rf);x = abs(x);

    figure(1)imagesc(x)title('Image after taking the hilbert and magnitude');

    % envelope detectionxmax = max(max(x));xmin = min(min(x));normalizeImage = abs(( x / (xmax - xmin) ) - xmin);

    figure(2)imagesc(normalizeImage)title('envelope detector')colormap bone;

    % Logarithmic Compression

    figure(3)k = 20;c = .1;logCompression = k * exp( log (normalizeImage ) );imagesc((logCompression))

    figure(4)imagesc(logCompression(.5:15))

    %I only used this code to view the images of the doppler once, then I%commented it out.

    % for j=3:15% figure(j)% copyDopler=[];% copy1Dopler=doppler_rf(:,:,j);% imagesc(copy1Dopler)%

    % end

    % filtering with butterworh

    doppler_rf = doppler_rf (.5:15) ;ORDER = 2;% by recomendation of the m file.

    FCUTOFF = .5;

    output=URIIIRfilter(doppler_rf,ORDER,FCUTOFF);

    output= real(output);% filtering ends

    % looking througth the volume after filteringfigure(5)

    imagesc(output)title('image after filtering')

    % analytical signal of each image (hilbert)

  • 8/8/2019 Part 1 Lab 8

    20/20

    Velez-Colon | EE 454

    Page 20 of 20

    %calculating all analytical signalsresult=[];for i=1:187,

    analyticalSignal1=[];% erase the dataanalyticalSignal2=[];% erase the data

    analyticalSignal1=hilbert(bmode_rf(:,i));analyticalSignal2=conj(hilbert(bmode_rf(:,i+1)));

    computation = analyticalSignal1 .* analyticalSignal2;result=[result computation];% store all the computations to calculate

    the phase later.

    end

    % angle returns the phase angle in radians

    imaginary = imag(result);realPart = real(result);phaseSum = sum(atan(imaginary/realPart));

    % doppler velocityv = (c * fc / (4*pi*fc_dop)) .* phaseSum;

    % doppler powerresult2=[];for i=1:187,

    analyticalSignal1=[];% erase the dataanalyticalSignal2=[];% erase the data

    analyticalSignal1=hilbert(bmode_rf(:,i));analyticalSignal2=conj(hilbert(bmode_rf(:,i)));computation = analyticalSignal1 .* analyticalSignal2;result2=[result2 computation];% store all the computations to calculate

    the phase later.

    end% doppler power additiondopplerPower2 =cumsum(result2);dopplerPower2 =dopplerPower2(end);

    % doppler power for spatial mapdopplerPower = sum(result2);figure(6)bar(dopplerPower)title('Doppler Power')

    %spatial mapc = 1540*100;

    fs = 40e6;T = 1/fs;spatialMap = dopplerPower(1,:)*c*T/2;figure(7)imagesc(spatialMap,posx_bmode,dopplerPower)title('Doppler Power Spatial Map')

    Thank you Dr Won. I have learned more in the past quarters with you than in the past 5 years!

    I hope you have a good vacation.