{"action":"created","issue":{"url":"https://api.github.com/repos/SuperElastix/elastix/issues/74","repository_url":"https://api.github.com/repos/SuperElastix/elastix","labels_url":"https://api.github.com/repos/SuperElastix/elastix/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/SuperElastix/elastix/issues/74/comments","events_url":"https://api.github.com/repos/SuperElastix/elastix/issues/74/events","html_url":"https://github.com/SuperElastix/elastix/issues/74","id":338704699,"node_id":"MDU6SXNzdWUzMzg3MDQ2OTk=","number":74,"title":"Exact metric not returning value","user":{"login":"thatguy14","id":25937625,"node_id":"MDQ6VXNlcjI1OTM3NjI1","avatar_url":"https://avatars2.githubusercontent.com/u/25937625?v=4","gravatar_id":"","url":"https://api.github.com/users/thatguy14","html_url":"https://github.com/thatguy14","followers_url":"https://api.github.com/users/thatguy14/followers","following_url":"https://api.github.com/users/thatguy14/following{/other_user}","gists_url":"https://api.github.com/users/thatguy14/gists{/gist_id}","starred_url":"https://api.github.com/users/thatguy14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatguy14/subscriptions","organizations_url":"https://api.github.com/users/thatguy14/orgs","repos_url":"https://api.github.com/users/thatguy14/repos","events_url":"https://api.github.com/users/thatguy14/events{/privacy}","received_events_url":"https://api.github.com/users/thatguy14/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-05T19:51:49Z","updated_at":"2018-07-06T19:35:34Z","closed_at":null,"author_association":"NONE","body":"Hello, I am trying to determine if the current registration I am preforming is converging. I turned on the exact metric to true but it is just returning \"-nan(ind)\" Here is the code of my parameter file thanks for your time!\r\n\r\n```\r\n(FixedInternalImagePixelType \"float\")\r\n(MovingInternalImagePixelType \"float\")\r\n(FixedImageDimension 3)\r\n(MovingImageDimension 3)\r\n(UseDirectionCosines \"true\")\r\n\r\n// **************** Main Components **************************\r\n\r\n(Registration \"MultiMetricMultiResolutionRegistration\")\r\n(Interpolator \"BSplineInterpolator\")\r\n(ResampleInterpolator \"FinalBSplineInterpolator\")\r\n(Resampler \"DefaultResampler\")\r\n\r\n(FixedImagePyramid \"FixedSmoothingImagePyramid\")\r\n(MovingImagePyramid \"MovingSmoothingImagePyramid\")\r\n\r\n(Optimizer \"AdaptiveStochasticGradientDescent\")\r\n(Transform \"RecursiveBSplineTransform\")\r\n(Metric \"AdvancedMattesMutualInformation\" \"TransformBendingEnergyPenalty\")\r\n//(Metric \"PCAMetric2\" \"TransformBendingEnergyPenalty\")\r\n(Metric0Weight 1)\r\n(Metric1Weight 50) // OPTIMIZED BY QUANTITATIVE MEASURES\r\n\r\n// ***************** Transformation **************************\r\n\r\n(GridSpacingSchedule 4 2 1)\r\n(FinalGridSpacingInPhysicalUnits 10 10 10)\r\n(HowToCombineTransforms \"Compose\")\r\n\r\n// ******************* Similarity measure *********************\r\n\r\n(NumberOfHistogramBins 100) // OPTIMIZED BY QUANTITATIVE MEASURES\r\n\r\n// ******************** Multiresolution **********************\r\n\r\n(NumberOfResolutions 3)\r\n(ImagePyramidSchedule 8 8 8  4 4 4  1 1 1 1 1 1) // ACCOUNTING FOR ANISOTROPIC RESOLUTION\r\n\r\n// ******************* Optimizer ****************************\r\n\r\n(MaximumNumberOfIterations 3000) // COULD PROBABLY BE LOWERED, ESPECIALLY FOR THE FIRST LEVELS OF THE IMAGE PYRAMID\r\n\r\n// **************** Image sampling **********************\r\n\r\n(NumberOfSpatialSamples 10000) // COULD PROBABLY BE LOWERED, ESPECIALLY FOR THE FIRST LEVELS OF THE IMAGE PYRAMID\r\n(NewSamplesEveryIteration \"true\")\r\n(ImageSampler \"MultiInputRandomCoordinate\")\r\n(SampleRegionSize 40)  // OPTIMIZED BY QUANTITATIVE MEASURES\r\n(UseRandomSampleRegion \"true\")\r\n(MaximumNumberOfSamplingAttempts 10)\r\n(RequiredRatioOfValidSamples 0.05)\r\n\r\n// ************* Interpolation and Resampling ****************\r\n\r\n(BSplineInterpolationOrder 1)\r\n(FinalBSplineInterpolationOrder 3)\r\n\r\n(ShowExactMetricValue \"false\" \"false\" \"true\") \r\n(WriteTransformParametersEachResolution \"true\")\r\n(WriteResultImageAfterEachResolution \"true\")\r\n//(WritePyramidImagesAfterEachResolution \"true\")\r\n\r\n(DefaultPixelValue 0)\r\n(WriteResultImage \"true\")\r\n(ResultImagePixelType \"short\")\r\n(ResultImageFormat \"nrrd\")\r\n```"},"comment":{"url":"https://api.github.com/repos/SuperElastix/elastix/issues/comments/403127435","html_url":"https://github.com/SuperElastix/elastix/issues/74#issuecomment-403127435","issue_url":"https://api.github.com/repos/SuperElastix/elastix/issues/74","id":403127435,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzEyNzQzNQ==","user":{"login":"YuchuanQiao","id":7225045,"node_id":"MDQ6VXNlcjcyMjUwNDU=","avatar_url":"https://avatars1.githubusercontent.com/u/7225045?v=4","gravatar_id":"","url":"https://api.github.com/users/YuchuanQiao","html_url":"https://github.com/YuchuanQiao","followers_url":"https://api.github.com/users/YuchuanQiao/followers","following_url":"https://api.github.com/users/YuchuanQiao/following{/other_user}","gists_url":"https://api.github.com/users/YuchuanQiao/gists{/gist_id}","starred_url":"https://api.github.com/users/YuchuanQiao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuchuanQiao/subscriptions","organizations_url":"https://api.github.com/users/YuchuanQiao/orgs","repos_url":"https://api.github.com/users/YuchuanQiao/repos","events_url":"https://api.github.com/users/YuchuanQiao/events{/privacy}","received_events_url":"https://api.github.com/users/YuchuanQiao/received_events","type":"User","site_admin":false},"created_at":"2018-07-06T19:35:34Z","updated_at":"2018-07-06T19:35:34Z","author_association":"NONE","body":"It looks like TransformBendingEnergyPenalty metric did not return a valid exact metric value. I checked the code and found that m_NumberOfPixelsCounted is zero, which is related to the parameter setting (UseRandomSampleRegion \"true\") . You should set this one to false, and then the value will be not -nan(ind).\r\n\r\nHowever, there is still another bug when using MultiMetricMultiResolutionRegistration (I suspect), because even you change the setting to false, you can only get 0.0 exact metric value. You can add one line to src/Core/ComponentBaseClasses/elxMetricBase.hxx, (line number 293)  this->m_ExactMetricSampler->Update(); before this->SetAdvancedMetricImageSampler( this->m_ExactMetricSampler ); Then build your solution again, you could get your desired exact metric value.\r\n\r\n@mstaring Hi Marius, could you please double-check this?\r\n"}}
{"actor":{"display_login":"YuchuanQiao"}}