55import pandas as pd
66import pytest
77from pynwb import NWBHDF5IO , TimeSeries
8+ from pynwb .behavior import BehavioralEvents , Position
89
910from trodes_to_nwb import convert , convert_rec_header , convert_yaml
1011from trodes_to_nwb .convert_dios import add_dios
@@ -207,7 +208,7 @@ def test_correct_timestamps_for_camera_to_mcu_lag():
207208 np .allclose (corrected_camera_systime , expected_corrected_camera_systime )
208209
209210
210- def test_add_position ():
211+ def test_add_position (prior_position = False ):
211212 probe_metadata = [data_path / "tetrode_12.5.yml" ]
212213
213214 # make session_df
@@ -226,8 +227,17 @@ def test_add_position():
226227 # make nwb file
227228 nwbfile = convert_yaml .initialize_nwb (metadata , rec_header )
228229
230+ # Optional test: add position data to nwbfile before running add_position
231+ if prior_position :
232+ nwbfile .create_processing_module (
233+ name = "behavior" , description = "Contains all behavior-related data"
234+ )
235+ position = Position (name = "position" )
236+ nwbfile .processing ["behavior" ].add (position )
237+
229238 # run add_position and prerequisite functions
230239 convert_yaml .add_cameras (nwbfile , metadata )
240+
231241 add_position (nwbfile , metadata , session_df , rec_header )
232242
233243 # Check that the objects were properly added
@@ -294,6 +304,10 @@ def test_add_position():
294304 os .remove (filename )
295305
296306
307+ def test_add_position_preexisting ():
308+ test_add_position (prior_position = True )
309+
310+
297311from trodes_to_nwb .convert_position import read_trodes_datafile
298312
299313
0 commit comments