{"action":"created","issue":{"url":"https://api.github.com/repos/mne-tools/mne-python/issues/2649","labels_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2649/labels{/name}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2649/comments","events_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2649/events","html_url":"https://github.com/mne-tools/mne-python/pull/2649","id":119183553,"number":2649,"title":"FIX: data.shape[2] may be wrongly estimated in _BaseEpochs.__init__()","user":{"login":"cmoutard","id":7878675,"avatar_url":"https://avatars.githubusercontent.com/u/7878675?v=3","gravatar_id":"","url":"https://api.github.com/users/cmoutard","html_url":"https://github.com/cmoutard","followers_url":"https://api.github.com/users/cmoutard/followers","following_url":"https://api.github.com/users/cmoutard/following{/other_user}","gists_url":"https://api.github.com/users/cmoutard/gists{/gist_id}","starred_url":"https://api.github.com/users/cmoutard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmoutard/subscriptions","organizations_url":"https://api.github.com/users/cmoutard/orgs","repos_url":"https://api.github.com/users/cmoutard/repos","events_url":"https://api.github.com/users/cmoutard/events{/privacy}","received_events_url":"https://api.github.com/users/cmoutard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-11-27T11:50:34Z","updated_at":"2015-11-30T13:53:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2649","html_url":"https://github.com/mne-tools/mne-python/pull/2649","diff_url":"https://github.com/mne-tools/mne-python/pull/2649.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/2649.patch"},"body":"In \\__init\\__() within _BaseEpochs, data.shape[2] is evaluated as follow :\r\n```\r\nround((tmax - tmin) * self.info['sfreq']) + 1\r\n```\r\n\r\nAnd if data.shape[2] is not egal to this estimation, it throws an error :\r\n```\r\nraise RuntimeError('bad data shape')\r\n```\r\n\r\nHowever, in some cases, I think the estimation is wrong. Here is an exemple :\r\nLet's say that originally tmin=0.0 and tmax=0.009 (epochs lasting 9ms), and that self.info['sfreq'] was fixed to 500.\r\nThen, after decimation, times and data.shape[2] would be : \r\n\r\n```\r\nepochs.times = [0., 0.002, 0.004, 0.006, 0.008]        \r\ndata.shape[2] = 5\r\n```\r\n\r\nBut :\r\n```\r\n(tmax - tmin) * self.info['sfreq'] = 0.009*500 = 4.5\r\nround(4.5) = 5\r\n```\r\nSo :\r\n```\r\nround((tmax - tmin) * self.info['sfreq']) + 1 = 6\r\n```\r\n\r\n\\__init\\__() in _BaseEpochs whould then throw an error while everything is fine.\r\n\r\nTo sum it up, when the first decimal of (tmax - tmin) * self.info['sfreq'] is >=5, the rounding and the +1 are redondant, making the estimate of data.shape[2] wrong.\r\n\r\nI propose here to fix it by replacing _round_ by _int_, to floor the float and suppress the redondant increment. \r\n\r\nBtw, this issue is fairely related to another problem I met with tmin and tmax definition + decimation, which is still out there (see PR #2486, closed without being merged...).\r\n"},"comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/issues/comments/160634641","html_url":"https://github.com/mne-tools/mne-python/pull/2649#issuecomment-160634641","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2649","id":160634641,"user":{"login":"agramfort","id":161052,"avatar_url":"https://avatars.githubusercontent.com/u/161052?v=3","gravatar_id":"","url":"https://api.github.com/users/agramfort","html_url":"https://github.com/agramfort","followers_url":"https://api.github.com/users/agramfort/followers","following_url":"https://api.github.com/users/agramfort/following{/other_user}","gists_url":"https://api.github.com/users/agramfort/gists{/gist_id}","starred_url":"https://api.github.com/users/agramfort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agramfort/subscriptions","organizations_url":"https://api.github.com/users/agramfort/orgs","repos_url":"https://api.github.com/users/agramfort/repos","events_url":"https://api.github.com/users/agramfort/events{/privacy}","received_events_url":"https://api.github.com/users/agramfort/received_events","type":"User","site_admin":false},"created_at":"2015-11-30T13:53:55Z","updated_at":"2015-11-30T13:53:55Z","body":"not sure to follow but this needs a fix...\n"}}