[ITK] [ITK-users] Mattes Mutual Information Speed with 3D Images
Gabriel A. Giménez
gabrielgimenez85 at gmail.com
Thu Mar 12 15:24:05 EDT 2015
Hi!
I debug the code of the MMI implementation and the bottleneck is in in this
part:
*itkImageToImageMetricv4GetValueAndDerivativeThreader.hxx:*
template< typename TImageToImageMetricv4 >
void
ImageToImageMetricv4GetValueAndDerivativeThreader<
ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >
::*ThreadedExecution* ( const DomainType & indexSubRange,
const ThreadIdType threadId )
{
//Initialize per thread buffers and variables.
this->m_Associate->InitializeThread( threadId );
typename TImageToImageMetricv4::VirtualPointSetType::ConstPointer
virtualSampledPointSet = this->m_Associate->GetVirtualSampledPointSet();
typedef typename
TImageToImageMetricv4::VirtualPointSetType::MeshTraits::PointIdentifier
ElementIdentifierType;
const ElementIdentifierType begin = indexSubRange[0];
const ElementIdentifierType end = indexSubRange[1];
VirtualIndexType virtualIndex;
typename VirtualImageType::ConstPointer virtualImage =
this->m_Associate->GetVirtualImage();
* for( ElementIdentifierType i = begin; i <= end; ++i )*
* {*
* const VirtualPointType & virtualPoint =
virtualSampledPointSet->GetPoint( i );*
* virtualImage->TransformPhysicalPointToIndex( virtualPoint,
virtualIndex );*
* this->ProcessVirtualPoint( virtualIndex, virtualPoint, threadId );*
* }*
//Finalize per thread actions
this->m_Associate->FinalizeThread( threadId );
}
The "for" statement takes a long time to finish running... and I think the
default multithreaded is 2...I tried to raise this value through seter
"SetMaximumNumberOfThreads()" but did not notice substantial improvements
in performance ..
However, when set build-type to "release" instead "debug" the performance
is much better (2 ~ 3 sec.) but without reaching to the order of
milliseconds....would I like it to be.
I could not do the test with the ITK 3D Slicer (my OS is of 32-bits only).
What do you think? can further improve performance?
Thanks and regards!
2015-03-11 9:37 GMT-03:00 Gabriel A. Giménez <gabrielgimenez85 at gmail.com>:
> Ok...I understand...,I'll try...and I commented the results....
>
> Thanks in advance!
>
> 2015-03-11 9:26 GMT-03:00 Braun Tim <Tim.Braun at sirona.com>:
>
> Yes, exactly. If you compile ITK e.g. with Visual Studio, you can set
>> the compile profile either to ‘debug’, which is slow but allows the
>> debugger to stop at breakpoints etc, and ‘release’, which is much faster
>> due to enabled optimizations but cannot be debugged easily.. If you have
>> trouble compiling ITK, there are some good youtube tutorials around
>> covering this topic.
>>
>>
>>
>> *Von:* Gabriel A. Giménez [mailto:gabrielgimenez85 at gmail.com]
>> *Gesendet:* Mittwoch, 11. März 2015 13:21
>>
>> *An:* Braun Tim
>> *Betreff:* Re: [ITK] [ITK-users] Mattes Mutual Information Speed with 3D
>> Images
>>
>>
>>
>> Hi! thank you very much for your answer!
>>
>> I'll try the alternatives do you recommend me...,I do not understand the
>> execution mode "Release" ? it is a compile option?
>>
>>
>>
>> Regards!
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2015-03-11 6:18 GMT-03:00 Braun Tim <Tim.Braun at sirona.com>:
>>
>> Hi Gabriel,
>>
>>
>>
>> this is several orders of magnitude slower than it should be, so I assume
>> there is something weird going on. Applying the metric should take a couple
>> of milliseconds, not longer. Did you compile ITK from source yourself? Then
>> you should be able to use the ‘DEBUG’ configuration to trace into the
>> metric evaluation and find out what the performance bottleneck is – that’s
>> probably faster than empirical testing.. Running the algorithm must be done
>> in release mode, of course. Another option would be to try the ITK Slicer
>> program, which contains the Brainsfit algorithm which uses MMI for
>> registration – here, you can try different parameters and check the
>> runtime..
>>
>>
>>
>> cheers, Tim
>>
>>
>>
>>
>>
>> *Von:* Gabriel A. Giménez [mailto:gabrielgimenez85 at gmail.com]
>> *Gesendet:* Dienstag, 10. März 2015 13:33
>> *An:* Braun Tim
>> *Betreff:* Re: [ITK] [ITK-users] Mattes Mutual Information Speed with 3D
>> Images
>>
>>
>>
>> Hi Braun, thanks for your answer...
>>
>>
>>
>> I use images of RIRE BD (http://www.insight-journal.org/rire/), my
>> initial tests I make with package training_001 (CT - MR_PD). Following your
>> recommendation here is my configuration:
>>
>>
>>
>>
>>
>> metric->SetNumberOfHistogramBins( 50 );
>>
>> double samplingPercentage = 0.002;
>>
>> registration->SetMetricSamplingPercentage( samplingPercentage );
>>
>> RegistrationType::MetricSamplingStrategyType samplingStrategy =
>>
>>
>> RegistrationType::REGULAR;
>>
>>
>>
>> Unfortunately, the results were not good ... the average execution time
>> remains the same (25 ~ 30 seconds). With a population size equal to 50, the
>> execution time of an iteration is in the order of 25 minutes, very slow for
>> me ...
>>
>>
>>
>> These are the image data:
>>
>>
>>
>> Fixed Image:
>>
>> ObjectType = Image
>>
>> NDims = 3
>>
>> BinaryDataByteOrderMSB = True
>>
>> AnatomicalOrientation = LPH
>>
>> ElementSpacing = 0.653595 0.653595 4.000000
>>
>> *DimSize = 512 512 29*
>>
>> ElementType = MET_SHORT
>>
>> ElementDataFile = image.bin
>>
>>
>>
>> Moving Image:
>>
>> ObjectType = Image
>>
>> NDims = 3
>>
>> BinaryDataByteOrderMSB = True
>>
>> AnatomicalOrientation = LPH
>>
>> ElementSpacing = 1.250000 1.250000 4.000000
>>
>> *DimSize = 256 256 26*
>>
>> ElementType = MET_SHORT
>>
>> ElementDataFile = image.bin
>>
>>
>>
>>
>>
>> Thanks and regards!
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2015-03-10 5:51 GMT-03:00 Braun Tim <Tim.Braun at sirona.com>:
>>
>> Hi Gabriel,
>>
>> the easiest way to speed up the metric calculation I can think of
>> (without having more detailed information about your setup) is to reduce
>> the numbers of samples used to build the MMI histogram estimates. For 256^3
>> Voxel Volumes, we typically use a value of 0.002. You can set the sampling
>> percentage in the registration method that manages the metric and the
>> optimizer:
>>
>>
>> registrationMethod->SetMetricSamplingStrategy(ImageRegistrationMethodTypev4::REGULAR);
>> registrationMethod->SetMetricSamplingPercentage(0.002);
>>
>> Another way to speed up calculation would be to reduce the resolution of
>> the registered volumes - which is somewhat similar to reducing the sampling
>> percentage, but has memory benefits and might reduce aliasing..
>>
>>
>> Hope that helps!
>>
>> Cheers,
>> Tim
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Community [mailto:community-bounces at itk.org] Im Auftrag von Gabriel
>> A. Giménez
>> Gesendet: Dienstag, 10. März 2015 00:02
>> An: insight-users at itk.org
>> Betreff: [ITK] [ITK-users] Mattes Mutual Information Speed with 3D Images
>>
>>
>> Hello everyone...
>>
>> I'm working on a genetic optimizer for Rigid 3D Registration.
>>
>> The fitness of each individual is calculated using Mattes Mutual
>> Information, the execution time of the metric is high ... (30 seconds on
>> average). This makes the registration too slow.
>>
>> Any recommendations? could improve the performance metrics? otherwise
>> most appropriate metric?
>>
>> Regards!
>>
>>
>>
>> --
>> View this message in context:
>> http://itk-insight-users.2283740.n2.nabble.com/Mattes-Mutual-Information-Speed-with-3D-Images-tp7586971.html
>> Sent from the ITK Insight Users mailing list archive at Nabble.com.
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>> _______________________________________________
>> Community mailing list
>> Community at itk.org
>> http://public.kitware.com/mailman/listinfo/community
>>
>>
>>
>> -----------------------------------------------------------------------------------------------------------
>> Sirona Dental Systems GmbH * HRB 24948 *
>> Vorsitzender des Aufsichtsrats: Dr. Erich Blum *
>> Sirona Dental Services GmbH * HRB 25817 *
>> Geschaeftsfuehrung: Rainer Berthan * Michael Geil *
>> Sitz der Gesellschaften: Bensheim * Registergericht: AG Darmstadt *
>>
>> ------------------------------------------------------------------------------------------------------------
>> Diese E-Mail ist ausschliesslich fuer den angesprochenen Adressaten
>> bestimmt und kann vertrauliche Informationen beinhalten.
>> --
>> This e-mail is intended only for the designated recipient(s). It may
>> contain confidential or proprietary information.
>>
>> ------------------------------------------------------------------------------------------------------------
>>
>>
>>
>>
>>
>> --
>>
>> *Gabriel Alberto Giménez.*
>>
>>
>>
>>
>> -----------------------------------------------------------------------------------------------------------
>> Sirona Dental Systems GmbH • HRB 24948 •
>>
>> Vorsitzender des Aufsichtsrats: Dr. Erich Blum •
>> Sirona Dental Services GmbH • HRB 25817 •
>> Geschäftsführung: Rainer Berthan • Michael Geil •
>> Sitz der Gesellschaften: Bensheim • Registergericht: AG Darmstadt •
>>
>> ------------------------------------------------------------------------------------------------------------
>> Diese E-Mail ist ausschliesslich fuer den angesprochenen Adressaten
>> bestimmt und kann vertrauliche Informationen beinhalten.
>> --
>> This e-mail is intended only for the designated recipient(s). It may
>> contain confidential or proprietary information.
>>
>> ------------------------------------------------------------------------------------------------------------
>>
>>
>>
>>
>>
>> --
>>
>> *Gabriel Alberto Giménez.*
>>
>
>
>
> --
> *Gabriel Alberto Giménez.*
>
--
*Gabriel Alberto Giménez.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150312/1f62ef42/attachment-0001.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list