Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events files are read in with onset as the index, causing downstream issues #9

Open
tsalo opened this issue Oct 13, 2021 · 1 comment

Comments

@tsalo
Copy link
Contributor

tsalo commented Oct 13, 2021

In a few places within the package, events files are read in using pandas.read_csv, as below:

timing = pd.read_csv(event_files[0], header=0, index_col=0, sep='\t')

Setting index_col=0 means that the first column will be read in as the index, and in BIDS datasets that first column would generally be the "onset" column. Later, however, the "onset" column is directly referenced, but it won't be available since it'll be the index (see below).

blocks.append((cond_timing.loc[i]['onset'] / tr, ((cond_timing.loc[i]['onset'] + cond_timing.loc[i]['duration']) / tr) + 1))

I think the solution is to drop index_col=0 and header=0 from all read_csv calls targeting events files. Also, switching to read_table will let you drop sep="\t", so it would just be df = pd.read_table(events_file).

@62442katieb
Copy link
Owner

Good find! I'll go ahead and edit it. read_table will be much more efficient. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants