{"action":"created","issue":{"url":"https://api.github.com/repos/stnava/ANTsR/issues/12","labels_url":"https://api.github.com/repos/stnava/ANTsR/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/stnava/ANTsR/issues/12/comments","events_url":"https://api.github.com/repos/stnava/ANTsR/issues/12/events","html_url":"https://github.com/stnava/ANTsR/issues/12","id":57382504,"number":12,"title":"ImageMath strange results","user":{"login":"armaneshaghi","id":4290297,"avatar_url":"https://avatars.githubusercontent.com/u/4290297?v=3","gravatar_id":"","url":"https://api.github.com/users/armaneshaghi","html_url":"https://github.com/armaneshaghi","followers_url":"https://api.github.com/users/armaneshaghi/followers","following_url":"https://api.github.com/users/armaneshaghi/following{/other_user}","gists_url":"https://api.github.com/users/armaneshaghi/gists{/gist_id}","starred_url":"https://api.github.com/users/armaneshaghi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armaneshaghi/subscriptions","organizations_url":"https://api.github.com/users/armaneshaghi/orgs","repos_url":"https://api.github.com/users/armaneshaghi/repos","events_url":"https://api.github.com/users/armaneshaghi/events{/privacy}","received_events_url":"https://api.github.com/users/armaneshaghi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-11T21:48:15Z","updated_at":"2015-02-11T22:50:22Z","closed_at":null,"body":"Goal: test `ImageMath` for `addtozero`:\r\n\r\nfrom man:\r\n\r\n```\r\naddtozero : add image-b to image-a only over points where image-a has zero values\r\n``` \r\n\r\nReproducible example:\r\n\r\n```\r\nrequire(ANTsR)\r\nrequire(testthat)\r\n         img1_array <- array(rep(2, 5*5), dim=c(5,5))\r\n         img1_array[1,2] <- 0\r\n         img1_array[2,3] <- 0\r\n         img1_array[2,2] <- 0\r\n         img1_array[3,3] <- 0\r\n         img1_array[4,3] <- 0\r\n         img1_array[4,3] <- 0\r\n         img1_array[4,4] <- 0\r\n         img1_array[4,3] <- 0\r\n         img1_array[5,1] <- 0\r\n         img2_array <- array(rep(2, 5*5), dim=c(5,5))\r\n\r\n```\r\nso:\r\n```\r\n> as.array(img1)\r\n     [,1] [,2] [,3] [,4] [,5]\r\n[1,]    2    0    2    2    2\r\n[2,]    2    0    0    2    2\r\n[3,]    2    2    0    2    2\r\n[4,]    2    2    0    0    2\r\n[5,]    0    2    2    2    2\r\n\r\n```\r\nand:\r\n\r\n```\r\n> as.array(img2)\r\n     [,1] [,2] [,3] [,4] [,5]\r\n[1,]    2    2    2    2    2\r\n[2,]    2    2    2    2    2\r\n[3,]    2    2    2    2    2\r\n[4,]    2    2    2    2    2\r\n[5,]    2    2    2    2    2\r\n```\r\n\r\nMoving on:\r\n\r\n```\r\n         img1 <- as.antsImage(img1_array)\r\n         img2 <- as.antsImage(img2_array)\r\n         output <- antsImageClone(img2)\r\n         ImageMath(2, output, 'addtozero', img1, img2)\r\n```\r\n\r\nI would expect to get a homogenous array with 2s, but:\r\n\r\n```\r\n> as.array(output)\r\n     [,1] [,2]          [,3]          [,4]          [,5]\r\n[1,]    2    2  2.000000e+00 1.850677e-316 6.926506e-310\r\n[2,]    2    2  2.000000e+00 3.127860e-316 4.940656e-324\r\n[3,]    2    2  0.000000e+00 4.356597e-316 6.926506e-310\r\n[4,]    2    2 4.431769e-321 1.037538e-321 6.926506e-310\r\n[5,]    2    2 6.926606e-310 3.458460e-323 9.881313e-324\r\n\r\n```\r\n\r\nto check if casting could be a problem:\r\n\r\n```\r\n> img1@pixeltype\r\n[1] \"double\"\r\n> img2@pixeltype\r\n[1] \"double\"\r\n> output@pixeltype\r\n[1] \"double\"\r\n```\r\n\r\nImageMath.cxx:\r\n```\r\n else if( strcmp(operation.c_str(), \"addtozero\") == 0 && pix1 == 0 )\r\n      {\r\n      result = pix1 + pix2;\r\n      }\r\n    else if( strcmp(operation.c_str(), \"addtozero\") == 0 && pix1 != 0 )\r\n      {\r\n      result = pix1;\r\n\r\n```\r\nIdeas?\r\n\r\nArman"},"comment":{"url":"https://api.github.com/repos/stnava/ANTsR/issues/comments/73982286","html_url":"https://github.com/stnava/ANTsR/issues/12#issuecomment-73982286","issue_url":"https://api.github.com/repos/stnava/ANTsR/issues/12","id":73982286,"user":{"login":"stnava","id":324222,"avatar_url":"https://avatars.githubusercontent.com/u/324222?v=3","gravatar_id":"","url":"https://api.github.com/users/stnava","html_url":"https://github.com/stnava","followers_url":"https://api.github.com/users/stnava/followers","following_url":"https://api.github.com/users/stnava/following{/other_user}","gists_url":"https://api.github.com/users/stnava/gists{/gist_id}","starred_url":"https://api.github.com/users/stnava/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stnava/subscriptions","organizations_url":"https://api.github.com/users/stnava/orgs","repos_url":"https://api.github.com/users/stnava/repos","events_url":"https://api.github.com/users/stnava/events{/privacy}","received_events_url":"https://api.github.com/users/stnava/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T22:50:21Z","updated_at":"2015-02-11T22:50:21Z","body":"@jeffduda seems this is what we use from ImageMath\n\nCompCorrAuto, D, FastMarchingExtension, FillHoles, G, GD, GE,\nGetLargestComponent, Grad, LabelStats, Laplacian, MakeImage,\nMaurerDistance,  ME, MD, Neg, Normalize, PadImage, PeronaMalik, Project,\nSliceTimingCorrection, TruncateImageIntensity\n\nattached is a starter iMath.cpp\n\n\nbrian\n\n\n\nOn Wed, Feb 11, 2015 at 5:43 PM, bkandel <notifications@github.com> wrote:\n\n> Oh, I see. I misunderstood what an image negative is.\n>\n> On 11 February 2015 at 17:40, stnava <notifications@github.com> wrote:\n>\n> > @armaneshaghi <https://github.com/armaneshaghi>\n> >\n> > i think there is some problem in the class of operators in which\n> addtozero\n> > lives ... not sure what\n> >\n> > —\n> > Reply to this email directly or view it on GitHub\n> > <https://github.com/stnava/ANTsR/issues/12#issuecomment-73980757>.\n>\n> >\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/stnava/ANTsR/issues/12#issuecomment-73981144>.\n>\n"}}