From 15e3eb0cafd88a28447b105d57ed68622aaf44f8 Mon Sep 17 00:00:00 2001 From: Chris Langfield <34426450+chris-langfield@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:29:08 -0500 Subject: [PATCH] Rename neurodsp (#23) * initial drop-in replace * bump version and update changelog * you cant change history * update tests * catch and assert warning * add dummy module to warn user * flake * update change log * unused import --------- Co-authored-by: chris-langfield --- README.md | 2 +- release_notes.md | 5 +++ setup.py | 2 +- src/ibldsp/__init__.py | 0 src/{neurodsp => ibldsp}/cadzow.py | 0 src/{neurodsp => ibldsp}/cuda_tools.py | 0 src/{neurodsp => ibldsp}/destripe_gpu.py | 0 src/{neurodsp => ibldsp}/filter_gpu.py | 0 src/{neurodsp => ibldsp}/fourier.py | 0 src/{neurodsp => ibldsp}/raw_metrics.py | 4 +-- src/{neurodsp => ibldsp}/smooth.py | 2 +- src/{neurodsp => ibldsp}/sosfilt.cu | 0 src/{neurodsp => ibldsp}/spiketrains.py | 0 src/{neurodsp => ibldsp}/utils.py | 0 src/{neurodsp => ibldsp}/voltage.py | 4 +-- src/{neurodsp => ibldsp}/waveforms.py | 1 + src/neurodsp/__init__.py | 8 +++++ src/neuropixel.py | 2 +- src/neurowaveforms/model.py | 2 +- src/tests/integration/cpu/csd_experiments.py | 2 +- src/tests/integration/cpu/test_destripe.py | 2 +- src/tests/unit/cpu/test_dsp.py | 33 +++++++++++++++----- src/tests/unit/cpu/test_waveforms.py | 2 +- src/tests/unit/gpu/test_filter_gpu.py | 2 +- src/tests/unit/gpu/test_fourier.py | 2 +- 25 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 src/ibldsp/__init__.py rename src/{neurodsp => ibldsp}/cadzow.py (100%) rename src/{neurodsp => ibldsp}/cuda_tools.py (100%) rename src/{neurodsp => ibldsp}/destripe_gpu.py (100%) rename src/{neurodsp => ibldsp}/filter_gpu.py (100%) rename src/{neurodsp => ibldsp}/fourier.py (100%) rename src/{neurodsp => ibldsp}/raw_metrics.py (97%) rename src/{neurodsp => ibldsp}/smooth.py (99%) rename src/{neurodsp => ibldsp}/sosfilt.cu (100%) rename src/{neurodsp => ibldsp}/spiketrains.py (100%) rename src/{neurodsp => ibldsp}/utils.py (100%) rename src/{neurodsp => ibldsp}/voltage.py (99%) rename src/{neurodsp => ibldsp}/waveforms.py (99%) diff --git a/README.md b/README.md index f2ed5b7..d81eb1b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This relies on a fast fourier transform external library: `pip install pyfftw`. Minimal working example to destripe a neuropixel binary file. ```python from pathlib import Path -from neurodsp.voltage import decompress_destripe_cbin +from ibldsp.voltage import decompress_destripe_cbin sr_file = Path('/datadisk/Data/spike_sorting/pykilosort_tests/imec_385_100s.ap.bin') out_file = Path('/datadisk/scratch/imec_385_100s.ap.bin') diff --git a/release_notes.md b/release_notes.md index 5c7f134..e4af704 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,3 +1,8 @@ +# 0.9.1 +## 0.9.1 +- `neurodsp` is now `ibldsp`. Drop-in replacement of the package name is all that is required to update. The `neurodsp` name will disappear on +01-Sep-2024; until then both names will work. + # 0.9.0 ## 0.9.0 2024-01-17 - `neurodsp.utils.sync_timestamps`: uses FFT based correlation to speed up large arrays alignments diff --git a/setup.py b/setup.py index 689b73f..2c311ab 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="ibl-neuropixel", - version="0.9.0", + version="0.9.1", author="The International Brain Laboratory", description="Collection of tools for Neuropixel 1.0 and 2.0 probes data", long_description=long_description, diff --git a/src/ibldsp/__init__.py b/src/ibldsp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/neurodsp/cadzow.py b/src/ibldsp/cadzow.py similarity index 100% rename from src/neurodsp/cadzow.py rename to src/ibldsp/cadzow.py diff --git a/src/neurodsp/cuda_tools.py b/src/ibldsp/cuda_tools.py similarity index 100% rename from src/neurodsp/cuda_tools.py rename to src/ibldsp/cuda_tools.py diff --git a/src/neurodsp/destripe_gpu.py b/src/ibldsp/destripe_gpu.py similarity index 100% rename from src/neurodsp/destripe_gpu.py rename to src/ibldsp/destripe_gpu.py diff --git a/src/neurodsp/filter_gpu.py b/src/ibldsp/filter_gpu.py similarity index 100% rename from src/neurodsp/filter_gpu.py rename to src/ibldsp/filter_gpu.py diff --git a/src/neurodsp/fourier.py b/src/ibldsp/fourier.py similarity index 100% rename from src/neurodsp/fourier.py rename to src/ibldsp/fourier.py diff --git a/src/neurodsp/raw_metrics.py b/src/ibldsp/raw_metrics.py similarity index 97% rename from src/neurodsp/raw_metrics.py rename to src/ibldsp/raw_metrics.py index 0026526..d382752 100644 --- a/src/neurodsp/raw_metrics.py +++ b/src/ibldsp/raw_metrics.py @@ -1,5 +1,5 @@ -from neurodsp.voltage import destripe, destripe_lfp, detect_bad_channels -from neurodsp.utils import rms +from ibldsp.voltage import destripe, destripe_lfp, detect_bad_channels +from ibldsp.utils import rms import spikeglx import pandas as pd import scipy diff --git a/src/neurodsp/smooth.py b/src/ibldsp/smooth.py similarity index 99% rename from src/neurodsp/smooth.py rename to src/ibldsp/smooth.py index 34ecd74..494d40f 100644 --- a/src/neurodsp/smooth.py +++ b/src/ibldsp/smooth.py @@ -1,7 +1,7 @@ import numpy as np from scipy.interpolate import interp1d -import neurodsp.fourier as ft +import ibldsp.fourier as ft def lp(ts, fac, pad=0.2): diff --git a/src/neurodsp/sosfilt.cu b/src/ibldsp/sosfilt.cu similarity index 100% rename from src/neurodsp/sosfilt.cu rename to src/ibldsp/sosfilt.cu diff --git a/src/neurodsp/spiketrains.py b/src/ibldsp/spiketrains.py similarity index 100% rename from src/neurodsp/spiketrains.py rename to src/ibldsp/spiketrains.py diff --git a/src/neurodsp/utils.py b/src/ibldsp/utils.py similarity index 100% rename from src/neurodsp/utils.py rename to src/ibldsp/utils.py diff --git a/src/neurodsp/voltage.py b/src/ibldsp/voltage.py similarity index 99% rename from src/neurodsp/voltage.py rename to src/ibldsp/voltage.py index 8798e54..882ad0a 100644 --- a/src/neurodsp/voltage.py +++ b/src/ibldsp/voltage.py @@ -13,8 +13,8 @@ import spikeglx import neuropixel -import neurodsp.fourier as fourier -import neurodsp.utils as utils +import ibldsp.fourier as fourier +import ibldsp.utils as utils def agc(x, wl=.5, si=.002, epsilon=1e-8, gpu=False): diff --git a/src/neurodsp/waveforms.py b/src/ibldsp/waveforms.py similarity index 99% rename from src/neurodsp/waveforms.py rename to src/ibldsp/waveforms.py index da6056c..4eae3c1 100644 --- a/src/neurodsp/waveforms.py +++ b/src/ibldsp/waveforms.py @@ -284,6 +284,7 @@ def plot_peaktiptrough(df, arr, ax, nth_wav=0, plot_grey=True, fs=30000): ax.set_ylabel('(Volt)') ax.set_xlabel('Time (ms)') + def half_peak_point(arr_peak, df): ''' Compute the two intersection points at halp-maximum peak diff --git a/src/neurodsp/__init__.py b/src/neurodsp/__init__.py index e69de29..f9a6d74 100644 --- a/src/neurodsp/__init__.py +++ b/src/neurodsp/__init__.py @@ -0,0 +1,8 @@ +import ibldsp, sys +from warnings import warn + +sys.modules["neurodsp"] = ibldsp +warn( + "neurodsp has been renamed to ibldsp and the old name will be deprecated on 01-Sep-2024.", + FutureWarning, +) diff --git a/src/neuropixel.py b/src/neuropixel.py index ab9fc5e..0d42436 100644 --- a/src/neuropixel.py +++ b/src/neuropixel.py @@ -9,7 +9,7 @@ import numpy as np import spikeglx -from neurodsp.utils import WindowGenerator +from ibldsp.utils import WindowGenerator _logger = logging.getLogger('ibllib') diff --git a/src/neurowaveforms/model.py b/src/neurowaveforms/model.py index 44178fa..c35ded2 100644 --- a/src/neurowaveforms/model.py +++ b/src/neurowaveforms/model.py @@ -1,5 +1,5 @@ import numpy as np -from neurodsp.fourier import fshift +from ibldsp.fourier import fshift def generate_waveform(spike=None, sxy=None, wxy=None, fs=30000, vertical_velocity_mps=3): diff --git a/src/tests/integration/cpu/csd_experiments.py b/src/tests/integration/cpu/csd_experiments.py index eae99f2..744649e 100644 --- a/src/tests/integration/cpu/csd_experiments.py +++ b/src/tests/integration/cpu/csd_experiments.py @@ -9,7 +9,7 @@ from ibllib.atlas import BrainRegions from viewephys.gui import viewephys -from neurodsp import voltage, fourier +from ibldsp import voltage, fourier from neuropixel import trace_header diff --git a/src/tests/integration/cpu/test_destripe.py b/src/tests/integration/cpu/test_destripe.py index b7e574d..281a427 100644 --- a/src/tests/integration/cpu/test_destripe.py +++ b/src/tests/integration/cpu/test_destripe.py @@ -7,7 +7,7 @@ from neuropixel import trace_header import spikeglx -from neurodsp import voltage, utils +from ibldsp import voltage, utils _logger = logging.getLogger(__name__) diff --git a/src/tests/unit/cpu/test_dsp.py b/src/tests/unit/cpu/test_dsp.py index fa826ff..fe59fab 100644 --- a/src/tests/unit/cpu/test_dsp.py +++ b/src/tests/unit/cpu/test_dsp.py @@ -4,13 +4,13 @@ import scipy.fft import spikeglx -import neurodsp.fourier as fourier -import neurodsp.utils as utils -import neurodsp.voltage as voltage -import neurodsp.cadzow as cadzow -import neurodsp.smooth as smooth -import neurodsp.spiketrains as spiketrains -import neurodsp.raw_metrics as raw_metrics +import ibldsp.fourier as fourier +import ibldsp.utils as utils +import ibldsp.voltage as voltage +import ibldsp.cadzow as cadzow +import ibldsp.smooth as smooth +import ibldsp.spiketrains as spiketrains +import ibldsp.raw_metrics as raw_metrics from pathlib import Path import tempfile @@ -604,3 +604,22 @@ def test_compute_features(self): self.assertEqual(multi_index, list(df.index)) self.assertEqual(["snippet_id", "channel_id"], list(df.index.names)) self.assertEqual(num_snippets * (self.nc - 1), len(df)) + + +class TestNameDeprecationDate(unittest.TestCase): + def test_neurodsp_import(self): + # Check that the old import still works and gives the same package. + # (ibldsp.voltage is imported at the top of this file.) + with self.assertWarnsRegex(FutureWarning, "01-Sep-2024"): + import neurodsp + self.assertEqual(neurodsp.voltage, voltage) + + def test_deprecation_countdown(self): + # Fail on 01-Sep-2024, when `neurodsp` will be retired. + # When this test fails, remove the entire dummy + # `neurodsp` package at the top level of the ibl-neuropixel + # repository + import datetime + if datetime.datetime.now() > datetime.datetime(2024, 9, 1): + raise NotImplementedError("neurodsp will not longer be supported. " + "Change all references to ibldsp.") diff --git a/src/tests/unit/cpu/test_waveforms.py b/src/tests/unit/cpu/test_waveforms.py index 61ccd0e..ded4996 100644 --- a/src/tests/unit/cpu/test_waveforms.py +++ b/src/tests/unit/cpu/test_waveforms.py @@ -3,7 +3,7 @@ import numpy as np import pandas as pd -import neurodsp.waveforms as waveforms +import ibldsp.waveforms as waveforms from neurowaveforms.model import generate_waveform diff --git a/src/tests/unit/gpu/test_filter_gpu.py b/src/tests/unit/gpu/test_filter_gpu.py index cdcdd9d..366097c 100644 --- a/src/tests/unit/gpu/test_filter_gpu.py +++ b/src/tests/unit/gpu/test_filter_gpu.py @@ -3,7 +3,7 @@ from scipy.signal import butter, sosfiltfilt import unittest -from neurodsp.filter_gpu import sosfiltfilt_gpu +from ibldsp.filter_gpu import sosfiltfilt_gpu class TestFilterGpuCpuParity(unittest.TestCase): diff --git a/src/tests/unit/gpu/test_fourier.py b/src/tests/unit/gpu/test_fourier.py index 5f9b24b..278cbc6 100644 --- a/src/tests/unit/gpu/test_fourier.py +++ b/src/tests/unit/gpu/test_fourier.py @@ -2,7 +2,7 @@ import cupy as cp import unittest -from neurodsp.fourier import fshift, channel_shift +from ibldsp.fourier import fshift, channel_shift class TestFourierAlignmentGpuCpuParity(unittest.TestCase):