Skip to content

Commit 181677e

Browse files
committed
See details
- Apply black - Remove trailing whitespace - Reduce flake8 exceptions - Move imports to top - Remove unused imports (e.g., re, pathlib, log_from_json) - Add __all__ to init files specifying imports loaded - Add `noqa: C901` selectively where complexity is high - l -> line for _read_meta func in spikeglx.py - give version a default value before loading
1 parent 47de1d5 commit 181677e

17 files changed

+179
-149
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ repos:
4242
- "--select=B,C,E,F,W,T4,B9"
4343

4444
# these are errors that will be ignored by flake8
45-
# check out their meaning here
46-
# https://flake8.pycqa.org/en/latest/user/error-codes.html
47-
- "--ignore=C813,C901,E203,E266,E501,W503,F403,F401,E402,W605"
45+
# https://www.flake8rules.com/rules/{code}.html
46+
- "--ignore=E203,E501,W503,W605"
47+
# E203 - Colons should not have any space before them.
48+
# Needed for list indexing
49+
# E501 - Line lengths are recommended to be no greater than 79 characters.
50+
# Needed as we conform to 88
51+
# W503 - Line breaks should occur after the binary operator.
52+
# Needed because not compatible with black
53+
# W605 - a backslash-character pair that is not a valid escape sequence now
54+
# generates a DeprecationWarning. This will eventually become a SyntaxError.
55+
# Needed because we use \d as an escape sequence

docs/src/api/make_pages.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@
4141

4242
with mkdocs_gen_files.open("api/navigation.md", "w") as nav_file:
4343
nav_file.writelines(nav.build_literate_nav())
44-

element_array_ephys/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import datajoint as dj
22
import logging
33
import os
4+
from . import ephys_acute as ephys
45

6+
__all__ = ["ephys", "get_logger"]
57

68
dj.config["enable_python_native_blobs"] = True
79

@@ -10,6 +12,3 @@ def get_logger(name):
1012
log = logging.getLogger(name)
1113
log.setLevel(os.getenv("LOGLEVEL", "INFO"))
1214
return log
13-
14-
15-
from . import ephys_acute as ephys

element_array_ephys/ephys_acute.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class AcquisitionSoftware(dj.Lookup):
127127
"""
128128

129129
definition = """ # Software used for recording of neuropixels probes
130-
acq_software: varchar(24)
130+
acq_software: varchar(24)
131131
"""
132132
contents = zip(["SpikeGLX", "Open Ephys"])
133133

@@ -264,7 +264,7 @@ class EphysRecording(dj.Imported):
264264

265265
definition = """
266266
# Ephys recording from a probe insertion for a given session.
267-
-> ProbeInsertion
267+
-> ProbeInsertion
268268
---
269269
-> probe.ElectrodeConfig
270270
-> AcquisitionSoftware
@@ -465,9 +465,9 @@ class Electrode(dj.Part):
465465

466466
definition = """
467467
-> master
468-
-> probe.ElectrodeConfig.Electrode
468+
-> probe.ElectrodeConfig.Electrode
469469
---
470-
lfp: longblob # (uV) recorded lfp at this electrode
470+
lfp: longblob # (uV) recorded lfp at this electrode
471471
"""
472472

473473
# Only store LFP for every 9th channel, due to high channel density,
@@ -615,7 +615,7 @@ class ClusteringParamSet(dj.Lookup):
615615
# Parameter set to be used in a clustering procedure
616616
paramset_idx: smallint
617617
---
618-
-> ClusteringMethod
618+
-> ClusteringMethod
619619
paramset_desc: varchar(128)
620620
param_set_hash: uuid
621621
unique index (param_set_hash)
@@ -800,7 +800,7 @@ class Clustering(dj.Imported):
800800
# Clustering Procedure
801801
-> ClusteringTask
802802
---
803-
clustering_time: datetime # time of generation of this set of clustering results
803+
clustering_time: datetime # time of generation of this set of clustering results
804804
package_version='': varchar(16)
805805
"""
806806

@@ -925,11 +925,11 @@ class Curation(dj.Manual):
925925
-> Clustering
926926
curation_id: int
927927
---
928-
curation_time: datetime # time of generation of this set of curated clustering results
928+
curation_time: datetime # time of generation of this set of curated clustering results
929929
curation_output_dir: varchar(255) # output directory of the curated results, relative to root data directory
930930
quality_control: bool # has this clustering result undergone quality control?
931931
manual_curation: bool # has manual curation been performed on this clustering result?
932-
curation_note='': varchar(2000)
932+
curation_note='': varchar(2000)
933933
"""
934934

935935
def create1_from_clustering_task(self, key, curation_note=""):
@@ -978,7 +978,7 @@ class CuratedClustering(dj.Imported):
978978

979979
definition = """
980980
# Clustering results of a curation.
981-
-> Curation
981+
-> Curation
982982
"""
983983

