<div dir="ltr">I was testing different aproaches and I always get nothing less than 2800, how many images does the volume have?</div><br><div class="gmail_quote"><div dir="ltr">El jue., 19 de nov. de 2015 a la(s) 5:47 a. m., Luigi Riba <<a href="mailto:ribaluigi@gmail.com">ribaluigi@gmail.com</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all, <div><br></div><div>thanks for the continuous support.</div><div><br></div><div>I am gonna try with the BinShrinkImageFilter. </div><div><br></div><div>By the way, I guess that I am overlooking something in double to float code conversion. In fact, I have made this change on the ITK ImageRegistration1 example obtaining the same memory results.</div><div>I am on Windows 7, 64 bit, Visual Studio Express 12 (2013), ITK built in release mode with MT flags. I will be pleased if you could give a look at this piece of code.</div><div><br></div><div>I have attached at this mail:</div><div>ImageRegistration1Double: exactly the same as ImageRegistration1, with MemoryProbe added;<br></div><div>ImageRegistration1Float: MemoryProbe added and changed double to float in registration blocks;</div><div>BrainProton.....png a pair of test images;</div><div>Results....png a screenshot of the results in both cases.</div><div><br></div><div>Have a nice day,</div><div><br></div><div>Luigi</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-18 22:50 GMT+01:00 Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Luigi,<br>
<br>
It may be prudent to downsample the images using something like the<br>
BinShrinkImageFilter. Often, the full-resolution is overkill for the<br>
registration task.<br>
<br>
HTH,<br>
Matt<br>
<div><div><br>
On Wed, Nov 18, 2015 at 1:21 PM, Matias Montroull <<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>> wrote:<br>
> Luigi, I assume you are workimg on release mode right?<br>
> Would you be able to send the cpp file that you are compiling to test?<br>
><br>
> Matias<br>
><br>
> On Nov 18, 2015 7:53 AM, "Luigi Riba" <<a href="mailto:ribaluigi@gmail.com" target="_blank">ribaluigi@gmail.com</a>> wrote:<br>
>><br>
>> Dear all,<br>
>><br>
>> I have tried your suggestions and I have simplified my code.<br>
>> Unfortunately, I still have some issues:<br>
>><br>
>> 1. I cannot read the two images as unsigned short. If I do like this,<br>
>> VisualStudio compiler returns:<br>
>> Error 2 error C2440: 'initializing' : cannot convert from<br>
>> 'itk::Concept::Detail::UniqueType_bool<false>' to<br>
>> 'itk::Concept::Detail::UniqueType_bool<true>'<br>
>> f:\libs\itk\modules\core\common\include\itkConceptChecking.h 796 1 affine3d<br>
>><br>
>> 2. I have decided to read the images directly in float;<br>
>><br>
>> 3. I have set everything to float but I have noticed no memory usage<br>
>> differences between the "dobule" and "float" code. In particular, I have<br>
>> set:<br>
>>><br>
>>> typedef float InternalComputationValueType;<br>
>>> typedef itk::AffineTransform< InternalComputationValueType, Dimension><br>
>>> TransformType;<br>
>>> typedef<br>
>>> itk::RegularStepGradientDescentOptimizerv4<InternalComputationValueType><br>
>>> OptimizerType;<br>
>>> typedef itk::MeanSquaresImageToImageMetricv4<ImageType, ImageType,<br>
>>> ImageType, InternalComputationValueType> MetricType;<br>
>>> typedef itk::ImageRegistrationMethodv4<ImageType, ImageType,<br>
>>> TransformType> RegistrationType;<br>
>>> typedef float CoordinateType;<br>
>>> typedef itk::LinearInterpolateImageFunction<ImageType, CoordinateType><br>
>>> InterpolationType;<br>
>><br>
>><br>
>> RECAP:<br>
>> 1. I would like to reduce the memory usage of my registration code. In<br>
>> fact, I work with unsigned short, i.e. 16 bit grayscale images, ~1Gb each<br>
>> and memory usage gets high pretty soon (750MB images -> ~30GB total memory<br>
>> usage)<br>
>> 2. It has been suggested to set the algorithm to work with float instead<br>
>> of double;<br>
>> 3. How can I accomplish point 2.?<br>
>> 4. Is point 2. the only viable solution in order to reduce memory usage?<br>
>> 5 Is there a way to have a finer monitoring of memory usage. For the<br>
>> moment I am using itkMemoryProbe which just gives me the total amount of<br>
>> used memory.<br>
>><br>
>> Thank you for your kind support,<br>
>> Luigi<br>
>><br>
>><br>
>> 2015-11-16 16:55 GMT+01:00 Luigi Riba <<a href="mailto:ribaluigi@gmail.com" target="_blank">ribaluigi@gmail.com</a>>:<br>
>>><br>
>>> Dear Dženan and Matias,<br>
>>><br>
>>> thank you very much for the help.<br>
>>><br>
>>> I'll test your suggestion and I'll post back the results for the<br>
>>> community.<br>
>>><br>
>>> Best,<br>
>>><br>
>>> Luigi<br>
>>><br>
>>> 2015-11-16 16:53 GMT+01:00 Matias Montroull <<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>>:<br>
>>>><br>
>>>> That was my assumption Luigi<br>
>>>><br>
>>>> El lun., 16 de nov. de 2015 a la(s) 12:30 p. m., Dženan Zukić<br>
>>>> <<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>> escribió:<br>
>>>>><br>
>>>>> I believe Matias thought that your original pixel type was signed<br>
>>>>> short.<br>
>>>>><br>
>>>>> So just use the images you read as unsigned short (set them as input to<br>
>>>>> the registration), and don't make another copy of the images by casting them<br>
>>>>> to float.<br>
>>>>><br>
>>>>> HTH<br>
>>>>><br>
>>>>> On Mon, Nov 16, 2015 at 10:17 AM, Luigi Riba <<a href="mailto:ribaluigi@gmail.com" target="_blank">ribaluigi@gmail.com</a>><br>
>>>>> wrote:<br>
>>>>>><br>
>>>>>> Dear Matias,<br>
>>>>>><br>
>>>>>> thank you very much for your quick reply.<br>
>>>>>><br>
>>>>>> Unfortunately, I didn't have time yet to test it. Anyhow, could you<br>
>>>>>> please tell me the rationale behind it?<br>
>>>>>><br>
>>>>>> In my code:<br>
>>>>>><br>
>>>>>> I read two grayscale 16 bit .mhd images. To read them I define the<br>
>>>>>> IOPixelTyep as unsigned short;<br>
>>>>>> I cast them to the "operational" type called PixelType as float<br>
>>>>>> I define all the registration objects templated on float.<br>
>>>>>><br>
>>>>>> Why should I cast my images to PixelType == signed short?<br>
>>>>>><br>
>>>>>> Thanks in advance for the support,<br>
>>>>>> Luigi<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> 2015-11-10 15:45 GMT+01:00 Matias Montroull <<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>>:<br>
>>>>>>><br>
>>>>>>> try this:<br>
>>>>>>> typedef signed short PixelType;<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> El mar., 10 de nov. de 2015 a la(s) 11:36 a. m., Luigi Riba<br>
>>>>>>> <<a href="mailto:ribaluigi@gmail.com" target="_blank">ribaluigi@gmail.com</a>> escribió:<br>
>>>>>>>><br>
>>>>>>>> Dear Matt,<br>
>>>>>>>><br>
>>>>>>>> I have tried following your suggestion but, unfortunately, it didn't<br>
>>>>>>>> work out.<br>
>>>>>>>><br>
>>>>>>>> In particular:<br>
>>>>>>>><br>
>>>>>>>> I read a pair of uint16 images;<br>
>>>>>>>> I cast them to float pixel type via the CastImageFilter;<br>
>>>>>>>> I change the TInternalComputationValueType for the metric, the<br>
>>>>>>>> optimizer, the transform and the registration doing something like:<br>
>>>>>>>>><br>
>>>>>>>>> const unsigned int Dimension = 3;<br>
>>>>>>>>><br>
>>>>>>>>> typedef float PixelType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef unsigned short IOPixelType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::Image<IOPixelType, Dimension> IOImageType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::Image<PixelType, Dimension> ImageType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::AffineTransform<float, Dimension > TransformType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::RegularStepGradientDescentOptimizerv4<float><br>
>>>>>>>>> OptimizerType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::MeanSquaresImageToImageMetricv4<ImageType,<br>
>>>>>>>>> ImageType,ImageType,float> MetricType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::ImageRegistrationMethodv4<ImageType, ImageType,<br>
>>>>>>>>> TransformType> RegistrationType;<br>
>>>>>>>>><br>
>>>>>>>>> typedef itk::ResampleImageFilter<IOImageType, IOImageType,<br>
>>>>>>>>> float,float> ResampleFilterType;<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> I have put one memory probe before the registration procedure and<br>
>>>>>>>> one afterwards of it. In the "double" case and in the "float" case I've seen<br>
>>>>>>>> the same memory consumption.<br>
>>>>>>>><br>
>>>>>>>> Am I missing something? Are there other things I should change in my<br>
>>>>>>>> code?<br>
>>>>>>>><br>
>>>>>>>> Thanks again for the support,<br>
>>>>>>>> Luigi<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> 2015-11-09 17:23 GMT+01:00 Matt McCormick<br>
>>>>>>>> <<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>>:<br>
>>>>>>>>><br>
>>>>>>>>> Hi Luigi,<br>
>>>>>>>>><br>
>>>>>>>>> The type of optimizer should not have too large of an impact on<br>
>>>>>>>>> memory<br>
>>>>>>>>> consumption. Using a gradient-free optimizer may help slightly,<br>
>>>>>>>>> but<br>
>>>>>>>>> try changing the pixel type of the input images or, if possible,<br>
>>>>>>>>> the<br>
>>>>>>>>> parameter type of the transformation, from double to float.<br>
>>>>>>>>><br>
>>>>>>>>> HTH,<br>
>>>>>>>>> Matt<br>
>>>>>>>>><br>
>>>>>>>>> On Mon, Nov 9, 2015 at 10:24 AM, Luigi Riba <<a href="mailto:ribaluigi@gmail.com" target="_blank">ribaluigi@gmail.com</a>><br>
>>>>>>>>> wrote:<br>
>>>>>>>>> > Dear all,<br>
>>>>>>>>> ><br>
>>>>>>>>> > I am registering a couple of volumes with ITK 4 on windows 7 64<br>
>>>>>>>>> > bit.<br>
>>>>>>>>> ><br>
>>>>>>>>> > I wrote a code based on the affine transformation, with the mean<br>
>>>>>>>>> > square<br>
>>>>>>>>> > error metric and the RegularStepGradientDescentOptimizerv4.<br>
>>>>>>>>> > Unfortunately,<br>
>>>>>>>>> > the memory usage is pretty high.<br>
>>>>>>>>> ><br>
>>>>>>>>> > I have checked memory consumption with the itkMemoryProbe and,<br>
>>>>>>>>> > after looking<br>
>>>>>>>>> > around on previous mailing list messages I have decided to try<br>
>>>>>>>>> > with a<br>
>>>>>>>>> > gradient free optimizer like the Nelder-Mead one.<br>
>>>>>>>>> ><br>
>>>>>>>>> > So I have rewrote the code using the AmoebaOptimizerV4 and I have<br>
>>>>>>>>> > continued<br>
>>>>>>>>> > monitoring the memory consumption via MemoryProbe. Unfortunately,<br>
>>>>>>>>> > it seems<br>
>>>>>>>>> > that nothing has changed. Is this working as expected? If this is<br>
>>>>>>>>> > the case,<br>
>>>>>>>>> > do you have any suggestion to gave me in order to reduce the<br>
>>>>>>>>> > memory<br>
>>>>>>>>> > consumption of the code?<br>
>>>>>>>>> ><br>
>>>>>>>>> > Thanks in advance for the help.<br>
>>>>>>>>> ><br>
>>>>>>>>> > Best,<br>
>>>>>>>>> ><br>
>>>>>>>>> > Luigi<br>
>>>>>>>>> ><br>
>>>>>>>>> > _______________________________________________<br>
>>>>>>>>> > Community mailing list<br>
>>>>>>>>> > <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
>>>>>>>>> > <a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
>>>>>>>>> ><br>
>>>>>>>><br>
>>>>>>>> _______________________________________________<br>
>>>>>>>> Community mailing list<br>
>>>>>>>> <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
>>>>>>>> <a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
>>>>>>><br>
>>>>>>> --<br>
>>>>>>> Matias<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> _______________________________________________<br>
>>>>>> Community mailing list<br>
>>>>>> <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
>>>>>> <a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
>>>>>><br>
>>>>><br>
>>>> --<br>
>>>> Matias<br>
>>><br>
>>><br>
>><br>
><br>
> _______________________________________________<br>
> Community mailing list<br>
> <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
> <a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
><br>
</div></div></blockquote></div><br></div>
</blockquote></div><div dir="ltr">-- <br></div><div dir="ltr">Matias</div>