How do I define log function for arguments of type int16 ?

23 views (last 30 days)
I am doing image processing and at some point in my code I need to find the natural log of a ratio (ration between the pre-contrast "Spre" and post-contrast signal intensities "Spost").But they are of type int16 and matlab gives me an error that "Undefined function 'log' for input arguments of type 'int16'". Could you please help me out with a solution, thanks alot.
R2 = 1./SE;
TE = 120; % echo time 120 ms
SE = analyze75read('10_ep2d_ge_se_128_DCE_slice8.hdr');
[xsize_se, ysize_se, tsize_se] = size(SE);
for x = 1:xsize_se
for y = 1:ysize_se
IM_signal_SE = squeeze(SE(x,y,:));
IM_signal_SE_baseline = squeeze(SE(x,y,4:15));
Spre = mean(IM_signal_SE_baseline); % pre contrast (AVERAGE baseline signal intensity)
Spost = IM_signal_SE - Spre; % post contrast signal SE
*deltaR2 = 1/TE (log(Spre./Spost));*
end
end

Accepted Answer

James Tursa
James Tursa on 18 Jun 2014
Turn them into double. E.g.,
log(double(Spre)./double(Spost))
  2 Comments
Image Analyst
Image Analyst on 18 Jun 2014
Hoda said in his own Answer (which I deleted because only 1 Answer can be accepted), which he mistakenly accepted:
Thank you very much!
I transferred it here and deleted Hoda's answer so he can officially Accept James's answer instead.
Image Analyst
Image Analyst on 18 Jun 2014
Edited: Image Analyst on 18 Jun 2014
Please accept and vote for an answer if it solved your problem.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!