<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thank you very much for this, Kris. &nbsp;I can work around the anisotropy.<div>I just really appreciate the insight regarding the implications of such&nbsp;</div><div>data. &nbsp;I'll take a look at the patch tonight or tomorrow.</div><div><br></div><div>Thanks again,</div><div>Nick</div><div><br><div><br></div><div><br><div><div>On Dec 10, 2012, at 5:07 PM, Kris Zygmunt &lt;<a href="mailto:krismz@sci.utah.edu">krismz@sci.utah.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Nick,<div>&nbsp; &nbsp;Your patch had been abandoned, so I created a new patch that addresses all of the issues mentioned below. &nbsp;It can be found at&nbsp;<a href="http://review.source.kitware.com/#/c/8833/" target="_blank">http://review.source.kitware.com/#/c/</a>8874 . &nbsp;The only thing I am still concerned about with the weights is your large spacing anisotropy where your image is [1.95, 1.95, 10]. &nbsp;In this case, instead of a 9x9x9 patch for the isotropic case, you will end up with a patch that is 43x43x9 which will make all of the processing much slower. &nbsp;I'm not sure how it would be best for the denoising filter to support this much anisotropy.</div><div>-Kris</div><div><br></div><div><br><div><div>On Dec 7, 2012, at 4:09 AM, Nicholas Tustison wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks Suyash.<div><br><div><div>On Dec 6, 2012, at 11:23 PM, Suyash P. Awate &lt;<a href="mailto:suyash@sci.utah.edu">suyash@sci.utah.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>Hi folks,<br><br>I've discussed this with Kris this afternoon and this needs a small fix in the way weights are being handled for anisotropic voxel sizes and in dimensions higher than 2.<br><div class="gmail_extra"> <br clear="all"> <br>Regards,<br>Suyash<br> <br><br><div class="gmail_quote">On Thu, Dec 6, 2012 at 4:02 PM, Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "> Hi Kris,<br> <br> You're right. &nbsp;If I change the image spacing to be isotropic, I get<br> past the error which is great. &nbsp;I'm assuming we'll just see what<br> Suyash says. &nbsp;Thanks for looking into this.<br> <br> Nick<br> <div><br> <br> On Dec 6, 2012, at 5:24 PM, Kris Zygmunt &lt;<a href="mailto:krismz@sci.utah.edu" target="_blank">krismz@sci.utah.edu</a>&gt; wrote:<br> <br> &gt; Ok, there are 2 problems going on. &nbsp;The first is that the patch weights are not appropriately 3D sphere. &nbsp;The second is that the resampling of the patch weights results in a max patch weight &lt; 1 for non-integer resampling values. &nbsp;But I think the resampling should really be reconsidered a bit more. &nbsp;If the image spacing is 0.5,0.5,0.5 I'm not sure that resampling really needs to happen. &nbsp;The point is really to make the patch weights capture the relative anisotropy. &nbsp;Thus if the image spacing is 1,1,0.5 then maybe in that case it makes sense to resample the patch weights in the z direction to cover the same amount of physical space. &nbsp;I'm including Suyash on this message to see what he thinks is the best way to handle this.<br> &gt;<br> &gt; I haven't looked at your code changes yet, as I first wanted to understand better what was happening. &nbsp;I'll take a look there next.<br> &gt;<br> &gt; -Kris<br> &gt;<br> &gt; On Dec 6, 2012, at 12:24 PM, Nicholas Tustison wrote:<br> &gt;<br> &gt;&gt; Thanks Kris and Brad for your responses. &nbsp;Since it's easier to<br> &gt;&gt; look at code, I thought I'd post the changes I had to make.<br> &gt;&gt;<br> &gt;&gt; <a href="http://review.source.kitware.com/#/c/8833/" target="_blank">http://review.source.kitware.com/#/c/8833/</a><br> &gt;&gt;<br> &gt;&gt; Kris, if I read the code correctly, it seems to me that the physical<br> &gt;&gt; weighting image shouldn't be affected at all by anisotropic voxels<br> &gt;&gt; in the input image. &nbsp;Am I reading that right? &nbsp;The size of the physical<br> &gt;&gt; weighting image seems only affected by the patch radius with<br> &gt;&gt; isotropic spacing equal to 1. &nbsp;When I write that image to disk using<br> &gt;&gt; my patch, I get an isotropic weighting distance function. &nbsp;Otherwise<br> &gt;&gt; I get a flat disk where the weighting in the z? direction seems to be<br> &gt;&gt; close to 0. &nbsp;Before we get to the issue that both Brad and I are<br> &gt;&gt; having of the thrown exception, perhaps we can clarify this issue.<br> &gt;&gt; Is that okay?<br> &gt;&gt;<br> &gt;&gt; Thanks again for your help with this, Kris,<br> &gt;&gt;<br> &gt;&gt; Nick<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt;<br> &gt;&gt; On Dec 6, 2012, at 1:08 PM, Bradley Lowekamp &lt;<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>&gt; wrote:<br> &gt;&gt;<br> &gt;&gt;&gt; Nick,<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; I just ran into this problem too this morning. I am glad you looked into the problem further than I did.<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; I was wrapping it for SimpleITK. I was setting up the filter with the defaults matching:<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; <a href="http://review.source.kitware.com/#/c/8803/1/Code/BasicFilters/json/PatchBasedDenoisingImageFilter.json" target="_blank">http://review.source.kitware.com/#/c/8803/1/Code/BasicFilters/json/PatchBasedDenoisingImageFilter.json</a><br> &gt;&gt;&gt;<br> &gt;&gt;&gt; And I was testing it with the following 3D image:<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; <a href="http://itk.org/gitweb?p=SimpleITKData.git;a=blob;f=Input/RA-Short.nrrd;h=fca085049470a826324a4f2c93af2fd65fbaed52;hb=HEAD" target="_blank">http://itk.org/gitweb?p=SimpleITKData.git;a=blob;f=Input/RA-Short.nrrd;h=fca085049470a826324a4f2c93af2fd65fbaed52;hb=HEAD</a><br> &gt;&gt;&gt;<br> &gt;&gt;&gt; With the following meta information:<br> &gt;&gt;&gt; Size: [64, 64, 64]<br> &gt;&gt;&gt; Spacing: [0.755874, 0.755874, 0.755874]<br> &gt;&gt;&gt; Origin: [0.283453, 0.283453, 0.283453]<br> &gt;&gt;&gt; Direction:<br> &gt;&gt;&gt; 1 0 0<br> &gt;&gt;&gt; 0 1 0<br> &gt;&gt;&gt; 0 0 1<br> &gt;&gt;&gt;<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; I get the same error with the defaults as you did, when I run the filter with the defaults<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; And then if I change the patchRadius:<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; python: sitk.PatchBasedDenoising( img, patchRadius=8 )<br> &gt;&gt;&gt; ---------------------------------------------------------------------------<br> &gt;&gt;&gt; RuntimeError &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Traceback (most recent call last)<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; /home/blowekamp/src/SimpleITK/Testing/Data/Input/&lt;ipython console&gt; in &lt;module&gt;()<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; /home/blowekamp/build/SimpleITK/SimpleITK-build/Wrapping/SimpleITK.pyc in PatchBasedDenoising(*args, **kwargs)<br> &gt;&gt;&gt; 5767 &nbsp; &nbsp; &nbsp; &nbsp; double fractionPixelsForSigmaUpdate=1.0) -&gt; Image<br> &gt;&gt;&gt; 5768 &nbsp; &nbsp; """<br> &gt;&gt;&gt; -&gt; 5769 &nbsp; return _SimpleITK.PatchBasedDenoising(*args, **kwargs)<br> &gt;&gt;&gt; 5770 class MaximumProjectionImageFilter(_object):<br> &gt;&gt;&gt; 5771 &nbsp; &nbsp; """<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; RuntimeError: Exception thrown in SimpleITK PatchBasedDenoising: /home/blowekamp/build/SimpleITK/ITK-prefix/include/ITK-4.3/itkPatchBasedDenoisingImageFilter.hxx:641:<br> &gt;&gt;&gt; itk::ERROR: PatchBasedDenoisingImageFilter(0x3086ee0): Center pixel's weight (0.685381) must be equal to 1.0<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; Thanks,<br> &gt;&gt;&gt; Brad<br> &gt;&gt;&gt;<br> &gt;&gt;&gt; On Dec 6, 2012, at 12:07 PM, Nicholas Tustison &lt;<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>&gt; wrote:<br> &gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Hi Kris,<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Today I finally got a chance to look at your denoising work (I'm ashamed<br> &gt;&gt;&gt;&gt; that I was at Penn for with Suyash for some time but I never asked him<br> &gt;&gt;&gt;&gt; about it). &nbsp;Anyway, I have a couple questions and I was hoping you could<br> &gt;&gt;&gt;&gt; help me try to run your denoising work on some of my MRI. &nbsp; I took the test<br> &gt;&gt;&gt;&gt; that you wrote and modified it only so that I could use it as a stand-alone<br> &gt;&gt;&gt;&gt; program. &nbsp;I also verified that my version worked with the test images.<br> &gt;&gt;&gt;&gt; However, when I tried to use it on my image (stats below)<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Image information<br> &gt;&gt;&gt;&gt; Size: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[256, 256, 20]<br> &gt;&gt;&gt;&gt; Origin: &nbsp; &nbsp; &nbsp; &nbsp;[-232.879, -135.656, 240.706]<br> &gt;&gt;&gt;&gt; SpatialExtent: [498.047, 498.047, 190]<br> &gt;&gt;&gt;&gt; Center: &nbsp; &nbsp; &nbsp; &nbsp;[16.1448, 113.368, 335.706]<br> &gt;&gt;&gt;&gt; Spacing: &nbsp; &nbsp; &nbsp; [1.95312, 1.95312, 10]<br> &gt;&gt;&gt;&gt; Index: &nbsp; &nbsp; &nbsp; &nbsp; [0, 0, 0]<br> &gt;&gt;&gt;&gt; Direction:<br> &gt;&gt;&gt;&gt; 1 0 0<br> &gt;&gt;&gt;&gt; 0 1 0<br> &gt;&gt;&gt;&gt; 0 0 1<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; using the following parameters<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; patchRadius = 4<br> &gt;&gt;&gt;&gt; noiseModel = gaussian<br> &gt;&gt;&gt;&gt; fidelityWeight = 0.0<br> &gt;&gt;&gt;&gt; numberOfIterations = 1<br> &gt;&gt;&gt;&gt; sigmaMultiplicationFactor = 2<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; it gave me the following error<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Line: 634<br> &gt;&gt;&gt;&gt; Description: itk::ERROR: PatchBasedDenoisingImageFilter(0x7fbffb0f5e10): Center pixel's weight (0) must be equal to 1.0<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; After investigating this section of the code, I noticed that the physicalWeightsImage<br> &gt;&gt;&gt;&gt; (after writing it to an image file) consists of what looked like a weighted 2-D disc.<br> &gt;&gt;&gt;&gt; Based on my reading of the comments, should this be more of a 3-D weighted sphere?<br> &gt;&gt;&gt;&gt; If so, I made some changes in the code to actually get a weighted sphere thinking<br> &gt;&gt;&gt;&gt; that might be solve the problem but I still got the same error. &nbsp;However, if I increase<br> &gt;&gt;&gt;&gt; the radius to 8, it seems to get past that error without issue. &nbsp;Is there a general rule<br> &gt;&gt;&gt;&gt; for determining a minimal radius for this filter?<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Thanks for your help,<br> &gt;&gt;&gt;&gt; Nick<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; _______________________________________________<br> &gt;&gt;&gt;&gt; Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Visit other Kitware open-source projects at<br> &gt;&gt;&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Kitware offers ITK Training Courses, for more information visit:<br> &gt;&gt;&gt;&gt; <a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Please keep messages on-topic and check the ITK FAQ at:<br> &gt;&gt;&gt;&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br> &gt;&gt;&gt;&gt;<br> &gt;&gt;&gt;&gt; Follow this link to subscribe/unsubscribe:<br> &gt;&gt;&gt;&gt; <a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br> &gt;&gt;&gt;<br> &gt;&gt;<br> &gt;<br> <br> </div></blockquote></div><br></div> </blockquote></div><br></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></body></html>