984984
class Unit(dj.Part):
@@ -1005,7 +1005,7 @@ class Unit(dj.Part):
10051005
spike_count: int # how many spikes in this recording for this unit
10061006
spike_times: longblob # (s) spike times of this unit, relative to the start of the EphysRecording
10071007
spike_sites : longblob # array of electrode associated with each spike
1008-
spike_depths=null : longblob # (um) array of depths associated with each spike, relative to the (0, 0) of the probe
1008+
spike_depths=null : longblob # (um) array of depths associated with each spike, relative to the (0, 0) of the probe
10091009
"""
10101010

10111011
def make(self, key):
@@ -1131,8 +1131,8 @@ class Waveform(dj.Part):
11311131
# Spike waveforms and their mean across spikes for the given unit
11321132
-> master
11331133
-> CuratedClustering.Unit
1134-
-> probe.ElectrodeConfig.Electrode
1135-
---
1134+
-> probe.ElectrodeConfig.Electrode
1135+
---
11361136
waveform_mean: longblob # (uV) mean waveform across spikes of the given unit
11371137
waveforms=null: longblob # (uV) (spike x sample) waveforms of a sampling of spikes at the given electrode for the given unit
11381138
"""
@@ -1260,7 +1260,7 @@ class QualityMetrics(dj.Imported):
12601260

12611261
definition = """
12621262
# Clusters and waveforms metrics
1263-
-> CuratedClustering
1263+
-> CuratedClustering
12641264
"""
12651265

12661266
class Cluster(dj.Part):
@@ -1285,26 +1285,26 @@ class Cluster(dj.Part):
12851285
contamination_rate (float): Frequency of spikes in the refractory period.
12861286
"""
12871287

1288-
definition = """
1288+
definition = """
12891289
# Cluster metrics for a particular unit
12901290
-> master
12911291
-> CuratedClustering.Unit
12921292
---
1293-
firing_rate=null: float # (Hz) firing rate for a unit
1293+
firing_rate=null: float # (Hz) firing rate for a unit
12941294
snr=null: float # signal-to-noise ratio for a unit
12951295
presence_ratio=null: float # fraction of time in which spikes are present
12961296
isi_violation=null: float # rate of ISI violation as a fraction of overall rate
12971297
number_violation=null: int # total number of ISI violations
12981298
amplitude_cutoff=null: float # estimate of miss rate based on amplitude histogram
12991299
isolation_distance=null: float # distance to nearest cluster in Mahalanobis space
1300-
l_ratio=null: float #
1300+
l_ratio=null: float #
13011301
d_prime=null: float # Classification accuracy based on LDA
13021302
nn_hit_rate=null: float # Fraction of neighbors for target cluster that are also in target cluster
13031303
nn_miss_rate=null: float # Fraction of neighbors outside target cluster that are in target cluster
13041304
silhouette_score=null: float # Standard metric for cluster overlap
13051305
max_drift=null: float # Maximum change in spike depth throughout recording
1306-
cumulative_drift=null: float # Cumulative change in spike depth throughout recording
1307-
contamination_rate=null: float #
1306+
cumulative_drift=null: float # Cumulative change in spike depth throughout recording
1307+
contamination_rate=null: float #
13081308
"""
13091309

13101310
class Waveform(dj.Part):
@@ -1324,7 +1324,7 @@ class Waveform(dj.Part):
13241324
velocity_below (float) inverse velocity of waveform propagation from soma toward the bottom of the probe.
13251325
"""
13261326

1327-
definition = """
1327+
definition = """
13281328
# Waveform metrics for a particular unit
13291329
-> master
13301330
-> CuratedClustering.Unit

element_array_ephys/ephys_chronic.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datajoint as dj
22
import pathlib
3-
import re
43
import numpy as np
54
import inspect
65
import importlib
@@ -127,7 +126,7 @@ class AcquisitionSoftware(dj.Lookup):
127126
"""
128127

129128
definition = """ # Software used for recording of neuropixels probes
130-
acq_software: varchar(24)
129+
acq_software: varchar(24)
131130
"""
132131
contents = zip(["SpikeGLX", "Open Ephys"])
133132

@@ -144,7 +143,7 @@ class ProbeInsertion(dj.Manual):
144143

145144
definition = """
146145
# Probe insertion chronically implanted into an animal.
147-
-> Subject
146+
-> Subject
148147
insertion_number: tinyint unsigned
149148
---
150149
-> probe.Probe
@@ -197,7 +196,7 @@ class EphysRecording(dj.Imported):
197196
definition = """
198197
# Ephys recording from a probe insertion for a given session.
199198
-> Session
200-
-> ProbeInsertion
199+
-> ProbeInsertion
201200
---
202201
-> probe.ElectrodeConfig
203202
-> AcquisitionSoftware
@@ -399,9 +398,9 @@ class Electrode(dj.Part):
399398

400399
definition = """
401400
-> master
402-
-> probe.ElectrodeConfig.Electrode
401+
-> probe.ElectrodeConfig.Electrode
403402
---
404-
lfp: longblob # (uV) recorded lfp at this electrode
403+
lfp: longblob # (uV) recorded lfp at this electrode
405404
"""
406405

