• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

int-brain-lab / iblrig / 11407201950

18 Oct 2024 04:12PM UTC coverage: 47.898% (+1.1%) from 46.79%
11407201950

Pull #730

github

86ab26
web-flow
Merge 9801a3e94 into 0f4a57326
Pull Request #730: 8.24.4

47 of 68 new or added lines in 8 files covered. (69.12%)

1013 existing lines in 22 files now uncovered.

4170 of 8706 relevant lines covered (47.9%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/iblrig_tasks/_iblrig_tasks_neuroModulatorChoiceWorld/task_validation.py
1
# first read jsonable file containing the trials in record oriented way
2
import matplotlib.pyplot as plt
×
3
import numpy as np
×
4
import pandas as pd
×
5

6
from iblutil.io import jsonable
×
7

8
task_data = jsonable.read('/Users/olivier/Downloads/D6/_iblrig_taskData.raw.jsonable')
×
9

10
# pop-out the bpod data from the table
11
bpod_data = []
×
12
for td in task_data:
×
13
    bpod_data.append(td.pop('behavior_data'))
×
14

15
# and convert the remaining dictionary in a proper table format
16
task_data = pd.DataFrame(task_data)
×
17

18
## %%
19
# from the bpod data, we create columns that contain the time elapsed during reward and delays
20
task_data['bpod_valve_time'] = 0
×
21
task_data['bpod_delay'] = 0
×
22
for i, bp in enumerate(bpod_data):
×
23
    sts = bp['States timestamps']
×
NEW
24
    task_data.at[i, 'bpod_valve_time'] = np.diff(sts.get('reward', np.nan))
×
25
    task_data.at[i, 'bpod_delay'] = np.nansum(
×
26
        np.r_[
27
            np.diff(sts['delay_reward'])[0] if 'delay_reward' in sts else 0,
28
            np.diff(sts['delay_error'])[0] if 'delay_error' in sts else 0,
29
            np.diff(sts['delay_nogo'])[0] if 'delay_nogo' in sts else 0,
30
        ]
31
    )
32

33
## %%
34
# if all checks out the valve time should almost proportional to the reward amound
35
r = np.corrcoef(
×
36
    task_data['reward_amount'][~np.isnan(task_data['valve_time'])], task_data['valve_time'][~np.isnan(task_data['valve_time'])]
37
)
38
assert r[0, 1] >= 0.9999
×
39

40
# the other test is to check that we have delays - this fails on data collected 27/01/2023
41
# here the rewarded trials have no delay. Oups...
42
assert np.all(task_data['bpod_delay'] >= 1.5)
×
43

44
## %%
45
plt.figure()
×
46
plt.plot(task_data['reward_amount'].values, task_data['valve_time'].values, '.')
×
47
plt.figure()
×
48
plt.plot(task_data['bpod_delay'])
×
49
plt.show()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc