Skip to content

Commit

Permalink
Merge pull request #2792 from zm711/settings-json
Browse files Browse the repository at this point in the history
Add write settings.json for back compatibility for early-adopters of SortingAnalyzer
  • Loading branch information
alejoe91 authored May 2, 2024
2 parents c53c06a + b12c755 commit 1d88111
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/spikeinterface/core/sortinganalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,21 @@ def load_from_binary_folder(cls, folder, recording=None):
else:
sparsity = None

# PATCH: Because SortingAnalyzer added this json during the development of 0.101.0 we need to save
# this as a bridge for early adopters. The else branch can be removed in version 0.102.0/0.103.0
# so that this can be simplified in the future
# See https://github.com/SpikeInterface/spikeinterface/issues/2788

settings_file = folder / f"settings.json"
with open(settings_file, "r") as f:
settings = json.load(f)
if settings_file.exists():
with open(settings_file, "r") as f:
settings = json.load(f)
else:
warnings.warn("settings.json not found for this folder writing one with return_scaled=True")
settings = dict(return_scaled=True)
with open(settings_file, "w") as f:
json.dump(check_json(settings), f, indent=4)

return_scaled = settings["return_scaled"]

sorting_analyzer = SortingAnalyzer(
Expand Down

0 comments on commit 1d88111

Please sign in to comment.