407406
# Only store LFP for every 9th channel, due to high channel density,
@@ -549,7 +548,7 @@ class ClusteringParamSet(dj.Lookup):
549548
# Parameter set to be used in a clustering procedure
550549
paramset_idx: smallint
551550
---
552-
-> ClusteringMethod
551+
-> ClusteringMethod
553552
paramset_desc: varchar(128)
554553
param_set_hash: uuid
555554
unique index (param_set_hash)
@@ -732,7 +731,7 @@ class Clustering(dj.Imported):
732731
# Clustering Procedure
733732
-> ClusteringTask
734733
---
735-
clustering_time: datetime # time of generation of this set of clustering results
734+
clustering_time: datetime # time of generation of this set of clustering results
736735
package_version='': varchar(16)
737736
"""
738737

@@ -857,11 +856,11 @@ class Curation(dj.Manual):
857856
-> Clustering
858857
curation_id: int
859858
---
860-
curation_time: datetime # time of generation of this set of curated clustering results
859+
curation_time: datetime # time of generation of this set of curated clustering results
861860
curation_output_dir: varchar(255) # output directory of the curated results, relative to root data directory
862861
quality_control: bool # has this clustering result undergone quality control?
863862
manual_curation: bool # has manual curation been performed on this clustering result?
864-
curation_note='': varchar(2000)
863+
curation_note='': varchar(2000)
865864
"""
866865

867866
def create1_from_clustering_task(self, key, curation_note: str = ""):
@@ -910,7 +909,7 @@ class CuratedClustering(dj.Imported):
910909

911910
definition = """
912911
# Clustering results of a curation.
913-
-> Curation
912+
-> Curation
914913
"""
915914

916915
class Unit(dj.Part):
@@ -937,7 +936,7 @@ class Unit(dj.Part):
937936
spike_count: int # how many spikes in this recording for this unit
938937
spike_times: longblob # (s) spike times of this unit, relative to the start of the EphysRecording
939938
spike_sites : longblob # array of electrode associated with each spike
940-
spike_depths=null : longblob # (um) array of depths associated with each spike, relative to the (0, 0) of the probe
939+
spike_depths=null : longblob # (um) array of depths associated with each spike, relative to the (0, 0) of the probe
941940
"""
942941

943942
def make(self, key):
@@ -1063,8 +1062,8 @@ class Waveform(dj.Part):
10631062
# Spike waveforms and their mean across spikes for the given unit
10641063
-> master
10651064
-> CuratedClustering.Unit
1066-
-> probe.ElectrodeConfig.Electrode
1067-
---
1065+
-> probe.ElectrodeConfig.Electrode
1066+
---
10681067
waveform_mean: longblob # (uV) mean waveform across spikes of the given unit
10691068
waveforms=null: longblob # (uV) (spike x sample) waveforms of a sampling of spikes at the given electrode for the given unit
10701069
"""
@@ -1192,7 +1191,7 @@ class QualityMetrics(dj.Imported):
11921191

11931192
definition = """
11941193
# Clusters and waveforms metrics
1195-
-> CuratedClustering
1194+
-> CuratedClustering
11961195
"""
11971196

11981197
class Cluster(dj.Part):
@@ -1217,26 +1216,26 @@ class Cluster(dj.Part):
12171216
contamination_rate (float): Frequency of spikes in the refractory period.
12181217
"""
12191218

1220-
definition = """
1219+
definition = """
12211220
# Cluster metrics for a particular unit
12221221
-> master
12231222
-> CuratedClustering.Unit
12241223
---
1225-
firing_rate=null: float # (Hz) firing rate for a unit
1224+
firing_rate=null: float # (Hz) firing rate for a unit
12261225
snr=null: float # signal-to-noise ratio for a unit
12271226
presence_ratio=null: float # fraction of time in which spikes are present
12281227
isi_violation=null: float # rate of ISI violation as a fraction of overall rate
12291228
number_violation=null: int # total number of ISI violations
12301229
amplitude_cutoff=null: float # estimate of miss rate based on amplitude histogram
12311230
isolation_distance=null: float # distance to nearest cluster in Mahalanobis space
1232-
l_ratio=null: float #
1231+
l_ratio=null: float #
12331232
d_prime=null: float # Classification accuracy based on LDA
12341233
nn_hit_rate=null: float # Fraction of neighbors for target cluster that are also in target cluster
12351234
nn_miss_rate=null: float # Fraction of neighbors outside target cluster that are in target cluster
12361235
silhouette_score=null: float # Standard metric for cluster overlap
12371236
max_drift=null: float # Maximum change in spike depth throughout recording
1238-
cumulative_drift=null: float # Cumulative change in spike depth throughout recording
1239-
contamination_rate=null: float #
1237+
cumulative_drift=null: float # Cumulative change in spike depth throughout recording
1238+
contamination_rate=null: float #
12401239
"""
12411240

12421241
class Waveform(dj.Part):
@@ -1256,7 +1255,7 @@ class Waveform(dj.Part):
12561255
velocity_below (float) inverse velocity of waveform propagation from soma toward the bottom of the probe.
12571256
"""
12581257

1259-
definition = """
1258+
definition = """
12601259
# Waveform metrics for a particular unit
12611260
-> master
12621261
-> CuratedClustering.Unit

0 commit comments

Comments
 (0)