<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://974/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>We have a python example for this filter it should be a good starting point:</div><div><br></div><div><a href="http://www.itk.org/SimpleITKDoxygen/html/N4BiasFieldCorrection_8py-example.html">http://www.itk.org/SimpleITKDoxygen/html/N4BiasFieldCorrection_8py-example.html</a></div><div><br></div><div>To change the image type you simply need to use the CastImageFilter.</div><div><br></div><div>Also if you want to look at what image types a filter works with look at the PixelIDTypeList defined for that filter in the Doxygen:</div><div><br></div><div><a href="http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1N4BiasFieldCorrectionImageFilter.html#a56b78dd41836a5fce343fef10a65d848">http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1N4BiasFieldCorrectionImageFilter.html#a56b78dd41836a5fce343fef10a65d848</a></div><div><br></div><div>I have had quite a few discussions recently, about how to improve this error message. What would you have liked to see?</div><div><br></div><div>Brad</div><div><br><div><div>On Apr 4, 2013, at 6:17 PM, "Becksfort, Jared" &lt;<a href="mailto:Jared.Becksfort@STJUDE.ORG">Jared.Becksfort@STJUDE.ORG</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Hello,<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">This is a question regarding the Java version of SimpleITK.&nbsp; I downloaded some .mha files from the BRATS segmentation challenge and can’t seem to get the bias field correction using N4BiasFieldCorrectionImageFilter to work.&nbsp;<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">I get this error when running a downloaded image and when running a .tif file too:<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Consolas; color: red; ">Exception in thread "main"<span class="Apple-converted-space">&nbsp;</span></span><u><span style="font-size: 10pt; font-family: Consolas; color: navy; ">java.lang.RuntimeException</span></u><span style="font-size: 10pt; 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: 10pt; font-family: Consolas; "><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; 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: 10pt; font-family: Consolas; "><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Consolas; color: red; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.itk.simple.SimpleITKJNI.N4BiasFieldCorrectionImageFilter_execute__SWIG_0(</span><u><span style="font-size: 10pt; font-family: Consolas; color: navy; ">Native Method</span></u><span style="font-size: 10pt; font-family: Consolas; color: red; ">)</span><span style="font-size: 10pt; font-family: Consolas; "><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Consolas; color: red; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.itk.simple.N4BiasFieldCorrectionImageFilter.execute(</span><u><span style="font-size: 10pt; font-family: Consolas; color: navy; ">N4BiasFieldCorrectionImageFilter.java:124</span></u><span style="font-size: 10pt; font-family: Consolas; color: red; ">)</span><span style="font-size: 10pt; font-family: Consolas; "><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Consolas; color: red; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at utility.BiasCorrectionTest.main(</span><u><span style="font-size: 10pt; font-family: Consolas; color: navy; ">BiasCorrectionTest.java:19</span></u><span style="font-size: 10pt; font-family: Consolas; color: red; ">)</span><span style="font-size: 10pt; font-family: Consolas; "><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Consolas; color: red; ">&nbsp;</span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Does anyone know if I am doing something wrong or if there is a problem with the class in Java?&nbsp; 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.&nbsp; I don’t know that they were using the Java version though.&nbsp; I haven’t tried converting it to another data type yet because…well I don’t know how.&nbsp; I will look into that, but I figure it is something else that I am doing wrong.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">The code is below.&nbsp; Images can be downloaded from here in case someone wants to go to the trouble of actually doing so.&nbsp; Hopefully it is just me doing something stupid and quick for someone to point out.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><a href="http://challenge.kitware.com/midas/folder/102" style="color: purple; text-decoration: underline; ">http://challenge.kitware.com/midas/folder/102</a><o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Thanks!<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Jared<o:p></o:p></div><div style="border-style: none none solid; border-bottom-width: 1pt; border-bottom-color: windowtext; padding: 0in 0in 1pt; "><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; border: none; padding: 0in; "><o:p>&nbsp;</o:p></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">package utility;<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">import org.itk.simple.Image;<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">import org.itk.simple.SimpleITK;<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">import org.itk.simple.N4BiasFieldCorrectionImageFilter;<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">public class BiasCorrectionTest {<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp; /**<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp; * @param args<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp; */<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp; public static void main(String[] args) {<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p>&nbsp;</o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String inFilename = "BRATS_HG0004_T1.mha";<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String outFilename = "biasTestOut_4_T1.mha";<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Image image = SimpleITK.readImage(inFilename);<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Image corrected = new Image(image);<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; N4BiasFieldCorrectionImageFilter correcter = new N4BiasFieldCorrectionImageFilter();<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; correcter.execute(image, corrected);&nbsp; // The error happens here<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SimpleITK.writeImage(corrected, outFilename);<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">&nbsp;&nbsp;&nbsp; }<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">}<o:p></o:p></div></div><br><hr><font face="Arial" color="Gray" size="2">Email Disclaimer:<span class="Apple-converted-space">&nbsp;</span><a href="http://www.stjude.org/emaildisclaimer" style="color: purple; text-decoration: underline; ">www.stjude.org/emaildisclaimer</a><br>Consultation Disclaimer:<span class="Apple-converted-space">&nbsp;</span><a href="http://www.stjude.org/consultationdisclaimer" style="color: purple; text-decoration: underline; ">www.stjude.org/consultationdisclaimer</a><br></font>_____________________________________<br>Powered by<span class="Apple-converted-space">&nbsp;</span><a href="http://www.kitware.com" style="color: purple; text-decoration: underline; ">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" style="color: purple; text-decoration: underline; ">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php" style="color: purple; text-decoration: underline; ">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br><a href="http://www.itk.org/Wiki/ITK_FAQ" style="color: purple; text-decoration: underline; ">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-users" style="color: purple; text-decoration: underline; ">http://www.itk.org/mailman/listinfo/insight-users</a></div></blockquote></div><br></div></body></html>