tag:blogger.com,1999:blog-2499283742867058592024-03-19T09:16:49.839+00:00Rigorous AnalyticsOpen-Source Solutions for Medical Image AnalysisAnonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-249928374286705859.post-39814353685888475732014-09-20T14:29:00.000+01:002014-09-20T14:29:25.880+01:00Using the Debug Option in readDICOMfile()Some recent activity in <a href="http://stackoverflow.com/" target="_blank">stackoverflow</a> was brought to my attention. Specifically, several questions were raised with reading files into R using <span style="font-family: "Courier New",Courier,monospace;">readDICOMFile()</span> in the <b>oro.dicom</b> package. The questions did highlight some inadequacies in the code, and I would like to thank the person who brought these issues to the surface. Some of the errors that occurred were due to the fact that the files are not valid <a href="http://en.wikipedia.org/wiki/DICOM" target="_blank">DICOM</a> files, they were created in the early 1990s around the same time that the <a href="http://medical.nema.org/standard.html" target="_blank">DICOM Standard</a> was established. <br />
<br />
The result of <a href="http://stackoverflow.com/questions/tagged/r+dicom" target="_blank">these questions</a> is twofold<br />
<ol>
<li>I have modified some of the code to overcome difficiencies that were highlighted. These modifications will be available in the next release of <b>oro.dicom</b> (0.4.2). </li>
<li>I would like to raise the profile of a useful option in <span style="font-family: "Courier New",Courier,monospace;">readDICOMFile()<span style="font-family: inherit;">,</span></span> the <span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">debug = TRUE</span></span> input parameter. </li>
</ol>
Let's take a closer look at "debugging" the header information in DICOM files. The file of interest <a href="http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz" target="_blank">CR-MONO1-10-chest.dcm</a> is available for download. Note, you will have to uncompress this file before reading it. It is not necessary to rename it with a ".dcm" extension, but it looks nicer.<br />
<br />
<script src="https://gist.github.com/anonymous/6c2ee85c2e79bb734701.js"></script>
<br />
The first attempt at reading this file on line #2 fails. The error message is very informative, bytes 129-132 do not contain the characters DICM which is part of the DICOM Standard. So... it's safe to assume that this file is not a valid DICOM file. Delving further we turn on the debugging option (line #4) and are able to see what the first 128 bytes, which are skipped by default as part of the DICOM Standard, look like. They obviously contain information. By setting <span style="font-family: "Courier New",Courier,monospace;">skipFirst128<span class="o">=</span><span class="kc">FALSE</span></span><span class="p"> and </span><span style="font-family: "Courier New",Courier,monospace;">DICM<span class="o">=</span></span><span class="kc"><span style="font-family: "Courier New",Courier,monospace;">FALSE</span> (line #13) we can override the default settings are start reading information from the first set of bytes. This does the trick and with the debugging option turned on every field from the header is displayed. No errors have occurred, so we can display the image data from this file (line #40) below. </span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-mAbF1Wp9V2U/VB2Ao55uteI/AAAAAAAAEtU/SiwzJE-jpNk/s1600/OT-MONO2-8-hip.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-mAbF1Wp9V2U/VB2Ao55uteI/AAAAAAAAEtU/SiwzJE-jpNk/s640/OT-MONO2-8-hip.png" /></a></div>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com265tag:blogger.com,1999:blog-249928374286705859.post-504962782118883352013-12-29T17:25:00.002+00:002013-12-29T17:25:50.580+00:00oro.dicom 0.4.0The R package <a href="http://cran.r-project.org/web/packages/oro.dicom/">oro.dicom</a> contains data input/output functions for medical imaging data that conform to the <a href="http://medical.nema.org/">Digital Imaging and Communications in Medicine</a> (DICOM) standard, part of the Rigorous Analytics bundle.<br />
<br />
The latest version of <b>oro.dicom</b> (0.4.0) contains a substantial update:<br />
<br />
<ul>
<li>The function subroutines of readDICOMFile() have been re-written from scratch. </li>
<ul>
<li>The entire DICOM file is read into R using readBin(what = "raw") and parsed in a recursive fashion. That is, the DICOM header information is processed in the (group, element) doublets until a sequence header is found. Once a sequence header is found, then the subroutine is called again... and so on and so forth... until the entire DICOM header is parsed. This has reduced the total number of lines of code and, I believe, made the process more easily digestible. </li>
<li>Assuming a PixelData or SpectroscopyData field is present, the subsequent bytes will be read into a separate R data structure. </li>
</ul>
</ul>
Other modifications have taken place, one in particular is the ability of <b>oro.dicom</b> to process spectroscopy data in the DICOM format. I have had requests for this package to write DICOM files as output, but unfortunately I have not found the time myself to add this capability. <br />
<br />
The revised code has been tested against a collection of DICOM files and works well. However, only time will tell if the modifications work against the wide variety of DICOM headers one can find. If you have DICOM data that you would like to contribute to the test suite for <b>oro.dicom</b>, please contact me at <a href="mailto:rigorousanalytics@gmail.com">rigorousanalytics@gmail.com</a> or post messages on this blog. Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com77tag:blogger.com,1999:blog-249928374286705859.post-40984414034891848542013-12-29T14:50:00.001+00:002013-12-29T14:50:28.298+00:00oro.nifti 0.4.0Okay, so it's been quite a while since I provided an entry associated with <a href="http://cran.r-project.org/web/packages/oro.nifti/" target="_blank">oro.nifti</a>. That doesn't mean things haven't moved on... they have. Let's just say I've been occupied. One of the biggest changes to oro.nifti recently has been the "audit trail" is not turned off by default. If you want to take advantage of this feature you must explicitly turn it on using the commands<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">R> options("niftiAuditTrail" = TRUE)</span><br />
<span style="font-family: Courier New, Courier, monospace;">R> enableAuditTrail()</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">This modification was a consequence of severing the dependence on the <a href="http://cran.r-project.org/web/packages/XML/" target="_blank">XML</a> package, since it was only required if one wanted to keep track of the operations performed during the data analysis (it is now only suggested). Please see the vignette for more information about the audit trail feature. Otherwise, minor improvements have been made and updates so that the package works with the most current version of R (3.0.2 at the time of this blog entry). </span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;"><span style="background-color: white; line-height: 18px;">Please use the mailing list at <a href="http://r-forge.r-project.org/">r-forge.r-project.org</a> or contact </span><a href="mailto:rigorousanalytics@gmail.com" style="background-color: white; line-height: 18px; text-decoration: none;">rigorousanalytics@gmail.com</a><span style="background-color: white; line-height: 18px;"> with any suggestions.</span></span><br />
<span style="font-family: inherit;"><span style="background-color: white; line-height: 18px;"><br /></span></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcDD2UcP-9ykvU2qsj3GNSeohaQcjSax0VRdycZLbCk4FCufR9kWY_PqlMmrRtldka_Y8R7A4pTYmON0oHEv0WtEAH1qn0BiLM9Ob04LIaPUlki-e-sP7QxkFl7otoNID_Nm_7jF9lcJE/s1600/spine1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcDD2UcP-9ykvU2qsj3GNSeohaQcjSax0VRdycZLbCk4FCufR9kWY_PqlMmrRtldka_Y8R7A4pTYmON0oHEv0WtEAH1qn0BiLM9Ob04LIaPUlki-e-sP7QxkFl7otoNID_Nm_7jF9lcJE/s1600/spine1.png" height="400" width="400" /></a></div>
<span style="font-family: inherit;"><br /></span>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com33tag:blogger.com,1999:blog-249928374286705859.post-20071329632674984202011-12-29T13:42:00.000+00:002011-12-29T13:42:46.470+00:00Magnetic Resonance Imaging in RVolume 44 of the <a href="http://www.jstatsoft.org/" target="_blank"><i>Journal of Statistical Software</i></a> was published in October 2011. The special volume on “Magnetic Resonance Imaging in R” features articles and packages related to a variety of imaging modalities:<br />
<ul>
<li><a href="http://en.wikipedia.org/wiki/Functional_MRI" target="_blank">functional MRI</a></li>
<li><a href="http://en.wikipedia.org/wiki/Diffusion_MRI" target="_blank">diffusion-weighted MRI</a></li>
<li>dynamic contrast-enhanced MRI</li>
<li>dynamic susceptibility-contrast MRI </li>
<li>structural MRI</li>
</ul>
The papers describe the methodology, software implementation and provide comprehensive examples and data. A complete list of the issues is:<br />
<br />
<ul>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i01">Special Volume on Magnetic Resonance Imaging in R</a><br />
<i>Karsten Tabelow, Brandon Whitcher</i><br />
Vol. 44, Issue 1, Oct 2011<div class="dates">
Submitted 2011-09-29, Accepted 2011-09-29</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i02">Markov Chain Monte Carlo Random Effects Modeling in Magnetic Resonance Image Processing Using the BRugs Interface to WinBUGS</a><br />
<i>Martin D. King, Fernando Calamente, Chris A. Clark, David G. Gadian</i><br />
Vol. 44, Issue 2, Oct 2011<div class="dates">
Submitted 2010-10-01, Accepted 2011-06-10</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i03">DATforDCEMRI: An R Package for Deconvolution Analysis and Visualization of DCE-MRI Data</a><br />
<i>Gregory Z. Ferl</i><br />
Vol. 44, Issue 3, Oct 2011<div class="dates">
Submitted 2010-10-11, Accepted 2011-06-22</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i04">cudaBayesreg: Parallel Implementation of a Bayesian Multilevel Model for fMRI Data Analysis</a><br />
<i>Adelino R. Ferreira da Silva</i><br />
Vol. 44, Issue 4, Oct 2011<div class="dates">
Submitted 2010-10-20, Accepted 2011-06-16</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i05">Quantitative Analysis of Dynamic Contrast-Enhanced and Diffusion-Weighted Magnetic Resonance Imaging for Oncology in R</a><br />
<i>Brandon Whitcher, Volker J. Schmid</i><br />
Vol. 44, Issue 5, Oct 2011<div class="dates">
Submitted 2010-10-20, Accepted 2011-06-17</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i06">Working with the DICOM and NIfTI Data Standards in R</a><br />
<i>Brandon Whitcher, Volker J. Schmid, Andrew Thorton</i><br />
Vol. 44, Issue 6, Oct 2011<div class="dates">
Submitted 2010-10-25, Accepted 2011-06-07</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i07">mritc: A Package for MRI Tissue Classification</a><br />
<i>Dai Feng, Luke Tierney</i><br />
Vol. 44, Issue 7, Oct 2011<div class="dates">
Submitted 2010-10-28, Accepted 2011-06-20</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i08">TractoR: Magnetic Resonance Imaging and Tractography with R</a><br />
<i>Jonathan D. Clayden, Susana Muñoz Maniega, Amos J. Storkey, Martin D. King, Mark E. Bastin, Chris A. Clark</i><br />
Vol. 44, Issue 8, Oct 2011<div class="dates">
Submitted 2010-10-28, Accepted 2011-06-02</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i09">Temporal and Spatial Independent Component Analysis for fMRI Data Sets Embedded in the AnalyzeFMRI R Package</a><br />
<i>Cécile Bordier, Michel Dojat, Pierre Lafaye de Micheaux</i><br />
Vol. 44, Issue 9, Oct 2011<div class="dates">
Submitted 2010-10-29, Accepted 2011-06-16</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i10">neuRosim: An R Package for Generating fMRI Data</a><br />
<i>Marijke Welvaert, Joke Durnez, Beatrijs Moerkerke, Geert Berdoolaege, Yves Rosseel</i><br />
Vol. 44, Issue 10, Oct 2011<div class="dates">
Submitted 2010-10-31, Accepted 2011-06-21</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i11">Statistical Parametric Maps for Functional MRI Experiments in R: The Package fmri</a><br />
<i>Karsten Tabelow, Jörg Polzehl</i><br />
Vol. 44, Issue 11, Oct 2011<div class="dates">
Submitted 2010-11-10, Accepted 2011-06-15</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i12">Beyond the Gaussian Model in Diffusion-Weighted Imaging: The Package dti</a><br />
<i>Jörg Polzehl, Karsten Tabelow</i><br />
Vol. 44, Issue 12, Oct 2011<div class="dates">
Submitted 2010-11-10, Accepted 2011-06-15</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i13">FIAR: An R Package for Analyzing Functional Integration in the Brain</a><br />
<i>Bjorn Roelstraete, Yves Rosseel</i><br />
Vol. 44, Issue 13, Oct 2011<div class="dates">
Submitted 2010-11-13, Accepted 2011-06-21</div>
</li>
<li style="padding-bottom: 10px;">
<a href="http://www.jstatsoft.org/v44/i14">arf3DS4: An Integrated Framework for Localization and Connectivity Analysis of fMRI Data</a><br />
<i>Wouter D. Weeda, Frank de Vos, Lourens J. Waldorp, Raoul Grasman, Hilde M. Huizenga</i><br />
Vol. 44, Issue 14, Oct 2011<div class="dates">
Submitted 2010-11-14, Accepted 2011-10-28</div>
<div class="dates">
</div>
</li>
</ul>
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com30tag:blogger.com,1999:blog-249928374286705859.post-83692829382742698022011-12-27T22:05:00.000+00:002011-12-29T13:17:34.606+00:00oro.nifti 0.3.1The <b><span style="font-family: inherit;"></span></b> package <a href="http://cran.r-project.org/web/packages/oro.nifti/" target="_blank">oro.nifti</a>
contains functions for the input/output and visualization of medical
imaging data that follow either the ANALYZE, NIfTI or AFNI formats.
This package is part of the <a href="http://rigorousanalytics.blogspot.com/">Rigorous Analytics</a> bundle.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-80x0HGGjxl4/TvxnQLYay7I/AAAAAAAACis/trxWs9K24wo/s1600/func_image_axial.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="http://4.bp.blogspot.com/-80x0HGGjxl4/TvxnQLYay7I/AAAAAAAACis/trxWs9K24wo/s400/func_image_axial.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Lightbox display of functional MRI "resting-state" acquisition using image(). The axial plane is used by default.</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-p4s-Z8hkHHI/TvxnS3YwnsI/AAAAAAAACi0/VX1WGUPXi1I/s1600/func_image_coronal.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="http://4.bp.blogspot.com/-p4s-Z8hkHHI/TvxnS3YwnsI/AAAAAAAACi0/VX1WGUPXi1I/s400/func_image_coronal.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Lightbox display of functional MRI "resting-state" acquisition using image(, plane="coronal").</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-IYJs0urfw7A/TvxnUrHRt3I/AAAAAAAACi8/q4rLnBWGcAU/s1600/func_image_saggital.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="http://1.bp.blogspot.com/-IYJs0urfw7A/TvxnUrHRt3I/AAAAAAAACi8/q4rLnBWGcAU/s400/func_image_saggital.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Llightbox display of functional MRI "resting-state" acquisition using image(, plane="sagittal").</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-iVZ6p0q50Q4/TvxnWKcmzgI/AAAAAAAACjE/v7Ko0KPDRaA/s1600/func_ortho.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="http://4.bp.blogspot.com/-iVZ6p0q50Q4/TvxnWKcmzgI/AAAAAAAACjE/v7Ko0KPDRaA/s400/func_ortho.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Orthographic display of functional MRI "resting-state" acquisition using orthographic().</td></tr>
</tbody></table>
<br />
The latest version of <a href="http://cran.r-project.org/web/packages/oro.nifti/" target="_blank">oro.nifti</a> (0.3.1) contains a substantial number of updates:<br />
<ul>
<li><b>Visualization of NIfTI and ANALYZE S4 objects</b></li>
<ul>
<li>Aspect ratio is now respected in the overloaded image() function for "nifti" and "anlz" class objects.</li>
<li>The plane of acquisition (axial, coronal, sagittal) may now be specified by the user.</li>
<li> Min/max values of the data are properly interrogated if cal.min/cal.max or glmin/glmax are not specified.</li>
</ul>
<li>Added accessor/replacement functions for cal.min and cal.max NIfTI metadata fields.</li>
<li>Fixed bug in pixdim<- replacement function, should work now. </li>
<li>Fixed bug in writeNIfTI so that FSLView can correctly identify the min/max values.</li>
<li>Better treatment of Qform and Sform information.</li>
</ul>
Please use the mailing list at R-Forge or contact <a href="mailto:rigorousanalytics@googlemail.com">rigorousanalytics@googlemail.com</a> with any suggestions.<br />
<ul>
</ul>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com41tag:blogger.com,1999:blog-249928374286705859.post-20627722140789639542011-12-27T11:51:00.000+00:002011-12-27T21:49:27.503+00:00oro.dicom 0.3.3The R package <a href="http://cran.r-project.org/web/packages/oro.dicom/" target="_blank">oro.dicom</a> contains data input/output functions for medical imaging data that conform to the <a href="http://medical.nema.org/" target="_blank">Digital Imaging and Communications in Medicine</a> (DICOM) standard, part of the <a href="https://r-forge.r-project.org/projects/rigorous/" target="_blank">Rigorous Analytics bundle</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-VMioKBP_fCo/Tvmw-ZytucI/AAAAAAAACgo/xN2tI0ZV_4k/s1600/spine1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-VMioKBP_fCo/Tvmw-ZytucI/AAAAAAAACgo/xN2tI0ZV_4k/s320/spine1.png" width="320" /></a></div>
<br />
The latest version of <a href="http://cran.r-project.org/web/packages/oro.dicom/" target="_blank">oro.dicom</a> (0.3.3) contains a substantial number of updates:<br />
<ul>
<li>dicomInfo = readDICOMFile and dicomSeparate = readDICOM, but the old function calls still exist for now to smooth the transition.</li>
<ul>
<li>readDICOM now accepts a single file as input, creating the list-of-lists structure with one element in $hdr and $img.</li>
</ul>
<li>Modest speed improvements in readDICOMFile from a thorough use of Rprof().</li>
<li>Added txtProgressBar() to readDICOM and dicomTable.</li>
<li>Sub-routines used in readDICOM have been made private.</li>
<li>Added default sform information to dicom2nifti.</li>
<li>Miscellaneous bug fixes.</li>
<li>Added "instance" input parameter to create4D so the user can decide whether or not to access the "InstanceNumber" DICOM header field for slice ordering.</li>
</ul>
Please use the mailing list at R-Forge or contact <a href="mailto:rigorousanalytics@googlemail.com">rigorousanalytics@googlemail.com</a> with any suggestions.<br />
<br />Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com61tag:blogger.com,1999:blog-249928374286705859.post-29902496629794023892010-12-21T12:07:00.000+00:002010-12-21T12:07:28.743+00:00oro.nifti 0.2.4<div style="font-family: Arial,Helvetica,sans-serif;">The <b><span style="font-family: inherit;">R</span></b> package <b>oro.nifti</b> contains functions for the input/output and visualization of medical imaging data that follow either the ANALYZE, NIfTI or AFNI formats. This package is part of the <a href="http://rigorousanalytics.blogspot.com/">Rigorous Analytics</a> bundle.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFV6ljWYN_-ljhCkLsg4uroKTSMrDGMyqzpXjIXIsQsre9AOt7Ce4_wGG1rrdJ3Wl9NbT5dTBN1Tx-vWeAvN7O2BsrkusKL1kJqgedb4mUBYhoveOxjznh2tO62G6ld2SyF_NifuukEts/s1600/afni_anat1%252Borig.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFV6ljWYN_-ljhCkLsg4uroKTSMrDGMyqzpXjIXIsQsre9AOt7Ce4_wGG1rrdJ3Wl9NbT5dTBN1Tx-vWeAvN7O2BsrkusKL1kJqgedb4mUBYhoveOxjznh2tO62G6ld2SyF_NifuukEts/s400/afni_anat1%252Borig.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Orthographic display of structural MRI acquisition from the AFNI data collection (afni_anat1+orig.BRIK).</td></tr>
</tbody></table><br />
<br />
The latest version of <a href="http://cran.r-project.org/package=oro.nifti"><b>oro.nifti</b></a> (0.2.4) has been submitted to <a href="http://cran.r-project.org/">CRAN</a> and is available on <a href="http://r-forge.r-project.org/">R-Forge</a> now. New features include:</div><ul><li><span style="font-family: Arial,Helvetica,sans-serif;">Read/write/visualize AFNI data (thanks to contributions by K. Tabelow)</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif;">writeANALZE and writeNIfTI are now S4 generic functions (suggested by K. Tabelow)</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif;">Conversion in both directions between fmridata-S3 (from the <b>fmri</b> package) and nifti-S4 classes.</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif;">Fixed bugs in translateCoordinate (thanks to R. Heckemann)</span></li>
</ul><span style="font-family: Arial,Helvetica,sans-serif;">Please use the mailing list for any suggestions or contact <a href="mailto:rigorousanalytics@gmail.com">rigorousanalytics@gmail.com</a>.</span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"> </span>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com775tag:blogger.com,1999:blog-249928374286705859.post-17591681601916762742010-10-26T23:19:00.000+01:002010-10-26T23:19:58.522+01:00DEADLINE EXTENDED -- CFP: Special Issue in JSS for "Magnetic Resonance Imaging in R"<div style="text-align: center;"><i><b><span style="font-size: large;">Magnetic Resonance Imaging in R </span></b></i></div><br />
The deadline for submission to the Special Issue of the <i>Journal of Statistical Software</i>(<i>JSS</i> - <a href="http://www.jstatsoft.org/" target="_blank">http://www.jstatsoft.org)</a> has been extended to <b>November 14, 2010</b>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfelbasWF5zmf3dqo4xP0TEg8k2875xCVXIANgTUiBL6J4JqsRaXAAReytErj1AYts7BuFE4RgCk70bkphYFpeSt-GImo-5dF7OTgsQzuSm5-jb6yigyCI_fj65JYW7Prx0rkdj5D7Oek/s1600/ffd_zstat1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfelbasWF5zmf3dqo4xP0TEg8k2875xCVXIANgTUiBL6J4JqsRaXAAReytErj1AYts7BuFE4RgCk70bkphYFpeSt-GImo-5dF7OTgsQzuSm5-jb6yigyCI_fj65JYW7Prx0rkdj5D7Oek/s320/ffd_zstat1.png" width="320" /></a></div><br />
All MRI modalities are welcome, for example, structural MRI, functional MRI, diffusion tensor or diffusion-weighted imaging, perfusion MRI, pharmacological MRI, and others. Topics of interested include, but are not limited to,<br />
<ul><li> New analysis techniques for MRI data and their implementation.</li>
<li> The implementation of established MRI analysis techniques.</li>
<li> The incorporation of third-party open-source medical imaging software with R.</li>
<li> Data management.</li>
<li> (Semi-)Automated techniques for quality control.</li>
<li> Visualization of medical imaging data and/or modelling results.</li>
</ul>All papers will be subjected to the peer-review process, and must comply with the Guide for Authors; see <a href="http://www.jstatsoft.org/" target="_blank">http://www.jstatsoft.org</a> for more details. <br />
<br />
Please address any comments or inquiries <b>as well as submission of papers</b> to one of the guest editors below.<br />
<br />
Sincerely,<br />
<br />
<a href="mailto:b.whitcher@imperial.ac.uk">Brandon Whitcher</a> and <a href="mailto:karsten.tabelow@wias-berlin.de">Karsten Tabelow</a>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com19tag:blogger.com,1999:blog-249928374286705859.post-51327068209538226632010-10-09T22:07:00.001+01:002010-10-12T09:25:25.897+01:00oro.nifti 0.2.1<div style="font-family: Arial,Helvetica,sans-serif;">The <b><span style="font-family: inherit;">R</span></b> package <b>oro.nifti</b> contains functions for the input/output and visualization of medical imaging data that follow either the ANALYZE or NIfTI formats. This package is part of the <a href="http://rigorousanalytics.blogspot.com/">Rigorous Analytics</a> bundle.<br />
<br />
The latest version of <a href="http://cran.r-project.org/package=oro.nifti"><b>oro.nifti</b></a> (0.2.1) has been released on CRAN. New features include:</div><ul><li><span style="font-family: Arial,Helvetica,sans-serif;">More efficient use of validity checking</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif;">Added documentation for the ANALYZE 7.5 format (since it doesn't appear at www.mayo.edu)</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif;">Checks for the <b>bitops</b> package before trying to using it.<br />
</span></li>
</ul><span style="font-family: Arial,Helvetica,sans-serif;">Please use the mailing list for any suggestions or contact <a href="mailto:rigorousanalytics@gmail.com">rigorousanalytics@gmail.com</a>. </span>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com10tag:blogger.com,1999:blog-249928374286705859.post-22119284798312993612010-10-09T22:05:00.000+01:002010-10-12T09:31:50.184+01:00oro.dicom 0.2.7<div style="font-family: Arial,Helvetica,sans-serif;">The <b>R</b> package <a href="http://cran.r-project.org/package=oro.dicom"><b>oro.dicom</b></a> contains functions for the input/output of medical imaging data that conform to the Digital Imaging and Communications in Medicine (<b><a href="http://medical.nema.org/">DICOM</a></b>) standard. This package is part of the Rigorous Analytics bundle. <br />
<br />
The latest version of <a href="http://cran.r-project.org/package=oro.dicom"><b>oro.dicom</b></a> (0.2.7) has been released on CRAN. New features include:</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li>Improved handling of tables derived from DICOM headers; dicomTable()</li>
<li>Better validity checking</li>
<li>Fixed issues with swapDimensions()</li>
</ul><div style="font-family: Arial,Helvetica,sans-serif;">Please use the mailing list for any suggestions or contact <a href="mailto:rigorousanalytics@gmail.com">rigorousanalytics@gmail.com</a>. </div>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com18tag:blogger.com,1999:blog-249928374286705859.post-48926193452260267952010-07-06T09:12:00.000+01:002010-07-06T09:12:15.188+01:00oro.nifti 0.2.0The latest version of <a href="http://cran.r-project.org/web/packages/oro.nifti"><b>oro.nifti</b></a> (0.2.0) has been released on CRAN. New features include:<br />
<br />
<ul><li>Reduced overall size of the package by an additional <b>50%</b> </li>
<ul><li>This is a 75% reduction in total from version 0.1.4<b><br />
</b></li>
</ul><li>Four-dimensional acquisitions are now re-oriented and re-sliced appropriately when converting from DICOM to NIfTI</li>
</ul> Please use the mailing list for any suggestions and/or concerns.Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com5tag:blogger.com,1999:blog-249928374286705859.post-5026779787492934792010-07-01T19:30:00.000+01:002010-10-07T08:20:12.668+01:00Call for Papers: Special Issue in JSS for "Magnetic Resonance Imaging in R"We hereby call for the submission of original papers for a Special Issue of the <i>Journal of Statistical Software</i> (JSS - <a href="http://www.jstatsoft.org/" target="_blank">http://www.jstatsoft.org</a>)<br />
<br />
<div style="text-align: center;"><b><span style="font-size: large;">Magnetic Resonance Imaging in R</span></b></div><div style="text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><span style="font-size: large;"> </span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEkweqhelqzXc0ruVP1K8PkZJF6AesNJixlrrrd4Grp8iAn43BqkGSWm2tNRQE4qdK-sNNicsanPy54S2BprmSM6ucl46K6a93ft_y7FSXXDPnVc6qcCwT_cfmXJcr41t45wmc7EBTJM8/s1600/adni002_mprage_image.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEkweqhelqzXc0ruVP1K8PkZJF6AesNJixlrrrd4Grp8iAn43BqkGSWm2tNRQE4qdK-sNNicsanPy54S2BprmSM6ucl46K6a93ft_y7FSXXDPnVc6qcCwT_cfmXJcr41t45wmc7EBTJM8/s320/adni002_mprage_image.png" /></a></div><br />
<br />
planned for Summer 2011. The deadline for submission is <span style="font-size: large;"><b>October 31, 2010</b></span>.<br />
<br />
All MRI modalities are welcome, for example, structural MRI, functional MRI, diffusion tensor or diffusion-weighted imaging, perfusion MRI, pharmacological MRI, and others. Topics of interested include, but are not limited to, <br />
<ul><li> New analysis techniques for MRI data and their implementation.</li>
<li> The implementation of established MRI analysis techniques.</li>
<li> The incorporation of third-party open-source medical imaging software with R.</li>
<li> Data management.</li>
<li> (Semi-)Automated techniques for quality control.</li>
<li> Visualization of medical imaging data and/or modelling results.</li>
</ul>All papers will be subjected to the peer-review process, and must comply with the Guide for Authors; see <a href="http://www.jstatsoft.org/" target="_blank">http://www.jstatsoft.org</a> for more details. Please address any comments or inquiries <b>as well as submission of papers </b>to one of the guest editors below.<br />
<br />
Sincerely,<br />
<br />
Brandon Whitcher and Karsten Tabelow<br />
<br />
<i><b>Guest editors:</b></i><br />
<br />
Brandon Whitcher<br />
GlaxoSmithKline Clinical Imaging Centre<br />
Hammersmith Hospital, Imperial College<br />
London, United Kingdom<br />
<i>email:</i> <a href="mailto:b.whitcher@imperial.ac.uk">b.whitcher@imperial.ac.uk</a><br />
<br />
Karsten Tabelow<br />
Weierstrass Institute for Applied Analysis and Stochastics<br />
Berlin, Germany<br />
<i>email:</i> <a href="mailto:karsten.tabelow@wias-berlin.de">karsten.tabelow@wias-berlin.de</a>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com8tag:blogger.com,1999:blog-249928374286705859.post-60552527378761330312010-06-10T17:13:00.000+01:002010-06-10T17:13:44.786+01:00oro.nifti 0.1.5The latest version of <a href="http://cran.r-project.org/web/packages/oro.nifti"><b>oro.nifti</b></a> (0.1.5) has been released on CRAN. New features include:<br />
<br />
<ul><li>Reduced overall size of the package by <b>50%</b></li>
<li>Minor improvements; for example, the XML package is no longer required as indicated from the DESCRIPTION file</li>
</ul> Please use the mailing list for any suggestions and/or concerns.Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com3tag:blogger.com,1999:blog-249928374286705859.post-84858263975102284402010-06-10T17:06:00.000+01:002010-06-10T17:14:01.794+01:00oro.dicom 0.2.6The latest version of <b><a href="http://cran.r-project.org/web/packages/oro.dicom">oro.dicom</a></b> (0.2.6) has been released on CRAN. New features/improvements include:<br />
<ul><li><b>33%</b> increase in the speed of DICOM file handling</li>
<li>Automatic re-orientation/re-slicing of 3D and 4D volumes when converting from DICOM to NIfTI format</li>
</ul><br />
Work is underway to incorporate the best features across the different DICOM file-handling programs in multiple R packages. It's not standardization, but we're on the right path!Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com5tag:blogger.com,1999:blog-249928374286705859.post-87960359682954486322010-04-10T12:58:00.000+01:002010-04-10T13:26:30.057+01:00Where do you sit? Author position and the h-indexI was recently introduced to the concept of the <a href="http://en.wikipedia.com/wiki/H-index">h-index</a> and was compelled to find out my own h-index via Scopus. Numbers don't matter, but discussion with my colleagues turned to the issue of author position. We quickly decided that there are three important "positions" in the list of authors for a publication: first, last and everywhere else (let's call it the middle). Three-dimensional plots are never easy to deal with, but the concept of the <a href="http://en.wikipedia.com/wiki/Ternary_plot">triangle plot</a> has always stuck in the back of my mind. Armed with this fine plotting mechanism, and the R language, I decided to attack the output from Scopus.<br />
<br />
First things first... here is code to parse the .csv output provided by Scopus and calculate the h-index with a simple plot.<br />
<script class="brush: R" type="syntaxhighlighter">
<![CDATA[
h.index <- function(citations, plot=TRUE,
xlab="papers", ylab="citations", ...) {
citations <- citations[!is.na(citations)]
sc <- sort(citations, decreasing=TRUE)
lsc <- length(sc)
h <- max(which(sc >= 1:lsc))
if (plot) {
plot(1:lsc, sc, xlab=xlab, ylab=ylab, ...)
abline(0, 1, lwd=2, col=2)
abline(v=h, lty=2)
}
return(h)
}
surname <- "whitcher"
fname <- paste("scopus_", surname, ".csv", sep="")
scopus <- read.csv(fname, stringsAsFactors=FALSE)
(h <- h.index(scopus$Cited.by, main="SCOPUS Results for BW"))
[1] 11
]]>
</script><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTincsq3K9gcNGo5AsLrr-gdddNsR9QsCHcHkwzUrmt8ZN18ajwu6YHwsUHTSSZLwDTYPz8BD5NUulmvbXkQm4X_ugCR1z7BJ2kaZpW-M5ushyd8W9zEZknz9Mj59p-E0UX9PoBZfDJvs/s1600/whitcher_hindex.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTincsq3K9gcNGo5AsLrr-gdddNsR9QsCHcHkwzUrmt8ZN18ajwu6YHwsUHTSSZLwDTYPz8BD5NUulmvbXkQm4X_ugCR1z7BJ2kaZpW-M5ushyd8W9zEZknz9Mj59p-E0UX9PoBZfDJvs/s320/whitcher_hindex.png" /></a></div><br />
Now to deal with the authorship position we first parse the author list, determine where the author of interest is located and then convert the three categories into percentages. I have neglected to include the code that explicitly constructs the matrix <span style="font-family: "Courier New",Courier,monospace; font-size: small;">A</span>. Just let <span style="font-family: "Courier New",Courier,monospace;">A = rbind(A, triax.data)</span> to build it up for each author.<br />
<script class="brush: R" type="syntaxhighlighter">
<![CDATA[
pos <- lapply(strsplit(scopus$Authors, ","),
function(x) {
y <- grep("\\.", x, value=TRUE, invert=TRUE)
y <- sub("^[ ]", "", y)
p <- which(y == sub("\\b(\\w)", "\\U\\1", surname, perl=TRUE))
c(p == 1, p != 1 & p != length(y), p != 1 & p == length(y))
})
index <- (! is.na(scopus$Cited.by) & scopus$Cited.by >= h)
data <- data.frame(matrix(unlist(pos), ncol=3, byrow=TRUE)[index,])
names(data) <- paste(c("first", "middle", "last"), "author")
triax.data <- data.frame(t(colSums(data) / nrow(data)))
require("plotrix")
require("RColorBrewer")
triax.plot(A, show.grid=TRUE, col.symbols=brewer.pal(nrow(A),"Set1"),
pch=16, main=paste("SCOPUS Results"))
]]>
</script><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil7fX1lJ0t3SUl94VjfPTu4t08o79uNHs9n0TC0IZpSuj2Ef1C4hCCXiPRf60M_7Q035br2xXb7eIzSt0BLVtsAk2fCv8XYDj_heunU9xS8hAvgwe8mq_LWRhTplQmnpSG0-hVyem_LCU/s1600/cic_triax.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil7fX1lJ0t3SUl94VjfPTu4t08o79uNHs9n0TC0IZpSuj2Ef1C4hCCXiPRf60M_7Q035br2xXb7eIzSt0BLVtsAk2fCv8XYDj_heunU9xS8hAvgwe8mq_LWRhTplQmnpSG0-hVyem_LCU/s320/cic_triax.png" /></a></div>I happen to be the <b style="color: #cc0000;">red</b> dot in the triangle plot, with four of my colleagues also represented. With respect to journals in the field of medical imaging and the like, one would want to have as many first or last author positions as possible and fewer middle positions. First means you did all the work, last means you're the most senior author and (let's face it) nobody cares if you're anywhere else.<br />
<br />
So the question is, where do you sit?Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com39tag:blogger.com,1999:blog-249928374286705859.post-69949389738446231312010-03-24T08:46:00.000+00:002010-03-24T08:46:59.799+00:00oro.nifti 0.1.4The latest release of <a href="http://cran.r-project.org/web/packages/oro.nifti"><b>oro.nifti</b></a> (0.1.4) has been released on CRAN. New features include:<br />
<ul><li>Added text capability in the (unused) fourth pane in orthographic()</li>
<li>A vignette is now included (taken from <a href="http://cran.r-project.org/web/packages/dcemriS4"><b>dcemriS4</b></a>)</li>
</ul>Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com9tag:blogger.com,1999:blog-249928374286705859.post-53942743969895834092010-03-24T08:42:00.000+00:002010-03-24T08:47:58.621+00:00oro.dicom 0.2.5The latest version of <a href="http://cran.r-project.org/web/packages/oro.dicom"><b>oro.dicom</b></a> (0.2.5) has been released on CRAN. New features include:<br />
<ul><li>Added "mosaic" capability when creating 3D arrays from DICOM</li>
<li>dicomTable() now accepts single DICOM file</li>
<li>Better handling of SequenceItem tags when reading in DICOM files </li>
</ul>Work is ongoing to provide 4D array creation for both single-file and mosaic acquisitions.Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com4tag:blogger.com,1999:blog-249928374286705859.post-74189989596807242392010-03-21T23:59:00.000+00:002010-04-10T21:19:46.266+01:00Converting Siemens MOSAICSiemens multi-slice EPI data may be collected as a "mosiac" image; i.e., all slices acquired in a single TR (repitition time) of a functional MRI run are stored in a single DICOM file. The images are stored in an MxN array of images. The function create3D() will try to guess the number of images embedded within the single DICOM file using the AcquisitionMatrix field. If this doesn't work, one may enter the (M,N) doublet explicitly. <br />
<script class="brush: R" type="syntaxhighlighter">
<![CDATA[
> fname <- "MR-sonata-3D-as-Tile.dcm"
> dcm <- dicomInfo(system.file(paste("dcm", fname, sep="/"), package="oro.dicom"))
> dim(dcm$img)
[1] 384 384
> image(t(dcm$img), col=grey(0:64/64), axes=FALSE, xlab="", ylab="")
> dcmImage <- create3D(dcm, mode="integer", mosaic=TRUE)
> dim(dcmImage)
[1] 64 64 36
> dcmNifti <- dicom2nifti(dcmImage, dcm$hdr, datatype=4, aux.file=fname)
> dcmNifti
NIfTI-1 format
Type : niftiAuditTrail
Data Type : 4 (INT16)
Bits per Pixel : 16
Slice Code : 0 (Unknown)
Intent Code : 0 (None)
Qform Code : 0 (Unknown)
Sform Code : 0 (Unknown)
Dimension : 64 x 64 x 36
Pixel Dimension : 3.59 x 3.59 x 4
Voxel Units : mm
Time Units : sec
> descrip(dcmNifti)
[1] "ep2d_BOLD_evntX4"
> aux.file(dcmNifti)
[1] "MR-sonata-3D-as-Tile.dcm"
> image(dcmNifti)
]]>
</script><br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGZJpQ6EvPHhmcvT51KrFDlRsbRJDFTuvBocVxs5FWIWC4cnT6tH6gchs-wZbsjge5T_k9w3dSLAhL_QUu9IKk0RgNvDDlJUfNnXJlEvDhhhAceSBaL6K73TBp7LCwDe24dt2vVdh6PsA/s1600/mosaic_mosaic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGZJpQ6EvPHhmcvT51KrFDlRsbRJDFTuvBocVxs5FWIWC4cnT6tH6gchs-wZbsjge5T_k9w3dSLAhL_QUu9IKk0RgNvDDlJUfNnXJlEvDhhhAceSBaL6K73TBp7LCwDe24dt2vVdh6PsA/s320/mosaic_mosaic.png" /></a></div><br />
The first image is taken from the raw DICOM file, in mosaic format, and displayed with the default margins [(5,4,4,2)+0.1].<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSkkKE2PzEnV-VmAMOPKD6HRKgtyBGcz0rLeVkZxDBt9qQGWv5LiWxb0gVijnSuzPtIGRmkVR3loQ8NWv2uJeeOHm9to7j0z6VPIHcjOwtNQkkhHEYh74nPbWmVrIfNxMANAHgjKGI9Sc/s1600/mosaic_lightbox.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSkkKE2PzEnV-VmAMOPKD6HRKgtyBGcz0rLeVkZxDBt9qQGWv5LiWxb0gVijnSuzPtIGRmkVR3loQ8NWv2uJeeOHm9to7j0z6VPIHcjOwtNQkkhHEYh74nPbWmVrIfNxMANAHgjKGI9Sc/s320/mosaic_lightbox.png" /></a></div><br />
<br />
The second image is displayed after re-organizing the original DICOM file into a 3D array and then converting it to NIfTI format. Additional information, using the valid NIfTI header fields <i>descrip</i> and <i>aux_file</i>, have been defined for these data.<br />
<br />
Remember, all other Siemens DICOM data are stored as a seperate file for each image (as is the case with the other major MR scanner manufacturers).Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com13tag:blogger.com,1999:blog-249928374286705859.post-54932768424719930342010-03-16T13:24:00.000+00:002010-03-16T13:24:16.935+00:00DICOM-to-NIfTI ConversionNow that the two packages <a href="http://cran.r-project.org/web/packages/oro.dicom"><b>oro.dicom</b></a> and <a href="http://cran.r-project.org/web/packages/oro.nifti"><b>oro.nifti</b></a> have been released, we can put them together and perform the much sought after conversion from DICOM format to NIfTI format (entirely in R). Why? Because <a href="http://dicom.nema.org/">DICOM</a> is the international "standard" for medical imaging data coming off the scanners, but it's not the easiest thing to manipulate on a day-to-day basis. NIfTI was developed several years ago in order to provide a more user-friendly format for medical imaging data. <br />
<br />
Let's use the <a href="http://loni.ucla.edu/ADNI">ADNI</a> data that served our purposes before. Here is a sagittal MPRAGE acquisition, the data are read in using dicomSeparate() that takes in an entire directory of DICOM files.<br />
<script class="brush: R" type="syntaxhighlighter">
<![CDATA[
> dcm.path <- "ADNI/002_S_0295/MP-RAGE/2006-11-02_08_16_44.0/S21856"
> ADNI <- dicomSeparate(dcm.path, exclude="xml")
> mprage <- create3D(ADNI, mode="integer")
> pixelSpacing <-
+ header2matrix(extractHeader(ADNI$hdr, "PixelSpacing", FALSE), 2)[1,]
> sliceThickness <- unique(extractHeader(ADNI$hdr, "SliceThickness"))
> pixdim <- c(0, pixelSpacing, sliceThickness, rep(1,4))
> mprage.nifti <- nifti(mprage, datatype=4, pixdim=pixdim)
> mprage.nifti
NIfTI-1 format
Type : niftiAuditTrail
Data Type : 4 (INT16)
Bits per Pixel : 16
Slice Code : 0 (Unknown)
Intent Code : 0 (None)
Qform Code : 0 (Unknown)
Sform Code : 0 (Unknown)
Dimension : 256 x 256 x 166
Pixel Dimension : 0.94 x 0.94 x 1.2
Voxel Units : Unknown
Time Units : Unknown
> image(mprage.nifti)
> orthographic(mprage.nifti)
]]>
</script><br />
The DICOM object is converted into a three-dimensional array using create3D(). Voxel dimensions are obtained from two different DICOM header fields (PixelSpacing and SliceThickness) so this information may be provided to the final DICOM-to-NIfTI conversion into an S4 class. Note, two-byte integers were specified in order to cover the dynamic range of signal intensities of the original MR acquisition.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBEnO7EYHESRfFfz4ZdMbaN6ISP_i4frfG2PmAdO05Hqc91KhYTTAnfo1nffat8J9rPBl2hEX4BYlfjdN7YtJNP0mGsAovEMk_7HBcMTTaHLv_5hRlWPGUdmDegHkTEjowxg5hodD2KAQ/s1600-h/adni002_mprage_lightbox.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBEnO7EYHESRfFfz4ZdMbaN6ISP_i4frfG2PmAdO05Hqc91KhYTTAnfo1nffat8J9rPBl2hEX4BYlfjdN7YtJNP0mGsAovEMk_7HBcMTTaHLv_5hRlWPGUdmDegHkTEjowxg5hodD2KAQ/s320/adni002_mprage_lightbox.png" /></a></div><br />
The first figure provides a "lightbox"perspective of the MPRAGE acquisition, showing all 166 sagittal slices. There are numerous options for the oro.nifti::image() S4 Method. What is shown here uses all the default settings.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_pHQu7Zi9BfM/S56OjlDICRI/AAAAAAAABPk/8nd6nvm-KuY/s1600-h/adni002_mprage_ortho.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/_pHQu7Zi9BfM/S56OjlDICRI/AAAAAAAABPk/8nd6nvm-KuY/s320/adni002_mprage_ortho.png" /></a></div><br />
The second figure provides an "orthographic" representation of the MPRAGE acquisition, showing the mid-axial, mid-coronal and mid-sagittal slices with crosshairs providing a spatial position in each view. Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com8tag:blogger.com,1999:blog-249928374286705859.post-41761463053652943662010-03-05T19:41:00.000+00:002010-03-05T19:41:59.984+00:00oro.nifti 0.1.3The R package <a href="http://cran.r-project.org/web/packages/oro.nifti"><b>oro.nifti</b></a> has been released. Medical imaging data, in NIfTI or Analyze formats, may be input, created from scratch, converted from DICOM (using <a href="http://cran.r-project.org/web/packages/oro.dicom"><b>oro.dicom</b></a>) and output to a file. Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com4tag:blogger.com,1999:blog-249928374286705859.post-1895582082498271412010-02-26T22:45:00.000+00:002010-03-06T22:42:27.269+00:00oro.dicom 0.2.4The R package <a href="http://cran.r-project.org/web/packages/oro.dicom"><b>oro.dicom</b></a> is a major revision, and improvement, on the previous package <a href="http://cran.r-project.org/web/packages/DICOM"><b>DICOM</b></a>. New features include<br />
<ul><li>Increased speed</li>
<li>Uploading only header information (for restricted memory)</li>
<li>Reading implicit value representations (VR's)</li>
<li>Parsing SequenceItem tags (undefined lengths are allowed)</li>
<li>Integration with <a href="http://cran.r-project.org/web/packages/oro.nifti"><b>oro.nifti</b></a> to convert <a href="http://dicom.nema.org/">DICOM</a> to <a href="http://nifti.nimh.nih.gov/">NIfTI</a></li>
</ul>Provided below is a straightforward application of the <a href="http://cran.r-project.org/web/packages/oro.dicom"><b>oro.dicom</b></a> package to an example data set from the <a href="http://www.loni.ucla.edu/ADNI/">ADNI</a> (Alzheimer's Disease Neuroimaging Initiative).<br />
<script class="brush: R" type="syntaxhighlighter">
<![CDATA[
> dcm.path <- "ADNI/002_S_0295/MP-RAGE/2006-11-02_08_16_44.0/S21856"
> ADNI <- dicomSeparate(dcm.path, exclude="xml")
> names(ADNI)
[1] "hdr" "img"
> dim(ADNI$hdr[[1]])
[1] 312 7
> unique(extractHeader(ADNI$hdr, "SeriesDescription", FALSE))
[1] "MP-RAGE"
> unique(extractHeader(ADNI$hdr, "SeriesInstanceUID", FALSE))
[1] "2.16.124.113543.6006.99.6140400899638574745"
> mprage <- create3D(ADNI, mode="integer")
> dim(mprage)
[1] 256 256 166
> pixelSpacing <-
+ header2matrix(extractHeader(ADNI$hdr, "PixelSpacing", FALSE), 2)[1,]
> sliceThickness <- unique(extractHeader(ADNI$hdr, "SliceThickness"))
> c(pixelSpacing, sliceThickness)
[1] 0.9375 0.9375 1.2000
> par(mar=rep(0,4))
> image(mprage[,,166/2], col=grey(0:64/64), xlab="", ylab="", axes=FALSE)
]]>
</script><br />
The list object from reading all 166 DICOM files has two fields: header and image. Each <i>hdr</i> element contains the DICOM header fields associated with that file and the corresponding <i>img</i> element contains the PixelData tag. The first DICOM file contains 312 DICOM header fields. Using extractHeader() one can obtain the value of a DICOM header field in either text or numeric format.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Eccb1zQ6lY1XEV83bG0eNcbiLVVp3Ovn4TIiasnu8DuKIfgf2XOCYorB2ADkuUAhdipnoxwTftDg84ElB3KX0SDbjEXA21HzI-x6IVDTNiTEFX1JEORz8qdqx5JW8FgfBJwP-191YR4/s1600-h/adni002_mprage_image.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Eccb1zQ6lY1XEV83bG0eNcbiLVVp3Ovn4TIiasnu8DuKIfgf2XOCYorB2ADkuUAhdipnoxwTftDg84ElB3KX0SDbjEXA21HzI-x6IVDTNiTEFX1JEORz8qdqx5JW8FgfBJwP-191YR4/s320/adni002_mprage_image.png" /></a></div><br />
The image above is the mid-sagittal view of this subject from his/her <a href="http://radiology.rsna.org/content/182/3/769.abstract">MPRAGE</a> acquisition.Anonymoushttp://www.blogger.com/profile/12511295653932239187noreply@blogger.com3