@@ -387,61 +387,71 @@ def parse_spikeglx_fname(fname):
387
387
Consider the filenames: `Noise4Sam_g0_t0.nidq.bin` or `Noise4Sam_g0_t0.imec0.lf.bin`
388
388
The filenames consist of 3 or 4 parts separated by `.`
389
389
1. "Noise4Sam_g0_t0" will be the `name` variable. This choosen by the user at recording time.
390
- 2. "_g0_ " is the "gate_num"
391
- 3. "_t0_ " is the "trigger_num"
390
+ 2. "g0 " is the "gate_num"
391
+ 3. "t0 " is the "trigger_num"
392
392
4. "nidq" or "imec0" will give the `device`
393
393
5. "lf" or "ap" will be the `stream_kind`
394
- `stream_name` variable is the concatenation of `device.stream_kind`
394
+ `stream_name` variable is the concatenation of `device.stream_kind`
395
+
396
+ If CatGT is used, then the trigger numbers in the file names ("t0"/"t1"/etc.)
397
+ will be renamed to "tcat". In this case, the parsed "trigger_num" will be set to "cat".
395
398
396
399
This function is copied/modified from Graham Findlay.
397
400
398
401
Notes:
399
- * Sometimes the original file name is modified by the user and "_gt0_ " or "_t0_"
402
+ * Sometimes the original file name is modified by the user and "_g0_ " or "_t0_"
400
403
are manually removed. In that case gate_name and trigger_num will be None.
401
404
402
405
Parameters
403
406
---------
404
407
fname: str
405
408
The filename to parse without the extension, e.g. "my-run-name_g0_t1.imec2.lf"
409
+
406
410
Returns
407
411
-------
408
412
run_name: str
409
413
The run name, e.g. "my-run-name".
410
414
gate_num: int or None
411
415
The gate identifier, e.g. 0.
412
- trigger_num: int or None
413
- The trigger identifier, e.g. 1.
416
+ trigger_num: int | str or None
417
+ The trigger identifier, e.g. 1. If CatGT is used, then the trigger_num will be set to "cat".
414
418
device: str
415
419
The probe identifier, e.g. "imec2"
416
420
stream_kind: str or None
417
421
The data type identifier, "lf" or "ap" or None
418
422
"""
419
- r = re .findall (r"(\S*)_g(\d*)_t(\d*)\.(\S*).(ap|lf)" , fname )
420
- if len (r ) == 1 :
423
+ re_standard = re .findall (r"(\S*)_g(\d*)_t(\d*)\.(\S*).(ap|lf)" , fname )
424
+ re_tcat = re .findall (r"(\S*)_g(\d*)_tcat.(\S*).(ap|lf)" , fname )
425
+ re_nidq = re .findall (r"(\S*)_g(\d*)_t(\d*)\.(\S*)" , fname )
426
+ if len (re_standard ) == 1 :
421
427
# standard case with probe
422
- run_name , gate_num , trigger_num , device , stream_kind = r [0 ]
428
+ run_name , gate_num , trigger_num , device , stream_kind = re_standard [0 ]
429
+ elif len (re_tcat ) == 1 :
430
+ # tcat case
431
+ run_name , gate_num , device , stream_kind = re_tcat [0 ]
432
+ trigger_num = "cat"
433
+ elif len (re_nidq ) == 1 :
434
+ # case for nidaq
435
+ run_name , gate_num , trigger_num , device = re_nidq [0 ]
436
+ stream_kind = None
423
437
else :
424
- r = re .findall (r"(\S*)_g(\d*)_t(\d*)\.(\S*)" , fname )
425
- if len (r ) == 1 :
426
- # case for nidaq
427
- run_name , gate_num , trigger_num , device = r [0 ]
428
- stream_kind = None
438
+ # the naming do not correspond lets try something more easy
439
+ # example: sglx_xxx.imec0.ap
440
+ re_else = re .findall (r"(\S*)\.(\S*).(ap|lf)" , fname )
441
+ re_else_nidq = re .findall (r"(\S*)\.(\S*)" , fname )
442
+ if len (re_else ) == 1 :
443
+ run_name , device , stream_kind = re_else_nidq [0 ]
444
+ gate_num , trigger_num = None , None
445
+ elif len (re_else_nidq ) == 1 :
446
+ # easy case for nidaq, example: sglx_xxx.nidq
447
+ run_name , device = re_else_nidq [0 ]
448
+ gate_num , trigger_num , stream_kind = None , None , None
429
449
else :
430
- # the naming do not correspond lets try something more easy
431
- # example: sglx_xxx.imec0.ap
432
- r = re .findall (r"(\S*)\.(\S*).(ap|lf)" , fname )
433
- if len (r ) == 1 :
434
- run_name , device , stream_kind = r [0 ]
435
- gate_num , trigger_num = None , None
436
- else :
437
- # easy case for nidaq, example: sglx_xxx.nidq
438
- r = re .findall (r"(\S*)\.(\S*)" , fname )
439
- run_name , device = r [0 ]
440
- gate_num , trigger_num , stream_kind = None , None , None
450
+ raise ValueError (f"Cannot parse filename { fname } " )
441
451
442
452
if gate_num is not None :
443
453
gate_num = int (gate_num )
444
- if trigger_num is not None :
454
+ if trigger_num is not None and trigger_num != "cat" :
445
455
trigger_num = int (trigger_num )
446
456
447
457
return (run_name , gate_num , trigger_num , device , stream_kind )
0 commit comments