{"action":"created","comment":{"url":"https://api.github.com/repos/UCL/STIR/pulls/comments/227960288","pull_request_review_id":168105273,"id":227960288,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzk2MDI4OA==","diff_hunk":"@@ -124,52 +124,86 @@ actual_write_to_file(std::string& filename,\n \n       // find ITK origin (i.e. coordinates of first voxel)\n       ImageType::PointType origin;\n-      CartesianCoordinate3D<float> stir_offset = density.get_physical_coordinates_for_indices(min_indices);\n+      CartesianCoordinate3D<float> stir_offset\n+        = density.get_LPS_coordinates_for_indices(min_indices);\n       origin[0] = stir_offset.x();\n       origin[1] = stir_offset.y();\n-      // Note: need to use - for z-coordinate because of different axis conventions\n-      origin[2] = -stir_offset.z();\n-      \n+      origin[2] = stir_offset.z();\n+\n       // find ITK size\n       ImageType::SizeType size;\n-      size[0] = image_ptr.get_x_size(); // size along X\n-      size[1] = image_ptr.get_y_size(); // size along Y\n-      size[2] = image_ptr.get_z_size(); // size along Z\n+      size[0] = image.get_x_size(); // size along X\n+      size[1] = image.get_y_size(); // size along Y\n+      size[2] = image.get_z_size(); // size along Z\n \n       // find ITK voxel size\n       ImageType::SpacingType spacing;\n-      spacing[0] = image_ptr.get_voxel_size().x(); // size along X\n-      spacing[1] = image_ptr.get_voxel_size().y(); // size along Y\n-      spacing[2] = image_ptr.get_voxel_size().z(); // size along Z\n+      spacing[0] = image.get_voxel_size().x(); // size along X\n+      spacing[1] = image.get_voxel_size().y(); // size along Y\n+      spacing[2] = image.get_voxel_size().z(); // size along Z\n \n-      // ITK orientation (RAI)\n+      // ITK Direction Matrix columns are unit vectors in axes LPS direction.\n+      // NB: ITK Matrix is in row, column order\n       ImageType::DirectionType matrix;\n-      matrix.Fill(0.F);\n-      matrix(0,0) = 1.F;\n-      matrix(1,1) = 1.F;\n-      matrix(2,2) = -1.F;\n+      for (unsigned int axis = 0; axis < 3; ++axis) {\n+        CartesianCoordinate3D<int> next_idx_along_this_axis(min_indices);\n+        next_idx_along_this_axis[3 - axis] += 1;\n+        const CartesianCoordinate3D<float> next_coord_along_this_dim\n+          = density.get_LPS_coordinates_for_indices(next_idx_along_this_axis);\n+        const CartesianCoordinate3D<float> axis_direction\n+          = next_coord_along_this_dim - stir_offset;\n+        for (unsigned int dim = 0; dim < 3; ++dim) {\n+          matrix(dim, axis) = axis_direction[3 - dim] / norm(axis_direction);\n+        }\n+      }\n \n       ImageType::RegionType region;\n       region.SetSize( size );\n       region.SetIndex( start );\n \n-      image->SetSpacing(spacing);\n-      image->SetRegions( region );\n-      image->SetOrigin(origin);\n-      image->SetDirection( matrix );\n-      image->Allocate();\n-\t\n+      //Creating the image\n+      ImageType::Pointer itk_image = ImageType::New();\n+\n+      itk_image->SetSpacing(spacing);\n+      itk_image->SetRegions( region );\n+      itk_image->SetOrigin(origin);\n+      itk_image->SetDirection( matrix );\n+      itk_image->Allocate();\n+\n+      // std::cerr << \"ITK Origin: \"","path":"src/IO/ITKOutputFileFormat.cxx","position":107,"original_position":107,"commit_id":"bc0460e32d3a456e32b20373fdd9f7cb83fffbbc","original_commit_id":"bc0460e32d3a456e32b20373fdd9f7cb83fffbbc","user":{"login":"KrisThielemans","id":6362141,"node_id":"MDQ6VXNlcjYzNjIxNDE=","avatar_url":"https://avatars2.githubusercontent.com/u/6362141?v=4","gravatar_id":"","url":"https://api.github.com/users/KrisThielemans","html_url":"https://github.com/KrisThielemans","followers_url":"https://api.github.com/users/KrisThielemans/followers","following_url":"https://api.github.com/users/KrisThielemans/following{/other_user}","gists_url":"https://api.github.com/users/KrisThielemans/gists{/gist_id}","starred_url":"https://api.github.com/users/KrisThielemans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KrisThielemans/subscriptions","organizations_url":"https://api.github.com/users/KrisThielemans/orgs","repos_url":"https://api.github.com/users/KrisThielemans/repos","events_url":"https://api.github.com/users/KrisThielemans/events{/privacy}","received_events_url":"https://api.github.com/users/KrisThielemans/received_events","type":"User","site_admin":false},"body":"let's delete all these","created_at":"2018-10-24T21:07:36Z","updated_at":"2018-10-24T21:17:53Z","html_url":"https://github.com/UCL/STIR/pull/257#discussion_r227960288","pull_request_url":"https://api.github.com/repos/UCL/STIR/pulls/257","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/UCL/STIR/pulls/comments/227960288"},"html":{"href":"https://github.com/UCL/STIR/pull/257#discussion_r227960288"},"pull_request":{"href":"https://api.github.com/repos/UCL/STIR/pulls/257"}}},"pull_request":{"url":"https://api.github.com/repos/UCL/STIR/pulls/257","id":220258924,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwMjU4OTI0","html_url":"https://github.com/UCL/STIR/pull/257","diff_url":"https://github.com/UCL/STIR/pull/257.diff","patch_url":"https://github.com/UCL/STIR/pull/257.patch","issue_url":"https://api.github.com/repos/UCL/STIR/issues/257","number":257,"state":"open","locked":false,"title":"[ENH] ITK IO to be LPS-aware","user":{"login":"ashgillman","id":816777,"node_id":"MDQ6VXNlcjgxNjc3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/816777?v=4","gravatar_id":"","url":"https://api.github.com/users/ashgillman","html_url":"https://github.com/ashgillman","followers_url":"https://api.github.com/users/ashgillman/followers","following_url":"https://api.github.com/users/ashgillman/following{/other_user}","gists_url":"https://api.github.com/users/ashgillman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashgillman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashgillman/subscriptions","organizations_url":"https://api.github.com/users/ashgillman/orgs","repos_url":"https://api.github.com/users/ashgillman/repos","events_url":"https://api.github.com/users/ashgillman/events{/privacy}","received_events_url":"https://api.github.com/users/ashgillman/received_events","type":"User","site_admin":false},"body":"Solution for #242 \r\nDepends #248 \r\n\r\nStill one TODO - reading orientation from DICOM. But works for now with NIfTI by assuming HFS (actually it calls it unknown, this is just treated like HFS in #248).","created_at":"2018-10-04T06:03:49Z","updated_at":"2018-10-24T21:17:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"200e8176e3b4dfec500f458167955b4458048e98","assignee":{"login":"ashgillman","id":816777,"node_id":"MDQ6VXNlcjgxNjc3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/816777?v=4","gravatar_id":"","url":"https://api.github.com/users/ashgillman","html_url":"https://github.com/ashgillman","followers_url":"https://api.github.com/users/ashgillman/followers","following_url":"https://api.github.com/users/ashgillman/following{/other_user}","gists_url":"https://api.github.com/users/ashgillman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashgillman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashgillman/subscriptions","organizations_url":"https://api.github.com/users/ashgillman/orgs","repos_url":"https://api.github.com/users/ashgillman/repos","events_url":"https://api.github.com/users/ashgillman/events{/privacy}","received_events_url":"https://api.github.com/users/ashgillman/received_events","type":"User","site_admin":false},"assignees":[{"login":"ashgillman","id":816777,"node_id":"MDQ6VXNlcjgxNjc3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/816777?v=4","gravatar_id":"","url":"https://api.github.com/users/ashgillman","html_url":"https://github.com/ashgillman","followers_url":"https://api.github.com/users/ashgillman/followers","following_url":"https://api.github.com/users/ashgillman/following{/other_user}","gists_url":"https://api.github.com/users/ashgillman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashgillman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashgillman/subscriptions","organizations_url":"https://api.github.com/users/ashgillman/orgs","repos_url":"https://api.github.com/users/ashgillman/repos","events_url":"https://api.github.com/users/ashgillman/events{/privacy}","received_events_url":"https://api.github.com/users/ashgillman/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"rijobro","id":33289025,"node_id":"MDQ6VXNlcjMzMjg5MDI1","avatar_url":"https://avatars0.githubusercontent.com/u/33289025?v=4","gravatar_id":"","url":"https://api.github.com/users/rijobro","html_url":"https://github.com/rijobro","followers_url":"https://api.github.com/users/rijobro/followers","following_url":"https://api.github.com/users/rijobro/following{/other_user}","gists_url":"https://api.github.com/users/rijobro/gists{/gist_id}","starred_url":"https://api.github.com/users/rijobro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rijobro/subscriptions","organizations_url":"https://api.github.com/users/rijobro/orgs","repos_url":"https://api.github.com/users/rijobro/repos","events_url":"https://api.github.com/users/rijobro/events{/privacy}","received_events_url":"https://api.github.com/users/rijobro/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/UCL/STIR/pulls/257/commits","review_comments_url":"https://api.github.com/repos/UCL/STIR/pulls/257/comments","review_comment_url":"https://api.github.com/repos/UCL/STIR/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UCL/STIR/issues/257/comments","statuses_url":"https://api.github.com/repos/UCL/STIR/statuses/bc0460e32d3a456e32b20373fdd9f7cb83fffbbc","head":{"label":"ashgillman:ITK-IO-LPS","ref":"ITK-IO-LPS","sha":"bc0460e32d3a456e32b20373fdd9f7cb83fffbbc","user":{"login":"ashgillman","id":816777,"node_id":"MDQ6VXNlcjgxNjc3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/816777?v=4","gravatar_id":"","url":"https://api.github.com/users/ashgillman","html_url":"https://github.com/ashgillman","followers_url":"https://api.github.com/users/ashgillman/followers","following_url":"https://api.github.com/users/ashgillman/following{/other_user}","gists_url":"https://api.github.com/users/ashgillman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashgillman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashgillman/subscriptions","organizations_url":"https://api.github.com/users/ashgillman/orgs","repos_url":"https://api.github.com/users/ashgillman/repos","events_url":"https://api.github.com/users/ashgillman/events{/privacy}","received_events_url":"https://api.github.com/users/ashgillman/received_events","type":"User","site_admin":false},"repo":{"id":45081893,"node_id":"MDEwOlJlcG9zaXRvcnk0NTA4MTg5Mw==","name":"STIR","full_name":"ashgillman/STIR","private":false,"owner":{"login":"ashgillman","id":816777,"node_id":"MDQ6VXNlcjgxNjc3Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/816777?v=4","gravatar_id":"","url":"https://api.github.com/users/ashgillman","html_url":"https://github.com/ashgillman","followers_url":"https://api.github.com/users/ashgillman/followers","following_url":"https://api.github.com/users/ashgillman/following{/other_user}","gists_url":"https://api.github.com/users/ashgillman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashgillman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashgillman/subscriptions","organizations_url":"https://api.github.com/users/ashgillman/orgs","repos_url":"https://api.github.com/users/ashgillman/repos","events_url":"https://api.github.com/users/ashgillman/events{/privacy}","received_events_url":"https://api.github.com/users/ashgillman/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ashgillman/STIR","description":"Software for Tomographic Image Reconstruction","fork":true,"url":"https://api.github.com/repos/ashgillman/STIR","forks_url":"https://api.github.com/repos/ashgillman/STIR/forks","keys_url":"https://api.github.com/repos/ashgillman/STIR/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ashgillman/STIR/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ashgillman/STIR/teams","hooks_url":"https://api.github.com/repos/ashgillman/STIR/hooks","issue_events_url":"https://api.github.com/repos/ashgillman/STIR/issues/events{/number}","events_url":"https://api.github.com/repos/ashgillman/STIR/events","assignees_url":"https://api.github.com/repos/ashgillman/STIR/assignees{/user}","branches_url":"https://api.github.com/repos/ashgillman/STIR/branches{/branch}","tags_url":"https://api.github.com/repos/ashgillman/STIR/tags","blobs_url":"https://api.github.com/repos/ashgillman/STIR/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ashgillman/STIR/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ashgillman/STIR/git/refs{/sha}","trees_url":"https://api.github.com/repos/ashgillman/STIR/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ashgillman/STIR/statuses/{sha}","languages_url":"https://api.github.com/repos/ashgillman/STIR/languages","stargazers_url":"https://api.github.com/repos/ashgillman/STIR/stargazers","contributors_url":"https://api.github.com/repos/ashgillman/STIR/contributors","subscribers_url":"https://api.github.com/repos/ashgillman/STIR/subscribers","subscription_url":"https://api.github.com/repos/ashgillman/STIR/subscription","commits_url":"https://api.github.com/repos/ashgillman/STIR/commits{/sha}","git_commits_url":"https://api.github.com/repos/ashgillman/STIR/git/commits{/sha}","comments_url":"https://api.github.com/repos/ashgillman/STIR/comments{/number}","issue_comment_url":"https://api.github.com/repos/ashgillman/STIR/issues/comments{/number}","contents_url":"https://api.github.com/repos/ashgillman/STIR/contents/{+path}","compare_url":"https://api.github.com/repos/ashgillman/STIR/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ashgillman/STIR/merges","archive_url":"https://api.github.com/repos/ashgillman/STIR/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ashgillman/STIR/downloads","issues_url":"https://api.github.com/repos/ashgillman/STIR/issues{/number}","pulls_url":"https://api.github.com/repos/ashgillman/STIR/pulls{/number}","milestones_url":"https://api.github.com/repos/ashgillman/STIR/milestones{/number}","notifications_url":"https://api.github.com/repos/ashgillman/STIR/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ashgillman/STIR/labels{/name}","releases_url":"https://api.github.com/repos/ashgillman/STIR/releases{/id}","deployments_url":"https://api.github.com/repos/ashgillman/STIR/deployments","created_at":"2015-10-28T01:49:26Z","updated_at":"2018-10-19T00:40:41Z","pushed_at":"2018-10-24T10:16:24Z","git_url":"git://github.com/ashgillman/STIR.git","ssh_url":"git@github.com:ashgillman/STIR.git","clone_url":"https://github.com/ashgillman/STIR.git","svn_url":"https://github.com/ashgillman/STIR","homepage":null,"size":48517,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"UCL:master","ref":"master","sha":"980e793da310e7cf2bc0c4f440d0dd5c06210205","user":{"login":"UCL","id":2951150,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NTExNTA=","avatar_url":"https://avatars2.githubusercontent.com/u/2951150?v=4","gravatar_id":"","url":"https://api.github.com/users/UCL","html_url":"https://github.com/UCL","followers_url":"https://api.github.com/users/UCL/followers","following_url":"https://api.github.com/users/UCL/following{/other_user}","gists_url":"https://api.github.com/users/UCL/gists{/gist_id}","starred_url":"https://api.github.com/users/UCL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UCL/subscriptions","organizations_url":"https://api.github.com/users/UCL/orgs","repos_url":"https://api.github.com/users/UCL/repos","events_url":"https://api.github.com/users/UCL/events{/privacy}","received_events_url":"https://api.github.com/users/UCL/received_events","type":"Organization","site_admin":false},"repo":{"id":43287063,"node_id":"MDEwOlJlcG9zaXRvcnk0MzI4NzA2Mw==","name":"STIR","full_name":"UCL/STIR","private":false,"owner":{"login":"UCL","id":2951150,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NTExNTA=","avatar_url":"https://avatars2.githubusercontent.com/u/2951150?v=4","gravatar_id":"","url":"https://api.github.com/users/UCL","html_url":"https://github.com/UCL","followers_url":"https://api.github.com/users/UCL/followers","following_url":"https://api.github.com/users/UCL/following{/other_user}","gists_url":"https://api.github.com/users/UCL/gists{/gist_id}","starred_url":"https://api.github.com/users/UCL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UCL/subscriptions","organizations_url":"https://api.github.com/users/UCL/orgs","repos_url":"https://api.github.com/users/UCL/repos","events_url":"https://api.github.com/users/UCL/events{/privacy}","received_events_url":"https://api.github.com/users/UCL/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/UCL/STIR","description":"Software for Tomographic Image Reconstruction","fork":false,"url":"https://api.github.com/repos/UCL/STIR","forks_url":"https://api.github.com/repos/UCL/STIR/forks","keys_url":"https://api.github.com/repos/UCL/STIR/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UCL/STIR/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UCL/STIR/teams","hooks_url":"https://api.github.com/repos/UCL/STIR/hooks","issue_events_url":"https://api.github.com/repos/UCL/STIR/issues/events{/number}","events_url":"https://api.github.com/repos/UCL/STIR/events","assignees_url":"https://api.github.com/repos/UCL/STIR/assignees{/user}","branches_url":"https://api.github.com/repos/UCL/STIR/branches{/branch}","tags_url":"https://api.github.com/repos/UCL/STIR/tags","blobs_url":"https://api.github.com/repos/UCL/STIR/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UCL/STIR/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UCL/STIR/git/refs{/sha}","trees_url":"https://api.github.com/repos/UCL/STIR/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UCL/STIR/statuses/{sha}","languages_url":"https://api.github.com/repos/UCL/STIR/languages","stargazers_url":"https://api.github.com/repos/UCL/STIR/stargazers","contributors_url":"https://api.github.com/repos/UCL/STIR/contributors","subscribers_url":"https://api.github.com/repos/UCL/STIR/subscribers","subscription_url":"https://api.github.com/repos/UCL/STIR/subscription","commits_url":"https://api.github.com/repos/UCL/STIR/commits{/sha}","git_commits_url":"https://api.github.com/repos/UCL/STIR/git/commits{/sha}","comments_url":"https://api.github.com/repos/UCL/STIR/comments{/number}","issue_comment_url":"https://api.github.com/repos/UCL/STIR/issues/comments{/number}","contents_url":"https://api.github.com/repos/UCL/STIR/contents/{+path}","compare_url":"https://api.github.com/repos/UCL/STIR/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UCL/STIR/merges","archive_url":"https://api.github.com/repos/UCL/STIR/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UCL/STIR/downloads","issues_url":"https://api.github.com/repos/UCL/STIR/issues{/number}","pulls_url":"https://api.github.com/repos/UCL/STIR/pulls{/number}","milestones_url":"https://api.github.com/repos/UCL/STIR/milestones{/number}","notifications_url":"https://api.github.com/repos/UCL/STIR/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UCL/STIR/labels{/name}","releases_url":"https://api.github.com/repos/UCL/STIR/releases{/id}","deployments_url":"https://api.github.com/repos/UCL/STIR/deployments","created_at":"2015-09-28T07:44:46Z","updated_at":"2018-10-24T20:18:53Z","pushed_at":"2018-10-24T20:18:48Z","git_url":"git://github.com/UCL/STIR.git","ssh_url":"git@github.com:UCL/STIR.git","clone_url":"https://github.com/UCL/STIR.git","svn_url":"https://github.com/UCL/STIR","homepage":"http://stir.sourceforge.net/","size":48454,"stargazers_count":30,"watchers_count":30,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"archived":false,"open_issues_count":87,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":38,"open_issues":87,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UCL/STIR/pulls/257"},"html":{"href":"https://github.com/UCL/STIR/pull/257"},"issue":{"href":"https://api.github.com/repos/UCL/STIR/issues/257"},"comments":{"href":"https://api.github.com/repos/UCL/STIR/issues/257/comments"},"review_comments":{"href":"https://api.github.com/repos/UCL/STIR/pulls/257/comments"},"review_comment":{"href":"https://api.github.com/repos/UCL/STIR/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UCL/STIR/pulls/257/commits"},"statuses":{"href":"https://api.github.com/repos/UCL/STIR/statuses/bc0460e32d3a456e32b20373fdd9f7cb83fffbbc"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"KrisThielemans"}}