Skip to content

Commit 9a49678

Browse files
Fix sigui CLI --recording to reference correct args.recording_base_folder (#274)
* Fix sigui CLI --recording to reference correct args.recording_base_folder argparse was stores --recording-base-folder as args.recording_base_folder, but run_mainwindow_cli() was trying to access the non-existent args.recording_base_path. That error was caught by the except and only printed a misleading 'check the path or the file format', so --recording silently failed. * Verbalize real error and fail loudly on sigui CLI --recording load failure * Replace _ to - in CLI args Co-authored-by: Alessio Buccino <alejoe9187@gmail.com> --------- Co-authored-by: Alessio Buccino <alejoe9187@gmail.com>
1 parent fe900ee commit 9a49678

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

spikeinterface_gui/main.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ def run_mainwindow_cli():
316316
parser.add_argument('--recording', help='Path to a recording file (.json/.pkl) or folder that can be loaded with spikeinterface.load', default=None)
317317
parser.add_argument('--recording-base-folder', help='Base folder path for the recording (if .json/.pkl)', default=None)
318318
parser.add_argument('--verbose', help='Make the output verbose', action='store_true', default=False)
319-
parser.add_argument('--skip_extensions', help='Choose which extensions not to load, comma separated (e.g. waveforms,principal_components)', default=None)
319+
parser.add_argument('--skip-extensions', help='Choose which extensions not to load, comma separated (e.g. waveforms,principal_components)', default=None)
320320
parser.add_argument('--port', help='Port for web mode', default=0, type=int)
321321
parser.add_argument('--address', help='Address for web mode', default='localhost')
322322
parser.add_argument('--layout-file', help='Path to json file defining layout', default=None)
323323
parser.add_argument('--curation-file', help='Path to json file defining a curation', default=None)
324324
parser.add_argument('--settings-file', help='Path to json file specifying the settings of each view', default=None)
325-
parser.add_argument('--disable_save_settings_button', help='Disables button allowing for user to save default settings', action='store_true', default=False)
325+
parser.add_argument('--disable-save-settings-button', help='Disables button allowing for user to save default settings', action='store_true', default=False)
326326

327327
args = parser.parse_args(argv)
328328

@@ -348,19 +348,23 @@ def run_mainwindow_cli():
348348
try:
349349
if args.verbose:
350350
print('Loading recording...')
351-
recording_base_path = args.recording_base_path
352-
recording = load(args.recording, base_folder=recording_base_path)
351+
recording = load(args.recording, base_folder=args.recording_base_folder)
353352
if args.verbose:
354353
print('Recording loaded')
355354
except Exception as e:
356-
print('Error when loading recording. Please check the path or the file format')
357-
if recording is not None:
358-
if analyzer.get_num_channels() != recording.get_num_channels():
359-
print('Recording and analyzer have different number of channels. Slicing recording')
360-
channel_mask = np.isin(recording.channel_ids, analyzer.channel_ids)
361-
if np.sum(channel_mask) != analyzer.get_num_channels():
362-
raise ValueError('The recording does not have the same channel ids as the analyzer')
363-
recording = recording.select_channels(recording.channel_ids[channel_mask])
355+
raise RuntimeError(
356+
f"Could not load recording from '{args.recording}' "
357+
f"(base folder: {args.recording_base_folder}). "
358+
"Check that the path exists and is readable by spikeinterface.load."
359+
) from e
360+
# --recording loaded successfully here (a failure raises above), so the
361+
# analyzer/recording channel counts can be reconciled directly.
362+
if analyzer.get_num_channels() != recording.get_num_channels():
363+
print('Recording and analyzer have different number of channels. Slicing recording')
364+
channel_mask = np.isin(recording.channel_ids, analyzer.channel_ids)
365+
if np.sum(channel_mask) != analyzer.get_num_channels():
366+
raise ValueError('The recording does not have the same channel ids as the analyzer')
367+
recording = recording.select_channels(recording.channel_ids[channel_mask])
364368

365369
if args.curation_file is not None:
366370
with open(args.curation_file, "r") as f:

0 commit comments

Comments
 (0)