Skip to content

Add option to include layout json #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions spikeinterface_gui/layout_presets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json
from spikeinterface_gui.viewlist import possible_class_views

"""
A preset need 8 zones like this:

Expand All @@ -8,12 +11,28 @@
+-----------------+-----------------+

"""

_presets = {}
def get_layout_description(preset_name, layout_dict=None):
if layout_dict is not None:

def _check_valid_layout_dict(layout_dict):
for key, class_views in layout_dict.items():
if key not in [f"zone{a}" for a in range(1,9)]:
raise KeyError(f"Key {key} in layout dictionary not equal to zone1, zone2, ... or zone8.")
for class_view in class_views:
list_of_possible_class_views = list(possible_class_views.keys())
if class_view not in list_of_possible_class_views:
raise KeyError(f"View '{class_view}' in layout dictionary not equal to a valid View. "\
"Valid views are {list_of_possible_class_views}")

def get_layout_description(preset_name, layout=None):
if isinstance(layout, dict):
_check_valid_layout_dict(layout)
# If a layout_dict is provided, use it instead of the preset
return layout_dict
return layout
elif isinstance(layout, str):
if layout.endswith('json'):
with open(layout) as layout_file:
layout_dict = json.load(layout_file)
return get_layout_description(None, layout=layout_dict)
else:
if preset_name is None:
preset_name = 'default'
Expand Down
6 changes: 4 additions & 2 deletions spikeinterface_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def run_mainwindow_cli():
parser.add_argument('--verbose', help='Make the output verbose', action='store_true', default=False)
parser.add_argument('--port', help='Port for web mode', default=0, type=int)
parser.add_argument('--address', help='Address for web mode', default='localhost')

parser.add_argument('--layout-file', help='Path to json file defining layout', default=None)

args = parser.parse_args(argv)

analyzer_folder = args.analyzer_folder
Expand Down Expand Up @@ -292,5 +293,6 @@ def run_mainwindow_cli():
with_traces=not(args.no_traces),
curation=args.curation,
recording=recording,
verbose=args.verbose
verbose=args.verbose,
layout=args.layout_file,
)