{"action":"created","issue":{"url":"https://api.github.com/repos/SimpleITK/SimpleITK/issues/576","repository_url":"https://api.github.com/repos/SimpleITK/SimpleITK","labels_url":"https://api.github.com/repos/SimpleITK/SimpleITK/issues/576/labels{/name}","comments_url":"https://api.github.com/repos/SimpleITK/SimpleITK/issues/576/comments","events_url":"https://api.github.com/repos/SimpleITK/SimpleITK/issues/576/events","html_url":"https://github.com/SimpleITK/SimpleITK/issues/576","id":363411035,"node_id":"MDU6SXNzdWUzNjM0MTEwMzU=","number":576,"title":"FOV and pixelspacing mismatch issue ","user":{"login":"subhajitchatu","id":4659247,"node_id":"MDQ6VXNlcjQ2NTkyNDc=","avatar_url":"https://avatars1.githubusercontent.com/u/4659247?v=4","gravatar_id":"","url":"https://api.github.com/users/subhajitchatu","html_url":"https://github.com/subhajitchatu","followers_url":"https://api.github.com/users/subhajitchatu/followers","following_url":"https://api.github.com/users/subhajitchatu/following{/other_user}","gists_url":"https://api.github.com/users/subhajitchatu/gists{/gist_id}","starred_url":"https://api.github.com/users/subhajitchatu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/subhajitchatu/subscriptions","organizations_url":"https://api.github.com/users/subhajitchatu/orgs","repos_url":"https://api.github.com/users/subhajitchatu/repos","events_url":"https://api.github.com/users/subhajitchatu/events{/privacy}","received_events_url":"https://api.github.com/users/subhajitchatu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-25T05:02:25Z","updated_at":"2018-09-25T14:12:50Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI am getting a new issue when  I am trying to register two images using simpleITK.\r\n1. Images have different matrix size .\r\n  eg.\r\n    fixed: (512,512,60)   \r\n    moving: (480,480,60)\r\n2. Images have different FOV ( voxel size, resolution, pixel spacing etc. are different)\r\n    fixed: \r\n  eg.\r\n    fixed: (390mm,390mm,60)\r\n    moving: (340mm,340mm,60)\r\n\r\nSo, after registering them using sitkAffineTransformation , I resampled the output image according to the fixed image using SetSpacing(), SetOrigin(), SetDirection(). The problem I have found that\r\n1. The output image has same FOV and matrix size as fixed image. But the FOV is shrinking, i.e it is taking very small area and I could not able to match in with the fixed image in my further processing.\r\n\r\n2. When I  tried to use other methods like BSpline. The output image was filled with zeros only. It works only with Affine.\r\n\r\n3. In case of affine transform , the output image was having a translation also, which was not expected because in the the moving image, there is no translation.\r\n\r\nPlease let me know if I need to do some other steps in this case of FOV, pixel size mismatch.\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/SimpleITK/SimpleITK/issues/comments/424359741","html_url":"https://github.com/SimpleITK/SimpleITK/issues/576#issuecomment-424359741","issue_url":"https://api.github.com/repos/SimpleITK/SimpleITK/issues/576","id":424359741,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDM1OTc0MQ==","user":{"login":"subhajitchatu","id":4659247,"node_id":"MDQ6VXNlcjQ2NTkyNDc=","avatar_url":"https://avatars1.githubusercontent.com/u/4659247?v=4","gravatar_id":"","url":"https://api.github.com/users/subhajitchatu","html_url":"https://github.com/subhajitchatu","followers_url":"https://api.github.com/users/subhajitchatu/followers","following_url":"https://api.github.com/users/subhajitchatu/following{/other_user}","gists_url":"https://api.github.com/users/subhajitchatu/gists{/gist_id}","starred_url":"https://api.github.com/users/subhajitchatu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/subhajitchatu/subscriptions","organizations_url":"https://api.github.com/users/subhajitchatu/orgs","repos_url":"https://api.github.com/users/subhajitchatu/repos","events_url":"https://api.github.com/users/subhajitchatu/events{/privacy}","received_events_url":"https://api.github.com/users/subhajitchatu/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T14:12:50Z","updated_at":"2018-09-25T14:12:50Z","author_association":"NONE","body":"Hi @zivy ,\r\n\r\nI was just trying the below code\r\n\r\n`def GlobalAffineRegistration(fixed,moving):\r\n\r\n       moving = sitk.Cast(moving, fixed.GetPixelID())\r\n       ConstPixelSpacing = list(fixed.GetSpacing())\r\n       Origin = list(fixed.GetOrigin())\r\n       Direction = list(fixed.GetDirection())\r\n       moving.SetSpacing(ConstPixelSpacing)\r\n       moving.SetOrigin(Origin)\r\n       moving.SetDirection(Direction)\r\n       initialTx = sitk.CenteredTransformInitializer(fixed, moving, sitk.AffineTransform(fixed.GetDimension()))\r\n       R = sitk.ImageRegistrationMethod()\r\n       R.SetMetricAsJointHistogramMutualInformation(32)\r\n\r\n       R.SetOptimizerAsGradientDescent(learningRate=1.0,\r\n                                       numberOfIterations=100,\r\n                                       estimateLearningRate = R.EachIteration)\r\n\r\n       R.SetOptimizerScalesFromPhysicalShift()\r\n       R.SetInitialTransform(initialTx,inPlace=False)\r\n       R.SetInterpolator(sitk.sitkLinear)\r\n       outTx = R.Execute(sitk.Cast(fixed,sitk.sitkFloat32), sitk.Cast(moving,sitk.sitkFloat32))\r\n\r\n       resampler = sitk.ResampleImageFilter()\t\r\n       moving = sitk.Cast(moving, fixed.GetPixelID())\r\n       resampler.SetTransform(outTx)\r\n       resampler.SetReferenceImage(fixed)\r\n       resampler.SetInterpolator(sitk.sitkLinear)\r\n       out = resampler.Execute(moving)\r\n       Origin = list(fixed.GetOrigin())\r\n       Direction = list(fixed.GetDirection())\r\n       out.SetSpacing(ConstPixelSpacing)\t\r\n       out.SetOrigin(Origin)\r\n       out.SetDirection(Direction)\t\t\t\t\r\n       sitk.WriteImage(out,outFileName)\r\n`\r\n\r\nUsing this code I find the below output, where I tried to register moving and fixed image with different modality and may have different fov, pixel spacing etc. When I use bspline , whole image is having 0.0.\r\nI could not able to figure out the problem.\r\n\r\n![fixed1](https://user-images.githubusercontent.com/4659247/46019612-1ca91480-c0fa-11e8-836d-efc4136195f9.png)\r\n![moving1](https://user-images.githubusercontent.com/4659247/46019616-20d53200-c0fa-11e8-93f9-aa112b34c051.png)\r\n![output1](https://user-images.githubusercontent.com/4659247/46019635-29c60380-c0fa-11e8-8864-94f8bde62ea2.png)\r\n\r\n\r\n"}}
{"actor":{"display_login":"subhajitchatu"}}