Skip to content

Commit 892b9dc

Browse files
authored
Merge pull request #185 from SpikeInterface/remove-support-of-old-files
Remove support of files with v<1.5 and lazy_ops
2 parents dd7c5a1 + 05e4dd6 commit 892b9dc

3 files changed

Lines changed: 16 additions & 35 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "MEArec"
3-
version = "1.9.3"
3+
version = "1.10.0"
44
authors = [
55
{ name="Alessio Buccino", email="alessiop.buccino@gmail.com" },
66
]
77
description = "Python toolkit for biophysical simulation of extracellular electrophysiology recordings"
88
readme = "README.md"
9-
requires-python = ">=3.7,<4.0"
9+
requires-python = ">=3.10,<4.0"
1010
classifiers = [
1111
"Programming Language :: Python :: 3 :: Only",
1212
"License :: OSI Approved :: MIT License",
@@ -26,8 +26,6 @@ dependencies = [
2626
"joblib",
2727
"scipy",
2828
"elephant",
29-
"lazy_ops",
30-
"zarr<3.0",
3129
"MEAutility"
3230
]
3331

@@ -66,7 +64,7 @@ documentation = "https://mearec.readthedocs.io/"
6664
[project.optional-dependencies]
6765

6866
templates = [
69-
"neuron",
67+
"neuron<9",
7068
"LFPy"
7169
]
7270

readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sphinx:
77
build:
88
os: ubuntu-22.04
99
tools:
10-
python: "3.9"
10+
python: "3.12"
1111

1212
python:
1313
install:

src/MEArec/tools.py

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import scipy.signal as ss
1313
import yaml
1414
from joblib import Parallel, delayed
15-
from lazy_ops import DatasetView
1615
from packaging.version import parse
1716
from quantities import Quantity
1817

@@ -353,22 +352,18 @@ def load_recordings(
353352
f = h5py.File(str(recordings), "r")
354353
mearec_version = f.attrs.get("mearec_version", "1.4.0")
355354

356-
if parse(mearec_version) >= parse("1.5.0"):
355+
if parse(mearec_version) < parse("1.5.0"):
357356
# version after 1.5.0 is (n_samples, n_channel) inside the h5 file
358-
need_transpose = False
359-
else:
360-
# version 1.4.0 and before is (n_channel, n_samples) inside the h5 file
361-
print(
362-
"Warning: MEArec file created with version <1.5. This could result in lower efficiency. To upgrade"
363-
"your file to the new format use: mr.convert_recording_to_new_version(filename)"
357+
raise Exception(
358+
"MEArec file created with version <1.5 and not supported anymore. To upgrade"
359+
"your file to the new format, install MEArec version 1.5 or higher (<1.10.0) and use: "
360+
"`mr.convert_recording_to_new_version(filename)`"
364361
)
365-
need_transpose = True
366362

367363
rec_dict, info = load_recordings_from_file(
368364
f,
369365
return_h5_objects=return_h5_objects,
370366
load=load,
371-
need_transpose=need_transpose,
372367
load_waveforms=load_waveforms,
373368
)
374369

@@ -386,7 +381,7 @@ def load_recordings(
386381
return recgen
387382

388383

389-
def load_recordings_from_file(f, path="", return_h5_objects=True, load=None, need_transpose=False, load_waveforms=True):
384+
def load_recordings_from_file(f, path="", return_h5_objects=True, load=None, load_waveforms=True):
390385
"""
391386
Load generated recordings from file.
392387
@@ -403,10 +398,6 @@ def load_recordings_from_file(f, path="", return_h5_objects=True, load=None, nee
403398
'timestamps', 'spike_traces', 'templates'))
404399
load_waveforms : bool
405400
If True waveforms are loaded to spiketrains
406-
verbose : bool
407-
If True output is verbose
408-
check_suffix : bool
409-
If True, hdf5 suffix is checked
410401
411402
Returns
412403
-------
@@ -447,27 +438,17 @@ def load_recordings_from_file(f, path="", return_h5_objects=True, load=None, nee
447438
rec_dict["channel_positions"] = np.array(f.get(path + "channel_positions"))
448439
if f.get(path + "recordings") is not None and "recordings" in load:
449440
if return_h5_objects:
450-
if need_transpose:
451-
rec_dict["recordings"] = DatasetView(f.get(path + "recordings")).lazy_transpose()
452-
else:
453-
rec_dict["recordings"] = f.get(path + "recordings")
441+
rec_dict["recordings"] = f.get(path + "recordings")
454442
else:
455443
arr = np.array(f.get(path + "recordings"))
456-
if need_transpose:
457-
arr = arr.T
458444
rec_dict["recordings"] = arr
459445
if "gain_to_uV" in f.get(path + "recordings").attrs:
460446
rec_dict["gain_to_uV"] = f.get(path + "recordings").attrs["gain_to_uV"]
461447
if f.get(path + "spike_traces") is not None and "spike_traces" in load:
462448
if return_h5_objects:
463-
if need_transpose:
464-
rec_dict["spike_traces"] = DatasetView(f.get(path + "spike_traces")).lazy_transpose()
465-
else:
466-
rec_dict["spike_traces"] = f.get(path + "spike_traces")
449+
rec_dict["spike_traces"] = f.get(path + "spike_traces")
467450
else:
468451
arr = np.array(f.get(path + "spike_traces"))
469-
if need_transpose:
470-
arr = arr.T
471452
rec_dict["spike_traces"] = arr
472453
if f.get(path + "templates") is not None and "templates" in load:
473454
if return_h5_objects:
@@ -693,8 +674,10 @@ def recursively_save_dict_contents_to_group(h5file, path, dic):
693674
elif isinstance(item, dict):
694675
recursively_save_dict_contents_to_group(h5file, path + key + "/", item)
695676
else:
696-
print(key, item)
697-
raise ValueError("Cannot save %s type" % type(item))
677+
try:
678+
h5file[path + key] = item
679+
except Exception as e:
680+
raise ValueError("Cannot save %s type" % type(item))
698681

699682

700683
def load_dict_from_hdf5(h5file, path):

0 commit comments

Comments
 (0)