locations.py 591 B

123456789101112131415161718192021
  1. #!/usr/bin/python
  2. from os.path import join as opj
  3. import pandas as pd
  4. df = pd.read_csv(opj('src', 'locations', 'data', 'structure.csv'))
  5. # apply BIDS standard column names
  6. df.rename(columns=dict(time='onset'), inplace=True)
  7. # last line in input is not a shot, but the end of the last shot
  8. shot_durations = df['onset'].diff()[1:]
  9. shot_durations.index = range(0, len(shot_durations))
  10. df.drop(df.tail(1).index, inplace=True)
  11. # include BIDS standard duration column
  12. df.insert(1, 'duration', shot_durations)
  13. df.to_csv(
  14. opj('researchcut', 'locations.tsv'),
  15. sep='\t',
  16. index=False)