@@ -70,26 +70,29 @@ def add_dios(nwbfile: NWBFile, recfile: list[str], metadata: dict) -> None:
7070 prefix = "ECU_"
7171 break
7272
73- for channel_name in channel_name_map :
74- # merge streams from multiple files
75- all_timestamps = []
76- all_state_changes = []
77- for io in neo_io :
73+ all_timestamps = [[] for _ in channel_name_map ]
74+ all_state_changes = [[] for _ in channel_name_map ]
75+ # Loop through io objects and get timestamps and state changes for each channel
76+ for io in neo_io :
77+ for i , channel_name in enumerate ( channel_name_map ) :
7878 timestamps , state_changes = io .get_digitalsignal (
7979 stream_name , prefix + channel_name
8080 )
81- all_timestamps .append (timestamps )
82- all_state_changes .append (state_changes )
83- all_timestamps = np .concatenate (all_timestamps )
84- all_state_changes = np .concatenate (all_state_changes )
85- assert isinstance (all_timestamps [0 ], np .float64 )
86- assert isinstance (all_timestamps , np .ndarray )
81+ all_timestamps [i ].append (timestamps )
82+ all_state_changes [i ].append (state_changes )
83+ for channel_name , state_changes , timestamps in zip (
84+ channel_name_map , all_state_changes , all_timestamps
85+ ):
86+ timestamps = np .concatenate (timestamps )
87+ state_changes = np .concatenate (state_changes )
88+ assert isinstance (timestamps [0 ], np .float64 )
89+ assert isinstance (timestamps , np .ndarray )
8790 ts = TimeSeries (
8891 name = channel_name_map [channel_name ],
8992 description = channel_name ,
90- data = all_state_changes ,
93+ data = state_changes ,
9194 unit = "-1" , # TODO change to "N/A",
92- timestamps = all_timestamps , # TODO adjust timestamps
95+ timestamps = timestamps , # TODO adjust timestamps
9396 )
9497 beh_events .add_timeseries (ts )
9598
0 commit comments