From 1f37858dfa6a00c5fc5790a1f4f208186e0c7b53 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Mon, 30 Oct 2023 17:38:55 +0100 Subject: [PATCH] Make Sam happy by using import probeinterface --- .../core/tests/test_channelslicerecording.py | 4 ++-- src/spikeinterface/extractors/bids.py | 4 ++-- src/spikeinterface/extractors/cbin_ibl.py | 4 ++-- src/spikeinterface/extractors/iblstreamingrecording.py | 4 ++-- src/spikeinterface/extractors/neoextractors/biocam.py | 4 ++-- src/spikeinterface/extractors/neoextractors/maxwell.py | 4 ++-- src/spikeinterface/extractors/neoextractors/mearec.py | 4 ++-- src/spikeinterface/extractors/neoextractors/openephys.py | 8 +++++--- src/spikeinterface/extractors/neoextractors/spikeglx.py | 6 +++--- src/spikeinterface/extractors/shybridextractors.py | 6 +++--- .../deepinterpolation/tests/test_deepinterpolation.py | 4 ++-- 11 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/spikeinterface/core/tests/test_channelslicerecording.py b/src/spikeinterface/core/tests/test_channelslicerecording.py index 08bb22a2c8..565a743084 100644 --- a/src/spikeinterface/core/tests/test_channelslicerecording.py +++ b/src/spikeinterface/core/tests/test_channelslicerecording.py @@ -4,7 +4,7 @@ import pytest import numpy as np -import probeinterface as pi +import probeinterface from spikeinterface.core import ChannelSliceRecording, BinaryRecordingExtractor @@ -58,7 +58,7 @@ def test_ChannelSliceRecording(): assert np.all(traces[:, 1] == 0) # with probe and after save() - probe = pi.generate_linear_probe(num_elec=num_chan) + probe = probeinterface.generate_linear_probe(num_elec=num_chan) probe.set_device_channel_indices(np.arange(num_chan)) rec_p = rec.set_probe(probe) rec_sliced3 = ChannelSliceRecording(rec_p, channel_ids=[0, 2], renamed_channel_ids=[3, 4]) diff --git a/src/spikeinterface/extractors/bids.py b/src/spikeinterface/extractors/bids.py index e71d6aa4ff..b1888f4a27 100644 --- a/src/spikeinterface/extractors/bids.py +++ b/src/spikeinterface/extractors/bids.py @@ -3,7 +3,7 @@ import numpy as np import neo -import probeinterface as pi +import probeinterface from .nwbextractors import read_nwb from .neoextractors import read_nix @@ -60,7 +60,7 @@ def read_bids(folder_path): def _read_probe_group(folder, bids_name, recording_channel_ids): - probegroup = pi.read_BIDS_probe(folder) + probegroup = probeinterface.read_BIDS_probe(folder) # make maps between : channel_id and contact_id using _channels.tsv import pandas as pd diff --git a/src/spikeinterface/extractors/cbin_ibl.py b/src/spikeinterface/extractors/cbin_ibl.py index bd56208ebe..37ed931d1a 100644 --- a/src/spikeinterface/extractors/cbin_ibl.py +++ b/src/spikeinterface/extractors/cbin_ibl.py @@ -1,6 +1,6 @@ from pathlib import Path -import probeinterface as pi +import probeinterface from spikeinterface.core import BaseRecording, BaseRecordingSegment from spikeinterface.extractors.neuropixels_utils import get_neuropixels_sample_shifts @@ -89,7 +89,7 @@ def __init__(self, folder_path, load_sync_channel=False, stream_name="ap"): self.set_channel_offsets(offsets) if not load_sync_channel: - probe = pi.read_spikeglx(meta_file) + probe = probeinterface.read_spikeglx(meta_file) if probe.shank_ids is not None: self.set_probe(probe, in_place=True, group_mode="by_shank") diff --git a/src/spikeinterface/extractors/iblstreamingrecording.py b/src/spikeinterface/extractors/iblstreamingrecording.py index fcd03f8bcf..6ccf91b35b 100644 --- a/src/spikeinterface/extractors/iblstreamingrecording.py +++ b/src/spikeinterface/extractors/iblstreamingrecording.py @@ -4,7 +4,7 @@ from pathlib import Path import numpy as np -import probeinterface as pi +import probeinterface from spikeinterface.core import BaseRecording, BaseRecordingSegment from spikeinterface.core.core_tools import define_function_from_class @@ -165,7 +165,7 @@ def __init__( # set probe if not load_sync_channel: - probe = pi.read_spikeglx(meta_file) + probe = probeinterface.read_spikeglx(meta_file) if probe.shank_ids is not None: self.set_probe(probe, in_place=True, group_mode="by_shank") diff --git a/src/spikeinterface/extractors/neoextractors/biocam.py b/src/spikeinterface/extractors/neoextractors/biocam.py index 3e30cf77ae..1a1e02c554 100644 --- a/src/spikeinterface/extractors/neoextractors/biocam.py +++ b/src/spikeinterface/extractors/neoextractors/biocam.py @@ -1,6 +1,6 @@ from pathlib import Path -import probeinterface as pi +import probeinterface from spikeinterface.core.core_tools import define_function_from_class @@ -54,7 +54,7 @@ def __init__( probe_kwargs["mea_pitch"] = mea_pitch if electrode_width is not None: probe_kwargs["electrode_width"] = electrode_width - probe = pi.read_3brain(file_path, **probe_kwargs) + probe = probeinterface.read_3brain(file_path, **probe_kwargs) self.set_probe(probe, in_place=True) self.set_property("row", self.get_property("contact_vector")["row"]) self.set_property("col", self.get_property("contact_vector")["col"]) diff --git a/src/spikeinterface/extractors/neoextractors/maxwell.py b/src/spikeinterface/extractors/neoextractors/maxwell.py index ac85dbdf30..790bed0185 100644 --- a/src/spikeinterface/extractors/neoextractors/maxwell.py +++ b/src/spikeinterface/extractors/neoextractors/maxwell.py @@ -1,7 +1,7 @@ import numpy as np from pathlib import Path -import probeinterface as pi +import probeinterface from spikeinterface import BaseEvent, BaseEventSegment from spikeinterface.core.core_tools import define_function_from_class @@ -68,7 +68,7 @@ def __init__( well_name = self.stream_id # rec_name auto set by neo rec_name = self.neo_reader.rec_name - probe = pi.read_maxwell(file_path, well_name=well_name, rec_name=rec_name) + probe = probeinterface.read_maxwell(file_path, well_name=well_name, rec_name=rec_name) self.set_probe(probe, in_place=True) self.set_property("electrode", self.get_property("contact_vector")["electrode"]) self._kwargs.update(dict(file_path=str(Path(file_path).absolute()), rec_name=rec_name)) diff --git a/src/spikeinterface/extractors/neoextractors/mearec.py b/src/spikeinterface/extractors/neoextractors/mearec.py index 7dda9175f5..c0b820f65b 100644 --- a/src/spikeinterface/extractors/neoextractors/mearec.py +++ b/src/spikeinterface/extractors/neoextractors/mearec.py @@ -3,7 +3,7 @@ import numpy as np -import probeinterface as pi +import probeinterface from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseSortingExtractor @@ -48,7 +48,7 @@ def __init__(self, file_path: Union[str, Path], all_annotations: bool = False): self.extra_requirements.append("mearec") - probe = pi.read_mearec(file_path) + probe = probeinterface.read_mearec(file_path) probe.annotations["mearec_name"] = str(probe.annotations["mearec_name"]) self.set_probe(probe, in_place=True) self.annotate(is_filtered=True) diff --git a/src/spikeinterface/extractors/neoextractors/openephys.py b/src/spikeinterface/extractors/neoextractors/openephys.py index b9aa5d46d6..56b759e3d8 100644 --- a/src/spikeinterface/extractors/neoextractors/openephys.py +++ b/src/spikeinterface/extractors/neoextractors/openephys.py @@ -13,7 +13,7 @@ import numpy as np import warnings -import probeinterface as pi +import probeinterface from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseSortingExtractor, NeoBaseEventExtractor @@ -176,7 +176,9 @@ def __init__( settings_file = self.neo_reader.folder_structure[record_node]["experiments"][exp_id]["settings_file"] if Path(settings_file).is_file(): - probe = pi.read_openephys(settings_file=settings_file, stream_name=stream_name, raise_error=False) + probe = probeinterface.read_openephys( + settings_file=settings_file, stream_name=stream_name, raise_error=False + ) else: probe = None @@ -208,7 +210,7 @@ def __init__( sample_shifts = get_neuropixels_sample_shifts(total_channels, num_channels_per_adc, num_cycles_in_adc) if self.get_num_channels() != total_channels: # need slice because not all channel are saved - chans = pi.get_saved_channel_indices_from_openephys_settings(settings_file, oe_stream) + chans = probeinterface.get_saved_channel_indices_from_openephys_settings(settings_file, oe_stream) # lets clip to 384 because this contains also the synchro channel chans = chans[chans < total_channels] sample_shifts = sample_shifts[chans] diff --git a/src/spikeinterface/extractors/neoextractors/spikeglx.py b/src/spikeinterface/extractors/neoextractors/spikeglx.py index 8c3b33505d..7695d9b033 100644 --- a/src/spikeinterface/extractors/neoextractors/spikeglx.py +++ b/src/spikeinterface/extractors/neoextractors/spikeglx.py @@ -4,7 +4,7 @@ from pathlib import Path import neo -import probeinterface as pi +import probeinterface from spikeinterface.extractors.neuropixels_utils import get_neuropixels_sample_shifts @@ -60,7 +60,7 @@ def __init__(self, folder_path, load_sync_channel=False, stream_id=None, stream_ # Load probe geometry if available if "lf" in self.stream_id: meta_filename = meta_filename.replace(".lf", ".ap") - probe = pi.read_spikeglx(meta_filename) + probe = probeinterface.read_spikeglx(meta_filename) if probe.shank_ids is not None: self.set_probe(probe, in_place=True, group_mode="by_shank") @@ -84,7 +84,7 @@ def __init__(self, folder_path, load_sync_channel=False, stream_id=None, stream_ sample_shifts = get_neuropixels_sample_shifts(total_channels, num_channels_per_adc, num_cycles_in_adc) if self.get_num_channels() != total_channels: # need slice because not all channel are saved - chans = pi.get_saved_channel_indices_from_spikeglx_meta(meta_filename) + chans = probeinterface.get_saved_channel_indices_from_spikeglx_meta(meta_filename) # lets clip to 384 because this contains also the synchro channel chans = chans[chans < total_channels] sample_shifts = sample_shifts[chans] diff --git a/src/spikeinterface/extractors/shybridextractors.py b/src/spikeinterface/extractors/shybridextractors.py index e827cbb587..fffa0dfe41 100644 --- a/src/spikeinterface/extractors/shybridextractors.py +++ b/src/spikeinterface/extractors/shybridextractors.py @@ -2,7 +2,7 @@ import numpy as np -import probeinterface as pi +import probeinterface from spikeinterface.core import BinaryRecordingExtractor, BaseRecordingSegment, BaseSorting, BaseSortingSegment from spikeinterface.core.core_tools import write_binary_recording, define_function_from_class @@ -69,7 +69,7 @@ def __init__(self, file_path): ) # load probe file - probegroup = pi.read_prb(params["probe"]) + probegroup = probeinterface.read_prb(params["probe"]) self.set_probegroup(probegroup, in_place=True) self._kwargs = {"file_path": str(Path(file_path).absolute())} self.extra_requirements.extend(["hybridizer", "pyyaml"]) @@ -119,7 +119,7 @@ def write_recording(recording, save_path, initial_sorting_fn, dtype="float32", * # write probe file probe_fn = (save_path / probe_name).absolute() probegroup = recording.get_probegroup() - pi.write_prb(probe_fn, probegroup, total_nb_channels=recording.get_num_channels()) + probeinterface.write_prb(probe_fn, probegroup, total_nb_channels=recording.get_num_channels()) # create parameters file parameters = dict( diff --git a/src/spikeinterface/preprocessing/deepinterpolation/tests/test_deepinterpolation.py b/src/spikeinterface/preprocessing/deepinterpolation/tests/test_deepinterpolation.py index 0525cdfc7a..43b35dfef9 100644 --- a/src/spikeinterface/preprocessing/deepinterpolation/tests/test_deepinterpolation.py +++ b/src/spikeinterface/preprocessing/deepinterpolation/tests/test_deepinterpolation.py @@ -2,7 +2,7 @@ import numpy as np from pathlib import Path -import probeinterface as pi +import probeinterface from spikeinterface import download_dataset, generate_recording, append_recordings, concatenate_recordings from spikeinterface.extractors import read_mearec, read_spikeglx, read_openephys from spikeinterface.preprocessing import depth_order, zscore @@ -29,7 +29,7 @@ def recording_and_shape(): num_cols = 2 num_rows = 64 - probe = pi.generate_multi_columns_probe(num_columns=num_cols, num_contact_per_column=num_rows) + probe = probeinterface.generate_multi_columns_probe(num_columns=num_cols, num_contact_per_column=num_rows) probe.set_device_channel_indices(np.arange(num_cols * num_rows)) recording = generate_recording(num_channels=num_cols * num_rows, durations=[10.0], sampling_frequency=30000) recording.set_probe(probe, in_place=True)