1
- import datajoint as dj
1
+ import gc
2
+ import importlib
3
+ import inspect
2
4
import pathlib
3
5
import re
4
- import numpy as np
5
- import inspect
6
- import importlib
7
- import gc
8
6
from decimal import Decimal
9
- import pandas as pd
10
7
11
- from element_interface .utils import find_root_directory , find_full_path , dict_to_uuid
8
+ import datajoint as dj
9
+ import numpy as np
10
+ import pandas as pd
11
+ from element_interface .utils import dict_to_uuid , find_full_path , find_root_directory
12
12
13
- from .readers import spikeglx , kilosort , openephys
14
- from . import probe , get_logger , ephys_report
13
+ from . import ephys_report , get_logger , probe
14
+ from .readers import kilosort , openephys , spikeglx
15
15
16
16
log = get_logger (__name__ )
17
17
@@ -127,7 +127,7 @@ class AcquisitionSoftware(dj.Lookup):
127
127
"""
128
128
129
129
definition = """ # Software used for recording of neuropixels probes
130
- acq_software: varchar(24)
130
+ acq_software: varchar(24)
131
131
"""
132
132
contents = zip (["SpikeGLX" , "Open Ephys" ])
133
133
@@ -265,7 +265,7 @@ class EphysRecording(dj.Imported):
265
265
266
266
definition = """
267
267
# Ephys recording from a probe insertion for a given session.
268
- -> ProbeInsertion
268
+ -> ProbeInsertion
269
269
---
270
270
-> probe.ElectrodeConfig
271
271
-> AcquisitionSoftware
@@ -473,9 +473,9 @@ class Electrode(dj.Part):
473
473
474
474
definition = """
475
475
-> master
476
- -> probe.ElectrodeConfig.Electrode
476
+ -> probe.ElectrodeConfig.Electrode
477
477
---
478
- lfp: longblob # (uV) recorded lfp at this electrode
478
+ lfp: longblob # (uV) recorded lfp at this electrode
479
479
"""
480
480
481
481
# Only store LFP for every 9th channel, due to high channel density,
@@ -629,7 +629,7 @@ class ClusteringParamSet(dj.Lookup):
629
629
# Parameter set to be used in a clustering procedure
630
630
paramset_idx: smallint
631
631
---
632
- -> ClusteringMethod
632
+ -> ClusteringMethod
633
633
paramset_desc: varchar(128)
634
634
param_set_hash: uuid
635
635
unique index (param_set_hash)
@@ -694,7 +694,7 @@ class ClusterQualityLabel(dj.Lookup):
694
694
695
695
Attributes:
696
696
cluster_quality_label (foreign key, varchar(100) ): Cluster quality type.
697
- cluster_quality_description (varchar(4000) ): Description of the cluster quality type.
697
+ cluster_quality_description ( varchar(4000) ): Description of the cluster quality type.
698
698
"""
699
699
700
700
definition = """
@@ -718,7 +718,7 @@ class ClusteringTask(dj.Manual):
718
718
Attributes:
719
719
EphysRecording (foreign key): EphysRecording primary key.
720
720
ClusteringParamSet (foreign key): ClusteringParamSet primary key.
721
- clustering_outdir_dir ( varchar (255) ): Relative path to output clustering results.
721
+ clustering_output_dir ( varchar (255) ): Relative path to output clustering results.
722
722
task_mode (enum): `Trigger` computes clustering or and `load` imports existing data.
723
723
"""
724
724
@@ -808,14 +808,14 @@ class Clustering(dj.Imported):
808
808
Attributes:
809
809
ClusteringTask (foreign key): ClusteringTask primary key.
810
810
clustering_time (datetime): Time when clustering results are generated.
811
- package_version (varchar(16) ): Package version used for a clustering analysis.
811
+ package_version ( varchar(16) ): Package version used for a clustering analysis.
812
812
"""
813
813
814
814
definition = """
815
815
# Clustering Procedure
816
816
-> ClusteringTask
817
817
---
818
- clustering_time: datetime # time of generation of this set of clustering results
818
+ clustering_time: datetime # time of generation of this set of clustering results
819
819
package_version='': varchar(16)
820
820
"""
821
821
@@ -857,6 +857,10 @@ def make(self, key):
857
857
spikeglx_meta_filepath .parent
858
858
)
859
859
spikeglx_recording .validate_file ("ap" )
860
+ run_CatGT = (
861
+ params .pop ("run_CatGT" , True )
862
+ and "_tcat." not in spikeglx_meta_filepath .stem
863
+ )
860
864
861
865
if clustering_method .startswith ("pykilosort" ):
862
866
kilosort_triggering .run_pykilosort (
@@ -877,7 +881,7 @@ def make(self, key):
877
881
ks_output_dir = kilosort_dir ,
878
882
params = params ,
879
883
KS2ver = f'{ Decimal (clustering_method .replace ("kilosort" , "" )):.1f} ' ,
880
- run_CatGT = True ,
884
+ run_CatGT = run_CatGT ,
881
885
)
882
886
run_kilosort .run_modules ()
883
887
elif acq_software == "Open Ephys" :
@@ -930,22 +934,22 @@ class Curation(dj.Manual):
930
934
Clustering (foreign key): Clustering primary key.
931
935
curation_id (foreign key, int): Unique curation ID.
932
936
curation_time (datetime): Time when curation results are generated.
933
- curation_output_dir (varchar(255) ): Output directory of the curated results.
937
+ curation_output_dir ( varchar(255) ): Output directory of the curated results.
934
938
quality_control (bool): If True, this clustering result has undergone quality control.
935
939
manual_curation (bool): If True, manual curation has been performed on this clustering result.
936
- curation_note (varchar(2000) ): Notes about the curation task.
940
+ curation_note ( varchar(2000) ): Notes about the curation task.
937
941
"""
938
942
939
943
definition = """
940
944
# Manual curation procedure
941
945
-> Clustering
942
946
curation_id: int
943
947
---
944
- curation_time: datetime # time of generation of this set of curated clustering results
948
+ curation_time: datetime # time of generation of this set of curated clustering results
945
949
curation_output_dir: varchar(255) # output directory of the curated results, relative to root data directory
946
950
quality_control: bool # has this clustering result undergone quality control?
947
951
manual_curation: bool # has manual curation been performed on this clustering result?
948
- curation_note='': varchar(2000)
952
+ curation_note='': varchar(2000)
949
953
"""
950
954
951
955
def create1_from_clustering_task (self , key , curation_note = "" ):
@@ -994,7 +998,7 @@ class CuratedClustering(dj.Imported):
994
998
995
999
definition = """
996
1000
# Clustering results of a curation.
997
- -> Curation
1001
+ -> Curation
998
1002
"""
999
1003
1000
1004
class Unit (dj .Part ):
@@ -1021,7 +1025,7 @@ class Unit(dj.Part):
1021
1025
spike_count: int # how many spikes in this recording for this unit
1022
1026
spike_times: longblob # (s) spike times of this unit, relative to the start of the EphysRecording
1023
1027
spike_sites : longblob # array of electrode associated with each spike
1024
- spike_depths=null : longblob # (um) array of depths associated with each spike, relative to the (0, 0) of the probe
1028
+ spike_depths=null : longblob # (um) array of depths associated with each spike, relative to the (0, 0) of the probe
1025
1029
"""
1026
1030
1027
1031
def make (self , key ):
@@ -1149,8 +1153,8 @@ class Waveform(dj.Part):
1149
1153
# Spike waveforms and their mean across spikes for the given unit
1150
1154
-> master
1151
1155
-> CuratedClustering.Unit
1152
- -> probe.ElectrodeConfig.Electrode
1153
- ---
1156
+ -> probe.ElectrodeConfig.Electrode
1157
+ ---
1154
1158
waveform_mean: longblob # (uV) mean waveform across spikes of the given unit
1155
1159
waveforms=null: longblob # (uV) (spike x sample) waveforms of a sampling of spikes at the given electrode for the given unit
1156
1160
"""
@@ -1281,7 +1285,7 @@ class QualityMetrics(dj.Imported):
1281
1285
1282
1286
definition = """
1283
1287
# Clusters and waveforms metrics
1284
- -> CuratedClustering
1288
+ -> CuratedClustering
1285
1289
"""
1286
1290
1287
1291
class Cluster (dj .Part ):
@@ -1306,26 +1310,26 @@ class Cluster(dj.Part):
1306
1310
contamination_rate (float): Frequency of spikes in the refractory period.
1307
1311
"""
1308
1312
1309
- definition = """
1313
+ definition = """
1310
1314
# Cluster metrics for a particular unit
1311
1315
-> master
1312
1316
-> CuratedClustering.Unit
1313
1317
---
1314
- firing_rate=null: float # (Hz) firing rate for a unit
1318
+ firing_rate=null: float # (Hz) firing rate for a unit
1315
1319
snr=null: float # signal-to-noise ratio for a unit
1316
1320
presence_ratio=null: float # fraction of time in which spikes are present
1317
1321
isi_violation=null: float # rate of ISI violation as a fraction of overall rate
1318
1322
number_violation=null: int # total number of ISI violations
1319
1323
amplitude_cutoff=null: float # estimate of miss rate based on amplitude histogram
1320
1324
isolation_distance=null: float # distance to nearest cluster in Mahalanobis space
1321
- l_ratio=null: float #
1325
+ l_ratio=null: float #
1322
1326
d_prime=null: float # Classification accuracy based on LDA
1323
1327
nn_hit_rate=null: float # Fraction of neighbors for target cluster that are also in target cluster
1324
1328
nn_miss_rate=null: float # Fraction of neighbors outside target cluster that are in target cluster
1325
1329
silhouette_score=null: float # Standard metric for cluster overlap
1326
1330
max_drift=null: float # Maximum change in spike depth throughout recording
1327
- cumulative_drift=null: float # Cumulative change in spike depth throughout recording
1328
- contamination_rate=null: float #
1331
+ cumulative_drift=null: float # Cumulative change in spike depth throughout recording
1332
+ contamination_rate=null: float #
1329
1333
"""
1330
1334
1331
1335
class Waveform (dj .Part ):
@@ -1345,7 +1349,7 @@ class Waveform(dj.Part):
1345
1349
velocity_below (float) inverse velocity of waveform propagation from soma toward the bottom of the probe.
1346
1350
"""
1347
1351
1348
- definition = """
1352
+ definition = """
1349
1353
# Waveform metrics for a particular unit
1350
1354
-> master
1351
1355
-> CuratedClustering.Unit
0 commit comments