We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7ba418 commit 02f73c1Copy full SHA for 02f73c1
6 files changed
tests/conftest.py
@@ -181,23 +181,6 @@ def exemplar_extended_trials_fixture():
181
@pytest.fixture(scope="module")
182
def trials_df_fixture():
183
trials = pd.read_pickle(os.path.join(TESTING_RES_DIR, "trials.pkl"))
184
- trials["scheduled_change_time"] = trials.apply(
185
- lambda row: row["scheduled_change_time"] - row["starttime"],
186
- axis=1
187
- ) # change scheduled_change_time from time relative to experiment start to time relative to trial start
188
- del trials['stim_on_frames']
189
- del trials['publish_time']
190
- trials['endframe'] = trials['startframe'].shift(periods=-1)
191
- trials.at[trials.index[-1],'endframe']=94157
192
-
193
- def nan_to_empty_string(val):
194
- if pd.isnull(val):
195
- return ''
196
- return val
197
- trials["change_image_category"] = trials["change_image_category"].apply(nan_to_empty_string) # use empty string instead of NoneType
198
- trials["change_image_name"] = trials["change_image_name"].apply(nan_to_empty_string) # use empty string instead of NoneType
199
- trials["initial_image_category"] = trials["initial_image_category"].apply(nan_to_empty_string) # use empty string instead of NoneType
200
- trials["initial_image_name"] = trials["initial_image_name"].apply(nan_to_empty_string) # use empty string instead of NoneType
201
return trials
202
203
tests/res/trials.pkl
-942 KB
tests/translator/foraging/test_foraging_translator.py
@@ -26,6 +26,7 @@ def test_load_time(behavioral_session_output_fixture):
26
27
def test_load_trials(behavioral_session_output_fixture, trials_df_fixture):
28
trials = foraging.load_trials(behavioral_session_output_fixture)
29
+
30
pd.testing.assert_frame_equal(
31
trials,
32
trials_df_fixture,
@@ -96,6 +97,13 @@ def test_load_running_speed(behavioral_session_output_fixture):
96
97
# 3: -100.3045892838318,
98
# 4: -218.06477955362016
99
# },
100
+ 'frame': {
101
+ 0: 0,
102
+ 1: 1,
103
+ 2: 2,
104
+ 3: 3,
105
+ 4: 4
106
+ },
107
'speed': {
108
0: 0.0,
109
1: 0.14556417360329282,
@@ -111,10 +119,6 @@ def test_load_running_speed(behavioral_session_output_fixture):
111
119
4: 0.2000794094055891
112
120
}
113
121
},
114
- columns=[
115
- u'speed',
116
- u'time',
117
- ]
118
122
)
123
124
tests/translator/foraging2/test_foraging2_extract.py
@@ -283,10 +283,11 @@ def test_get_licks(monkeypatch, foraging2_data_fixture):
283
(
284
{},
285
pd.DataFrame(data={
286
- "time": np.array([0.0, 0.016, 0.032, 0.048, 0.064, ]),
287
- "speed (cm/s)": np.array([0, 0, 0, 0, 0, ]),
288
- "acceleration (cm/s^2)": np.array([0, 0, 0, 0, 0, ]),
289
- "jerk (cm/s^3)": np.array([0, 0, 0, 0, 0, ]),
+ "time": [0.0, 0.016, 0.032, 0.048, 0.064, ],
+ "speed": [0, 0, 0, 0, 0, ],
+ "frame": [0, 1, 2, 3, 4, ]
+ # "acceleration (cm/s^2)": np.array([0, 0, 0, 0, 0, ]),
290
+ # "jerk (cm/s^3)": np.array([0, 0, 0, 0, 0, ]),
291
}),
292
),
293
])
visual_behavior/translator/foraging2/__init__.py
@@ -216,17 +216,8 @@ def data_to_running(data):
216
-----
217
- the index of each time is the frame number
218
"""
219
- speed_df = get_running_speed(data)[["speed (cm/s)", "time"]] # yeah...it's dumb i kno...
220
221
- n_frames = len(speed_df)
222
223
- frames_df = pd.DataFrame(data={"frame": range(n_frames)})
224
225
- return pd.DataFrame(data={
226
- "speed": speed_df["speed (cm/s)"],
227
- "frame": frames_df["frame"],
228
- "time": speed_df["time"],
229
- })
+ speed_df = get_running_speed(data)
+ return speed_df
230
231
232
def data_to_time(data):
visual_behavior/translator/foraging2/extract.py
@@ -724,7 +724,8 @@ def get_running_speed(exp_data, smooth=False, time=None):
724
725
running_speed = pd.DataFrame({
726
'time': time,
727
- 'speed (cm/s)': speed,
+ 'frame': range(len(time)),
728
+ 'speed': speed,
729
# 'acceleration (cm/s^2)': accel,
730
# 'jerk (cm/s^3)': jerk,
731
})
0 commit comments