@@ -202,12 +202,7 @@ def _validate_data(data_blocks: list):
202202 )
203203 # Monocular tracking but switched between left/right eye
204204 elif len (set (eyes )) > 1 :
205- warn (
206- "The eye being tracked changed during the"
207- " recording. The channel names will reflect"
208- " the eye that was tracked at the start of"
209- " the recording."
210- )
205+ warn ("The eye being tracked changed during the recording." )
211206
212207
213208def _get_recording_datetime (fname ):
@@ -246,7 +241,13 @@ def _get_metadata(data_block: dict):
246241 meta_data = dict ()
247242 rec_info = data_block ["events" ]["SAMPLES" ][0 ]
248243 meta_data ["unit" ] = rec_info [0 ]
249- meta_data ["pupil_unit" ] = data_block ["events" ]["PUPIL" ][0 ][0 ]
244+
245+ # If the file doesn't have pupil data, i'm not sure if there will be any PUPIL info?
246+ if not data_block ["events" ]["PUPIL" ]:
247+ ps_unit = None
248+ else :
249+ ps_unit = data_block ["events" ]["PUPIL" ][0 ][0 ]
250+ meta_data ["pupil_unit" ] = ps_unit
250251 if ("LEFT" in rec_info ) and ("RIGHT" in rec_info ):
251252 meta_data ["tracking_mode" ] = "binocular"
252253 meta_data ["eye" ] = "both"
@@ -363,8 +364,7 @@ def _create_dataframes_for_block(block, apply_offsets):
363364 df_dict [label ] = pd .DataFrame (block ["events" ][event ])
364365 else :
365366 # Changed this from info to debug level to avoid spamming the log
366- block_idx = block ["info" ]["block_idx" ]
367- logger .debug (f"No { label } events found in block { block_idx } " )
367+ logger .debug (f"No { label } events found in block" )
368368
369369 # make dataframe for experiment messages in this block
370370 if block ["events" ]["MSG" ]:
@@ -464,19 +464,24 @@ def _combine_block_dataframes(processed_blocks: list[dict]):
464464
465465 # Determine unified column structure by collecting all unique column names
466466 # across all acquisition blocks
467- all_ch_names = set ()
467+ all_ch_names = []
468468 all_samples_cols = set ()
469469 all_df_types = set ()
470470
471471 for block in processed_blocks :
472- all_ch_names .update (block ["ch_names" ])
472+ # The tests assume a certain order of channel names.
473+ # so we can't use a set like we do for the columns.
474+ # bc it randomly orders the channel names.
475+ for ch_name in block ["ch_names" ]:
476+ if ch_name not in all_ch_names :
477+ all_ch_names .append (ch_name )
478+ # all_ch_names.update(block["ch_names"])
473479 if "samples" in block ["dfs" ]:
474480 all_samples_cols .update (block ["dfs" ]["samples" ].columns )
475481 all_df_types .update (block ["dfs" ].keys ())
476482
477- # Convert to sorted lists for consistent ordering
478- unified_ch_names = sorted (all_ch_names )
479- unified_samples_cols = sorted (all_samples_cols )
483+ # The sets randomly ordered the column names.
484+ all_samples_cols = sorted (all_samples_cols )
480485
481486 # Combine dataframes by type
482487 combined_dfs = {}
@@ -492,12 +497,12 @@ def _combine_block_dataframes(processed_blocks: list[dict]):
492497 # For samples dataframes, ensure all have the same columns
493498 if df_type == "samples" :
494499 # Add missing columns with NaN
495- for col in unified_samples_cols :
500+ for col in all_samples_cols :
496501 if col not in block_df .columns :
497502 block_df [col ] = np .nan
498503
499504 # Reorder columns to match unified structure
500- block_df = block_df [unified_samples_cols ]
505+ block_df = block_df [all_samples_cols ]
501506
502507 block_dfs .append (block_df )
503508
@@ -515,7 +520,7 @@ def _combine_block_dataframes(processed_blocks: list[dict]):
515520 blocks_data , columns = ["time" , "end_time" , "block" ]
516521 )
517522
518- return combined_dfs , unified_ch_names
523+ return combined_dfs , all_ch_names
519524
520525
521526def _drop_status_col (samples_df ):
0 commit comments