{"action":"created","issue":{"url":"https://api.github.com/repos/OpenChemistry/tomviz/issues/158","labels_url":"https://api.github.com/repos/OpenChemistry/tomviz/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/OpenChemistry/tomviz/issues/158/comments","events_url":"https://api.github.com/repos/OpenChemistry/tomviz/issues/158/events","html_url":"https://github.com/OpenChemistry/tomviz/issues/158","id":100778834,"number":158,"title":"Add ITK","user":{"login":"Hovden","id":6197997,"avatar_url":"https://avatars.githubusercontent.com/u/6197997?v=3","gravatar_id":"","url":"https://api.github.com/users/Hovden","html_url":"https://github.com/Hovden","followers_url":"https://api.github.com/users/Hovden/followers","following_url":"https://api.github.com/users/Hovden/following{/other_user}","gists_url":"https://api.github.com/users/Hovden/gists{/gist_id}","starred_url":"https://api.github.com/users/Hovden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hovden/subscriptions","organizations_url":"https://api.github.com/users/Hovden/orgs","repos_url":"https://api.github.com/users/Hovden/repos","events_url":"https://api.github.com/users/Hovden/events{/privacy}","received_events_url":"https://api.github.com/users/Hovden/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OpenChemistry/tomviz/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"mathturtle","id":553788,"avatar_url":"https://avatars.githubusercontent.com/u/553788?v=3","gravatar_id":"","url":"https://api.github.com/users/mathturtle","html_url":"https://github.com/mathturtle","followers_url":"https://api.github.com/users/mathturtle/followers","following_url":"https://api.github.com/users/mathturtle/following{/other_user}","gists_url":"https://api.github.com/users/mathturtle/gists{/gist_id}","starred_url":"https://api.github.com/users/mathturtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathturtle/subscriptions","organizations_url":"https://api.github.com/users/mathturtle/orgs","repos_url":"https://api.github.com/users/mathturtle/repos","events_url":"https://api.github.com/users/mathturtle/events{/privacy}","received_events_url":"https://api.github.com/users/mathturtle/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/OpenChemistry/tomviz/milestones/3","html_url":"https://github.com/OpenChemistry/tomviz/milestones/0.7","labels_url":"https://api.github.com/repos/OpenChemistry/tomviz/milestones/3/labels","id":1181081,"number":3,"title":"0.7","description":"First post M&M Release","creator":{"login":"Hovden","id":6197997,"avatar_url":"https://avatars.githubusercontent.com/u/6197997?v=3","gravatar_id":"","url":"https://api.github.com/users/Hovden","html_url":"https://github.com/Hovden","followers_url":"https://api.github.com/users/Hovden/followers","following_url":"https://api.github.com/users/Hovden/following{/other_user}","gists_url":"https://api.github.com/users/Hovden/gists{/gist_id}","starred_url":"https://api.github.com/users/Hovden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hovden/subscriptions","organizations_url":"https://api.github.com/users/Hovden/orgs","repos_url":"https://api.github.com/users/Hovden/repos","events_url":"https://api.github.com/users/Hovden/events{/privacy}","received_events_url":"https://api.github.com/users/Hovden/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":6,"state":"open","created_at":"2015-06-25T14:16:43Z","updated_at":"2015-09-14T20:18:21Z","due_on":"2015-11-20T05:00:00Z","closed_at":null},"comments":6,"created_at":"2015-08-13T14:11:47Z","updated_at":"2015-09-16T14:43:43Z","closed_at":null,"body":""},"comment":{"url":"https://api.github.com/repos/OpenChemistry/tomviz/issues/comments/140762897","html_url":"https://github.com/OpenChemistry/tomviz/issues/158#issuecomment-140762897","issue_url":"https://api.github.com/repos/OpenChemistry/tomviz/issues/158","id":140762897,"user":{"login":"mathturtle","id":553788,"avatar_url":"https://avatars.githubusercontent.com/u/553788?v=3","gravatar_id":"","url":"https://api.github.com/users/mathturtle","html_url":"https://github.com/mathturtle","followers_url":"https://api.github.com/users/mathturtle/followers","following_url":"https://api.github.com/users/mathturtle/following{/other_user}","gists_url":"https://api.github.com/users/mathturtle/gists{/gist_id}","starred_url":"https://api.github.com/users/mathturtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathturtle/subscriptions","organizations_url":"https://api.github.com/users/mathturtle/orgs","repos_url":"https://api.github.com/users/mathturtle/repos","events_url":"https://api.github.com/users/mathturtle/events{/privacy}","received_events_url":"https://api.github.com/users/mathturtle/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T14:43:43Z","updated_at":"2015-09-16T14:43:43Z","body":"@Hovden here is a sample ITK script for segmentation that can be used in the tomviz 'custom python transform' dialog.  I don't know much about ITK, so this may not be optimal, but I think it works (as far as I can tell anyways).\r\n```\r\ndef transform_scalars(dataset):\r\n    \"\"\"Define this method for Python operators that \r\n    transform the input array\"\"\"\r\n\r\n    from tomviz import utils\r\n    import numpy as np\r\n    import itk\r\n\r\n    # Get the current volume as a numpy array.\r\n    array = utils.get_array(dataset)\r\n\r\n    # Set up some ITK variables\r\n    itk_image_type = itk.Image.F3\r\n    itk_converter = itk.PyBuffer[itk_image_type]\r\n\r\n    # Read the image into ITK\r\n    itk_image = itk_converter.GetImageFromArray(array)\r\n\r\n    # ITK filter (I have no idea if this is right)\r\n    filter = itk.ConfidenceConnectedImageFilter[itk_image_type,itk.Image.SS3].New()\r\n    filter.SetInitialNeighborhoodRadius(3)\r\n    filter.SetMultiplier(3)\r\n    filter.SetNumberOfIterations(25)\r\n    filter.SetReplaceValue(255)\r\n    filter.SetSeed((24,65,37))\r\n    filter.SetInput(itk_image)\r\n    filter.Update()\r\n\r\n\r\n    # Get the image back from ITK\r\n    result = itk.PyBuffer[itk.Image.SS3].GetArrayFromImage(filter.GetOutput())\r\n\r\n    # This is where the transformed data is set, it will display in tomviz.\r\n    utils.set_array(dataset, result)\r\n```"}}