Skip to content

Commit

Permalink
Merge pull request #1 from ttngu207/nei_nienborg
Browse files Browse the repository at this point in the history
integrate with the latest version of SpikeInterface
  • Loading branch information
kushalbakshi authored Jun 4, 2024
2 parents 6a6e7b7 + 5f69808 commit 988ca7b
Show file tree
Hide file tree
Showing 9 changed files with 414 additions and 473 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.4.0] - 2024-05-28

+ Add - support for SpikeInterface version >= 0.101.0 (updated API)
+ Add - feature for memoization of spike sorting results (prevent duplicated runs)


## [0.3.4] - 2024-03-22

+ Add - pytest
Expand Down
21 changes: 0 additions & 21 deletions element_array_ephys/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
"""
isort:skip_file
"""

import logging
import os

import datajoint as dj


__all__ = ["ephys", "get_logger"]

dj.config["enable_python_native_blobs"] = True


def get_logger(name):
log = logging.getLogger(name)
log.setLevel(os.getenv("LOGLEVEL", "INFO"))
return log


from . import ephys_acute as ephys
510 changes: 200 additions & 310 deletions element_array_ephys/ephys_no_curation.py

Large diffs are not rendered by default.

103 changes: 53 additions & 50 deletions element_array_ephys/probe.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""
Neuropixels Probes
"""

import datajoint as dj

from .readers import probe_geometry
from .readers.probe_geometry import build_electrode_layouts

log = dj.logger

schema = dj.schema()


Expand All @@ -33,20 +31,6 @@ def activate(
schema_name, create_schema=create_schema, create_tables=create_tables
)

# Add neuropixels probes
for probe_type in (
"neuropixels 1.0 - 3A",
"neuropixels 1.0 - 3B",
"neuropixels UHD",
"neuropixels 2.0 - SS",
"neuropixels 2.0 - MS",
):
if not (ProbeType & {"probe_type": probe_type}):
try:
ProbeType.create_neuropixels_probe(probe_type)
except dj.errors.DataJointError as e:
print(f"Unable to create probe-type: {probe_type}\n{str(e)}")


@schema
class ProbeType(dj.Lookup):
Expand Down Expand Up @@ -87,39 +71,10 @@ class Electrode(dj.Part):

@staticmethod
def create_neuropixels_probe(probe_type: str = "neuropixels 1.0 - 3A"):
"""
Create `ProbeType` and `Electrode` for neuropixels probes:
+ neuropixels 1.0 - 3A
+ neuropixels 1.0 - 3B
+ neuropixels UHD
+ neuropixels 2.0 - SS
+ neuropixels 2.0 - MS

For electrode location, the (0, 0) is the
bottom left corner of the probe (ignore the tip portion)
Electrode numbering is 0-indexing
"""

npx_probes_config = probe_geometry.M
npx_probes_config["neuropixels 1.0 - 3A"] = npx_probes_config["3A"]
npx_probes_config["neuropixels 1.0 - 3B"] = npx_probes_config["NP1010"]
npx_probes_config["neuropixels UHD"] = npx_probes_config["NP1100"]
npx_probes_config["neuropixels 2.0 - SS"] = npx_probes_config["NP2000"]
npx_probes_config["neuropixels 2.0 - MS"] = npx_probes_config["NP2010"]

probe_type = {"probe_type": probe_type}
probe_params = dict(
zip(
probe_geometry.geom_param_names,
npx_probes_config[probe_type["probe_type"]],
)
log.warning(
"Class method `ProbeType.create_neuropixels_probe` is deprecated. Use `create_neuropixels_probe` instead.",
)
electrode_layouts = probe_geometry.build_npx_probe(
**{**probe_params, **probe_type}
)
with ProbeType.connection.transaction:
ProbeType.insert1(probe_type, skip_duplicates=True)
ProbeType.Electrode.insert(electrode_layouts, skip_duplicates=True)
return create_neuropixels_probe(probe_type)


@schema
Expand Down Expand Up @@ -171,3 +126,51 @@ class Electrode(dj.Part):
-> master
-> ProbeType.Electrode
"""


def create_neuropixels_probe_types():
# Add neuropixels probes
for probe_type in (
"neuropixels 1.0 - 3A",
"neuropixels 1.0 - 3B",
"neuropixels UHD",
"neuropixels 2.0 - SS",
"neuropixels 2.0 - MS",
):
if not (ProbeType & {"probe_type": probe_type}):
create_neuropixels_probe(probe_type)


def create_neuropixels_probe(probe_type: str = "neuropixels 1.0 - 3A"):
"""
Create `ProbeType` and `Electrode` for neuropixels probes:
+ neuropixels 1.0 - 3A
+ neuropixels 1.0 - 3B
+ neuropixels UHD
+ neuropixels 2.0 - SS
+ neuropixels 2.0 - MS

For electrode location, the (0, 0) is the
bottom left corner of the probe (ignore the tip portion)
Electrode numbering is 0-indexing
"""
npx_probes_config = probe_geometry.M
npx_probes_config["neuropixels 1.0 - 3A"] = npx_probes_config["3A"]
npx_probes_config["neuropixels 1.0 - 3B"] = npx_probes_config["NP1010"]
npx_probes_config["neuropixels UHD"] = npx_probes_config["NP1100"]
npx_probes_config["neuropixels 2.0 - SS"] = npx_probes_config["NP2000"]
npx_probes_config["neuropixels 2.0 - MS"] = npx_probes_config["NP2010"]

probe_type = {"probe_type": probe_type}
probe_params = dict(
zip(
probe_geometry.geom_param_names,
npx_probes_config[probe_type["probe_type"]],
)
)
electrode_layouts = probe_geometry.build_npx_probe(
**{**probe_params, **probe_type}
)
with ProbeType.connection.transaction:
ProbeType.insert1(probe_type)
ProbeType.Electrode.insert(electrode_layouts)
3 changes: 1 addition & 2 deletions element_array_ephys/spike_sorting/ecephys_spike_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


import datajoint as dj
from element_array_ephys import get_logger
from decimal import Decimal
import json
from datetime import datetime, timedelta
Expand All @@ -33,7 +32,7 @@
kilosort_triggering,
)

log = get_logger(__name__)
log = dj.logger

schema = dj.schema()

Expand Down
13 changes: 12 additions & 1 deletion element_array_ephys/spike_sorting/si_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from spikeinterface import preprocessing


def catGT(recording):
def CatGT(recording):
recording = si.preprocessing.phase_shift(recording)
recording = si.preprocessing.common_reference(
recording, operator="median", reference="global"
Expand Down Expand Up @@ -35,3 +35,14 @@ def IBLdestriping_modified(recording):
recording, operator="median", reference="global"
)
return recording


def NienborgLab_preproc(recording):
"""Preprocessing pipeline for 32chn ephys data from Trellis."""
recording = si.preprocessing.bandpass_filter(
recording=recording, freq_min=300, freq_max=6000
)
recording = si.preprocessing.common_reference(
recording=recording, operator="median"
)
return recording
Loading

0 comments on commit 988ca7b

Please sign in to comment.