@@ -184,8 +184,8 @@ def _parse_header(self):
184184 chan_id = f"{ stream_name } #{ chan_name } "
185185
186186 # Separate sync channel in its own stream
187- is_sync_channel = "SY" in chan_name and not self .load_sync_channel
188- if is_sync_channel :
187+ is_sync_channel = "SY" in chan_name and not self .load_sync_channel
188+ if is_sync_channel :
189189 # This is a sync channel and should be added as its own stream
190190 sync_stream_id = f"{ stream_name } -SYNC"
191191 sync_stream_id_to_buffer_id [sync_stream_id ] = buffer_id
@@ -387,7 +387,7 @@ def scan_files(dirname):
387387 continue
388388 meta_filename = Path (root ) / file
389389 bin_filename = meta_filename .with_suffix (".bin" )
390-
390+
391391 if meta_filename .exists () and bin_filename .exists ():
392392 meta = read_meta_file (meta_filename )
393393 info = extract_stream_info (meta_filename , meta )
@@ -401,6 +401,7 @@ def scan_files(dirname):
401401
402402 return info_list
403403
404+
404405def _add_segment_order (info_list ):
405406 """
406407 Uses gate and trigger numbers to construct a segment index (`seg_index`) for each signal in `info_list`.
@@ -413,7 +414,7 @@ def _add_segment_order(info_list):
413414 """
414415 # This sets non-integers values before integers
415416 normalize = lambda x : x if isinstance (x , int ) else - 1
416-
417+
417418 # Segment index is determined by the gate_num and trigger_num in that order
418419 def get_segment_tuple (info ):
419420 # Create a key from the normalized gate_num and trigger_num
@@ -475,7 +476,7 @@ def parse_spikeglx_fname(fname):
475476 stream_kind: str or None
476477 The data type identifier, "lf", "ap", "obx", or None
477478 """
478-
479+
479480 # Standard case: contains gate, trigger, device, and stream kind
480481 # Example: Noise4Sam_g0_t0.imec0.ap
481482 # Format: {run_name}_g{gate_num}_t{trigger_num}.{device}.{stream_kind}
@@ -502,7 +503,7 @@ def parse_spikeglx_fname(fname):
502503 gd = match .groupdict ()
503504 return gd ["run_name" ], int (gd ["gate_num" ]), "cat" , gd ["device" ], gd ["stream_kind" ]
504505
505- # OneBox case: ends in .obx
506+ # OneBox case: ends in .obx
506507 # Example: myRun_g0_t0.obx0.obx
507508 # Format: {run_name}_g{gate_num}_t{trigger_num}.{device}.obx
508509 # Regex tokens:
@@ -641,7 +642,7 @@ def extract_stream_info(meta_file, meta):
641642 device = fname .split ("." )[- 2 ] if "." in fname else device
642643 stream_kind = ""
643644 units = "V"
644-
645+
645646 # OneBox gain calculation
646647 # V = i * Vmax / Imax where Imax = obMaxInt, Vmax = obAiRangeMax
647648 # See: https://billkarsh.github.io/SpikeGLX/Sgl_help/Metadata_30.html
@@ -669,7 +670,7 @@ def extract_stream_info(meta_file, meta):
669670 probe_slot = meta .get ("imDatPrb_slot" , None )
670671 probe_port = meta .get ("imDatPrb_port" , None )
671672 probe_dock = meta .get ("imDatPrb_dock" , None )
672-
673+
673674 # OneBox specific metadata
674675 obx_slot = meta .get ("imDatObx_slot" , None )
675676
@@ -697,10 +698,10 @@ def extract_stream_info(meta_file, meta):
697698 info ["probe_port" ] = int (probe_port ) if probe_port else None
698699 info ["probe_dock" ] = int (probe_dock ) if probe_dock else None
699700 info ["obx_slot" ] = int (obx_slot ) if obx_slot else None
700-
701+
701702 # Add device index
702703 if info .get ("device_kind" ) == "imec" :
703- info ["device_index" ] = info ["device" ].split ("imec" )[- 1 ]
704+ info ["device_index" ] = info ["device" ].split ("imec" )[- 1 ]
704705 elif info .get ("device_kind" ) == "obx" :
705706 info ["device_index" ] = info ["device" ].split ("obx" )[- 1 ]
706707 else :
@@ -732,5 +733,4 @@ def extract_stream_info(meta_file, meta):
732733 info ["digital_channels" ] = [channel for channel in info ["channel_names" ] if channel .startswith ("XD" )]
733734 info ["analog_channels" ] = [channel for channel in info ["channel_names" ] if channel .startswith ("XA" )]
734735
735-
736736 return info
0 commit comments