@@ -34,6 +34,10 @@ def activate(ephys_schema_name, probe_schema_name=None, *, create_schema=True,
34
34
+ get_ephys_root_data_dir() -> str
35
35
Retrieve the root data directory - e.g. containing all subject/sessions data
36
36
:return: a string for full path to the root data directory
37
+ + get_clustering_root_data_dir() -> str
38
+ Retrieve the root data directory containing all subject/sessions clustering data
39
+ Note: if not provided, use "get_ephys_root_data_dir()"
40
+ :return: a string for full path to the clustering root data directory
37
41
+ get_session_directory(session_key: dict) -> str
38
42
Retrieve the session directory containing the recorded Neuropixels data for a given Session
39
43
:param session_key: a dictionary of one Session `key`
@@ -60,12 +64,25 @@ def activate(ephys_schema_name, probe_schema_name=None, *, create_schema=True,
60
64
def get_ephys_root_data_dir () -> str :
61
65
"""
62
66
get_ephys_root_data_dir() -> str
63
- Retrieve the root data directory - e.g. containing all subject/sessions data
64
- :return: a string for full path to the root data directory
67
+ Retrieve the root data directory - e.g. containing all subject/sessions ephys data
68
+ :return: a string for full path to the ephys root data directory
65
69
"""
66
70
return _linking_module .get_ephys_root_data_dir ()
67
71
68
72
73
+ def get_clustering_root_data_dir () -> str :
74
+ """
75
+ get_clustering_root_data_dir() -> str
76
+ Retrieve the root data directory containing all subject/sessions clustering data
77
+ Note: if not provided, use "get_ephys_root_data_dir()"
78
+ :return: a string for full path to the clustering root data directory
79
+ """
80
+ if not hasattr (_linking_module , 'get_clustering_root_data_dir' ):
81
+ return get_ephys_root_data_dir ()
82
+
83
+ return _linking_module .get_clustering_root_data_dir ()
84
+
85
+
69
86
def get_session_directory (session_key : dict ) -> str :
70
87
"""
71
88
get_session_directory(session_key: dict) -> str
@@ -396,7 +413,7 @@ class Clustering(dj.Imported):
396
413
"""
397
414
398
415
def make (self , key ):
399
- root_dir = pathlib .Path (get_ephys_root_data_dir ())
416
+ root_dir = pathlib .Path (get_clustering_root_data_dir ())
400
417
task_mode , output_dir = (ClusteringTask & key ).fetch1 (
401
418
'task_mode' , 'clustering_output_dir' )
402
419
ks_dir = root_dir / output_dir
@@ -435,7 +452,7 @@ def create1_from_clustering_task(self, key, curation_note=''):
435
452
raise ValueError (f'No corresponding entry in Clustering available'
436
453
f' for: { key } ; do `Clustering.populate(key)`' )
437
454
438
- root_dir = pathlib .Path (get_ephys_root_data_dir ())
455
+ root_dir = pathlib .Path (get_clustering_root_data_dir ())
439
456
task_mode , output_dir = (ClusteringTask & key ).fetch1 (
440
457
'task_mode' , 'clustering_output_dir' )
441
458
ks_dir = root_dir / output_dir
@@ -468,7 +485,7 @@ class Unit(dj.Part):
468
485
"""
469
486
470
487
def make (self , key ):
471
- root_dir = pathlib .Path (get_ephys_root_data_dir ())
488
+ root_dir = pathlib .Path (get_clustering_root_data_dir ())
472
489
ks_dir = root_dir / (Curation & key ).fetch1 ('curation_output_dir' )
473
490
ks = kilosort .Kilosort (ks_dir )
474
491
acq_software = (EphysRecording & key ).fetch1 ('acq_software' )
@@ -539,7 +556,7 @@ def key_source(self):
539
556
return Curation ()
540
557
541
558
def make (self , key ):
542
- root_dir = pathlib .Path (get_ephys_root_data_dir ())
559
+ root_dir = pathlib .Path (get_clustering_root_data_dir ())
543
560
ks_dir = root_dir / (Curation & key ).fetch1 ('curation_output_dir' )
544
561
ks = kilosort .Kilosort (ks_dir )
545
562
@@ -572,8 +589,9 @@ def make(self, key):
572
589
'peak_chn_waveform_mean' : channel_waveform })
573
590
else :
574
591
if acq_software == 'SpikeGLX' :
575
- npx_meta_fp = root_dir / (EphysRecording .EphysFile & key
576
- & 'file_path LIKE "%.ap.meta"' ).fetch1 ('file_path' )
592
+ ephys_root_dir = get_ephys_root_data_dir ()
593
+ npx_meta_fp = ephys_root_dir / (EphysRecording .EphysFile & key
594
+ & 'file_path LIKE "%.ap.meta"' ).fetch1 ('file_path' )
577
595
npx_recording = spikeglx .SpikeGLX (npx_meta_fp .parent )
578
596
elif acq_software == 'OpenEphys' :
579
597
sess_dir = pathlib .Path (get_session_directory (key ))
@@ -636,8 +654,8 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
636
654
root_dir = pathlib .Path (get_ephys_root_data_dir ())
637
655
if acq_software == 'SpikeGLX' :
638
656
npx_meta_path = root_dir / (EphysRecording .EphysFile
639
- & ephys_recording_key
640
- & 'file_path LIKE "%.ap.meta"' ).fetch1 ('file_path' )
657
+ & ephys_recording_key
658
+ & 'file_path LIKE "%.ap.meta"' ).fetch1 ('file_path' )
641
659
neuropixels_dir = (root_dir / npx_meta_path ).parent
642
660
643
661
meta_filepath = next (pathlib .Path (neuropixels_dir ).glob ('*.ap.meta' ))
@@ -651,9 +669,9 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
651
669
for recorded_site , (shank , shank_col , shank_row , _ ) in enumerate (
652
670
spikeglx_meta .shankmap ['data' ]):
653
671
channel2electrode_map [recorded_site ] = (q_electrodes
654
- & {'shank' : shank ,
655
- 'shank_col' : shank_col ,
656
- 'shank_row' : shank_row }).fetch1 ('KEY' )
672
+ & {'shank' : shank ,
673
+ 'shank_col' : shank_col ,
674
+ 'shank_row' : shank_row }).fetch1 ('KEY' )
657
675
elif acq_software == 'OpenEphys' :
658
676
sess_dir = pathlib .Path (get_session_directory (ephys_recording_key ))
659
677
loaded_oe = openephys .OpenEphys (sess_dir )
@@ -665,7 +683,8 @@ def get_neuropixels_channel2electrode_map(ephys_recording_key, acq_software):
665
683
* EphysRecording & ephys_recording_key )
666
684
channel2electrode_map = {}
667
685
for chn_idx in oe_probe .ap_meta ['channels_ids' ]:
668
- channel2electrode_map [chn_idx ] = (q_electrodes & {'electrode' : chn_idx }).fetch1 ('KEY' )
686
+ channel2electrode_map [chn_idx ] = (q_electrodes
687
+ & {'electrode' : chn_idx }).fetch1 ('KEY' )
669
688
670
689
return channel2electrode_map
671
690
0 commit comments