<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Mri on bramp.net</title>
    <link>https://blog.bramp.net/</link>
    <description>Recent content in Mri on bramp.net</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Tue, 15 May 2012 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bramp.net/tags/mri/" rel="self" type="application/rss+xml" />
    
    <item>
      <title>MRI scan of my brain</title>
      <link>https://blog.bramp.net/post/2012/05/15/mri-scan-of-my-brain/</link>
      <pubDate>Tue, 15 May 2012 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2012/05/15/mri-scan-of-my-brain/</guid>
      <description><p>I had a <a href="http://en.wikipedia.org/wiki/Magnetic_resonance_imaging">MRI</a> today, and afterwards I was given a CD of my scan. The data on the CD was stored in <a href="http://en.wikipedia.org/wiki/DICOM">DICOM</a> format, and after some searching I was able to find some open source software to view the data. I especially liked <a href="http://aeskulap.nongnu.org/">Aeskulap</a> which allowed interactive viewing of the data in multiple dimensions.</p>
<p>I wanted to put my scans online, so I found another set of tools, <a href="http://xmedcon.sourceforge.net/">medcon</a>, that allowed me to convert the DICOM images into png/gif format, and then I used <a href="http://ffmpeg.org/">ffmpeg</a> to create the following videos:</p>
<div class="row">
  <div class="col-md-6 text-center">
  	<video width="288" height="288" controls="controls"><source src="004.mp4" type="video/mp4" /><source src="004.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
  <div class="col-md-6 text-center">
  	<video width="288" height="288" controls="controls"><source src="000.mp4" type="video/mp4" /><source src="000.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
</div>
<div class="row">
  <div class="col-md-6 text-center">
  	<video width="256" height="256" controls="controls"><source src="001.mp4" type="video/mp4" /><source src="001.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
  <div class="col-md-6 text-center">
 	 <video width="256" height="256" controls="controls"><source src="003.mp4" type="video/mp4" /><source src="003.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
</div>
<div class="row">
  <div class="col-md-12 text-center">
  	<video width="256" height="256" controls="controls"><source src="008.mp4" type="video/mp4" /><source src="008.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
</div>
<p>I don’t know the exact layout, but on the CD I seemed to have 12 different scans, each with a series of images. The name of the files were all 8 digits numbers, with the first three being the scan number (0 to 11), and the following five digits being (0 to whatever). For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">DICOM/185723/00000000: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00000001: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00000002: DICOM medical imaging data
</span></span><span class="line"><span class="cl">...
</span></span><span class="line"><span class="cl">DICOM/185723/00100000: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00100001: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00100002: DICOM medical imaging data
</span></span><span class="line"><span class="cl">...
</span></span></code></pre></div><p>To create videos the first thing I did was to convert the images from DICOM to PNG</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install medcon
</span></span><span class="line"><span class="cl">mkdir png
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in DICOM/185723/*<span class="p">;</span> <span class="k">do</span> medcon -f <span class="nv">$i</span> -c png -o png/<span class="sb">`</span>basename <span class="nv">$i</span><span class="sb">`</span>.png <span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span></code></pre></div><p>Now to batch the images I started by creating animated gifs.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install imagemagick
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create animated gifs</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> convert -delay <span class="m">20</span> -loop <span class="m">0</span> png/<span class="nv">$i</span>*.png <span class="nv">$i</span>.gif<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span></code></pre></div><p>However, those gifs were huge, up to 20mb. So next I created a set of videos (that were a order of magnitude smaller than the gifs):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install ffmpeg
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create MP4</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> avconv -r <span class="m">5</span> -i png/<span class="nv">$i</span>%05d.png -r <span class="m">24</span> <span class="nv">$i</span>.mp4<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create webm</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> avconv -r <span class="m">5</span> -i png/<span class="nv">$i</span>%05d.png -r <span class="m">24</span> <span class="nv">$i</span>.webm<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create ogg video</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> avconv -r <span class="m">5</span> -i png/<span class="nv">$i</span>%05d.png -r <span class="m">24</span> <span class="nv">$i</span>.ogg<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span></code></pre></div><p>easy!</p>
</description>
    </item>
    
  </channel>
</rss>
