{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1354","labels_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1354/labels{/name}","comments_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1354/comments","events_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1354/events","html_url":"https://github.com/scikit-image/scikit-image/issues/1354","id":55310350,"number":1354,"title":"Bug in feature.peak_local_max leading to IndexError for ND arrays, N != 2","user":{"login":"kevin-keraudren","id":802153,"avatar_url":"https://avatars.githubusercontent.com/u/802153?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-keraudren","html_url":"https://github.com/kevin-keraudren","followers_url":"https://api.github.com/users/kevin-keraudren/followers","following_url":"https://api.github.com/users/kevin-keraudren/following{/other_user}","gists_url":"https://api.github.com/users/kevin-keraudren/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-keraudren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-keraudren/subscriptions","organizations_url":"https://api.github.com/users/kevin-keraudren/orgs","repos_url":"https://api.github.com/users/kevin-keraudren/repos","events_url":"https://api.github.com/users/kevin-keraudren/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-keraudren/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-23T17:45:47Z","updated_at":"2015-01-23T17:54:39Z","closed_at":null,"body":"Hi,\r\n\r\nThere is a bug there:\r\n\r\nhttps://github.com/scikit-image/scikit-image/blob/master/skimage/feature/peak.py#L152\r\n\r\nthis line assumes that we are working with 2D arrays while the rest of the code is for ND arrays.\r\n\r\nI propose the following fix:\r\n\r\n    intensities = image.flat[np.ravel_multi_index(coordinates,image.shape)]\r\n\r\nI usually follow the rule \"if it's not broken, don't fix it\", so you can ignore the following suggestion:\r\n\r\nhttps://github.com/scikit-image/scikit-image/blob/master/skimage/feature/peak.py#L149\r\n\r\n    coordinates = np.transpose((image > peak_threshold).nonzero())\r\n\r\ncould be written:\r\n\r\n    coordinates = np.argwhere(image > peak_threshold)\r\n\r\nSee http://docs.scipy.org/doc/numpy/reference/generated/numpy.argwhere.html\r\n\r\n\"np.argwhere(a) is the same as np.transpose(np.nonzero(a)).\"\r\n\r\nKind regards,\r\n\r\nKevin"},"comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/issues/comments/71234119","html_url":"https://github.com/scikit-image/scikit-image/issues/1354#issuecomment-71234119","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1354","id":71234119,"user":{"login":"ahojnnes","id":134307,"avatar_url":"https://avatars.githubusercontent.com/u/134307?v=3","gravatar_id":"","url":"https://api.github.com/users/ahojnnes","html_url":"https://github.com/ahojnnes","followers_url":"https://api.github.com/users/ahojnnes/followers","following_url":"https://api.github.com/users/ahojnnes/following{/other_user}","gists_url":"https://api.github.com/users/ahojnnes/gists{/gist_id}","starred_url":"https://api.github.com/users/ahojnnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahojnnes/subscriptions","organizations_url":"https://api.github.com/users/ahojnnes/orgs","repos_url":"https://api.github.com/users/ahojnnes/repos","events_url":"https://api.github.com/users/ahojnnes/events{/privacy}","received_events_url":"https://api.github.com/users/ahojnnes/received_events","type":"User","site_admin":false},"created_at":"2015-01-23T17:54:39Z","updated_at":"2015-01-23T17:54:39Z","body":"Hi Kevin,\r\n\r\nAll of what you write sounds right. Would you be willing to open a new PR to fix the issue and add a short test-case that covers the bug?\r\n\r\nThanks.\r\n\r\n> On Jan 23, 2015, at 12:45 PM, Kevin Keraudren <notifications@github.com> wrote:\r\n> \r\n> Hi,\r\n> \r\n> There is a bug there:\r\n> \r\n> https://github.com/scikit-image/scikit-image/blob/master/skimage/feature/peak.py#L152\r\n> \r\n> this line assumes that we are working with 2D arrays while the rest of the code is for ND arrays.\r\n> \r\n> I propose the following fix:\r\n> \r\n> intensities = image.flat[np.ravel_multi_index(coordinates,image.shape)]\r\n> \r\n> I usually follow the rule \"if it's not broken, don't fix it\", so you can ignore the following suggestion:\r\n> \r\n> https://github.com/scikit-image/scikit-image/blob/master/skimage/feature/peak.py#L149\r\n> \r\n> coordinates = np.transpose((image > peak_threshold).nonzero())\r\n> \r\n> could be written:\r\n> \r\n> coordinates = np.argwhere(image > peak_threshold)\r\n> \r\n> See http://docs.scipy.org/doc/numpy/reference/generated/numpy.argwhere.html\r\n> \r\n> \"np.argwhere(a) is the same as np.transpose(np.nonzero(a)).\"\r\n> \r\n> Kind regards,\r\n> \r\n> Kevin\r\n> \r\n> —\r\n> Reply to this email directly or view it on GitHub.\r\n> "}}