<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This is a question regarding the Java version of SimpleITK. I downloaded some .mha files from the BRATS segmentation challenge and can’t seem to get the bias field correction using N4BiasFieldCorrectionImageFilter to work.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I get this error when running a downloaded image and when running a .tif file too:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:red">Exception in thread "main"
</span><u><span style="font-size:10.0pt;font-family:Consolas;color:navy">java.lang.RuntimeException</span></u><span style="font-size:10.0pt;font-family:Consolas;color:red">: Exception thrown in SimpleITK N4BiasFieldCorrectionImageFilter_execute: c:\d\vs9-release\simpleitk\code\common\include\sitkDualMemberFunctionFactory.hxx:201:</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:red">sitk::ERROR: Pixel type: 16-bit signed integer is not supported in 3D byclass itk::simple::N4BiasFieldCorrectionImageFilter</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:red"> at org.itk.simple.SimpleITKJNI.N4BiasFieldCorrectionImageFilter_execute__SWIG_0(</span><u><span style="font-size:10.0pt;font-family:Consolas;color:navy">Native
Method</span></u><span style="font-size:10.0pt;font-family:Consolas;color:red">)</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:red"> at org.itk.simple.N4BiasFieldCorrectionImageFilter.execute(</span><u><span style="font-size:10.0pt;font-family:Consolas;color:navy">N4BiasFieldCorrectionImageFilter.java:124</span></u><span style="font-size:10.0pt;font-family:Consolas;color:red">)</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:red"> at utility.BiasCorrectionTest.main(</span><u><span style="font-size:10.0pt;font-family:Consolas;color:navy">BiasCorrectionTest.java:19</span></u><span style="font-size:10.0pt;font-family:Consolas;color:red">)</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;color:red"><o:p> </o:p></span></p>
<p class="MsoNormal">Does anyone know if I am doing something wrong or if there is a problem with the class in Java? I am fairly sure that it can handle 16-bit images normally because a number of people have used it in their publications that use BRATS data.
I don’t know that they were using the Java version though. I haven’t tried converting it to another data type yet because…well I don’t know how. I will look into that, but I figure it is something else that I am doing wrong.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The code is below. Images can be downloaded from here in case someone wants to go to the trouble of actually doing so. Hopefully it is just me doing something stupid and quick for someone to point out.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a href="http://challenge.kitware.com/midas/folder/102">http://challenge.kitware.com/midas/folder/102</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
<p class="MsoNormal">Jared<o:p></o:p></p>
<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0in 0in 1.0pt 0in">
<p class="MsoNormal" style="border:none;padding:0in"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">package utility;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">import org.itk.simple.Image;<o:p></o:p></p>
<p class="MsoNormal">import org.itk.simple.SimpleITK;<o:p></o:p></p>
<p class="MsoNormal">import org.itk.simple.N4BiasFieldCorrectionImageFilter;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">public class BiasCorrectionTest {<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> /**<o:p></o:p></p>
<p class="MsoNormal"> * @param args<o:p></o:p></p>
<p class="MsoNormal"> */<o:p></o:p></p>
<p class="MsoNormal"> public static void main(String[] args) {<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> String inFilename = "BRATS_HG0004_T1.mha";<o:p></o:p></p>
<p class="MsoNormal"> String outFilename = "biasTestOut_4_T1.mha";<o:p></o:p></p>
<p class="MsoNormal"> Image image = SimpleITK.readImage(inFilename);<o:p></o:p></p>
<p class="MsoNormal"> Image corrected = new Image(image);<o:p></o:p></p>
<p class="MsoNormal"> N4BiasFieldCorrectionImageFilter correcter = new N4BiasFieldCorrectionImageFilter();<o:p></o:p></p>
<p class="MsoNormal"> correcter.execute(image, corrected); // The error happens here<o:p></o:p></p>
<p class="MsoNormal"> SimpleITK.writeImage(corrected, outFilename);<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="2">Email Disclaimer: www.stjude.org/emaildisclaimer<br>
Consultation Disclaimer: www.stjude.org/consultationdisclaimer<br>
</font>
</body>
</html>