<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Topic: hounsfield2density not working for CT file</title>
		<link>http://www.k-wave.org/forum/topic/hounsfield2density-not-working-for-ct-file</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 01:50:10 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/hounsfield2density-not-working-for-ct-file" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "hounsfield2density not working for CT file"</title>
			<link>http://www.k-wave.org/forum/topic/hounsfield2density-not-working-for-ct-file#post-8285</link>
			<pubDate>Sat, 07 Aug 2021 08:03:32 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">8285@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;You can often figure out what to do by looking at the error messages. This time it says&#60;/p&#62;
&#60;p&#62;&#60;code&#62;Inputs must be floats, namely single or double&#60;/code&#62; &#60;/p&#62;
&#60;p&#62;This means it doesn't like that your image values are integers. You could try something like:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;density = hounsfield2density(single(nifti_file));&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Pmartc36 on "hounsfield2density not working for CT file"</title>
			<link>http://www.k-wave.org/forum/topic/hounsfield2density-not-working-for-ct-file#post-8282</link>
			<pubDate>Fri, 06 Aug 2021 16:31:45 +0000</pubDate>
			<dc:creator>Pmartc36</dc:creator>
			<guid isPermaLink="false">8282@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;An error still pops up:&#60;/p&#62;
&#60;p&#62;WARNING: makeGrid will be deprecated in a future version of k-Wave.&#60;br /&#62;
         Update codes to use the syntax kgrid = kWaveGrid(...).&#60;/p&#62;
&#60;p&#62;Error using polyval (line 67)&#60;br /&#62;
Inputs must be floats, namely single or double.&#60;/p&#62;
&#60;p&#62;Error in hounsfield2density (line 63)&#60;br /&#62;
density(ct_data &#38;lt; 930) = polyval([1.025793065681423, -5.680404011488714], ct_data(ct_data &#38;lt; 930));&#60;/p&#62;
&#60;p&#62;Error in nifti_test01 (line 20)&#60;br /&#62;
density = hounsfield2density(nifti_file);&#60;/p&#62;
&#60;p&#62;&#38;gt;&#38;gt;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "hounsfield2density not working for CT file"</title>
			<link>http://www.k-wave.org/forum/topic/hounsfield2density-not-working-for-ct-file#post-8280</link>
			<pubDate>Fri, 06 Aug 2021 09:40:35 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">8280@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;The error message suggests you put the variable name in quotes:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;Error in nifti_test01 (line 3)
[density, sound_speed] = hounsfield2density(&#38;#39;nifti_file&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;What happens if you remove them?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Pmartc36 on "hounsfield2density not working for CT file"</title>
			<link>http://www.k-wave.org/forum/topic/hounsfield2density-not-working-for-ct-file#post-8278</link>
			<pubDate>Fri, 06 Aug 2021 04:44:32 +0000</pubDate>
			<dc:creator>Pmartc36</dc:creator>
			<guid isPermaLink="false">8278@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello there, &#60;/p&#62;
&#60;p&#62;I've ran function hounsfield2density on a nifti file but this error keeps coming up. Here is the error log.&#60;/p&#62;
&#60;p&#62;&#38;gt;&#38;gt; whos nifti_file&#60;br /&#62;
  Name              Size                    Bytes  Class    Attributes&#60;/p&#62;
&#60;p&#62;  nifti_file      260x311x260            42047200  int16              &#60;/p&#62;
&#60;p&#62;&#38;gt;&#38;gt; nifti_test01&#60;br /&#62;
Error using zeros&#60;br /&#62;
Input following 'like' is not a numeric or logical array.&#60;/p&#62;
&#60;p&#62;Error in hounsfield2density (line 59)&#60;br /&#62;
density = zeros(size(ct_data), 'like', ct_data);&#60;/p&#62;
&#60;p&#62;Error in nifti_test01 (line 3)&#60;br /&#62;
[density, sound_speed] = hounsfield2density('nifti_file');&#60;/p&#62;
&#60;p&#62;This is the code I used.&#60;/p&#62;
&#60;p&#62;nifti_file = niftiread('att_map.nii');&#60;br /&#62;
niftiinfo('t1w_pct.nii');&#60;/p&#62;
&#60;p&#62;%% Create the computational grid&#60;/p&#62;
&#60;p&#62;Nx = 400;&#60;br /&#62;
Ny = 400;&#60;br /&#62;
Nz = 400;&#60;br /&#62;
dx = 50e-6;&#60;br /&#62;
dy = 50e-6;&#60;br /&#62;
dz = 50e-6;&#60;/p&#62;
&#60;p&#62;kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);&#60;/p&#62;
&#60;p&#62;%% Define medium properties (using hounsfield2density&#60;/p&#62;
&#60;p&#62;density = hounsfield2density(nifti_file);&#60;/p&#62;
&#60;p&#62;Any suggestion as to what I should do?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
