Skip to content

Commit 56efac7

Browse files
committed
fix: only check for bin file size if it exists
1 parent a0f20b3 commit 56efac7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

neo/rawio/spikeglxrawio.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,12 @@ def extract_stream_info(meta_file, meta):
695695
# Calculate sample_length from actual file size instead of metadata to handle stub/modified files
696696
# The metadata fileSizeBytes may not match the actual .bin file (e.g., in test stub files)
697697
# Original calculation (only correct for unmodified files):
698-
# info["sample_length"] = int(meta["fileSizeBytes"]) // 2 // num_chan
699-
actual_file_size = Path(meta_file).with_suffix(".bin").stat().st_size
700-
info["sample_length"] = actual_file_size // 2 // num_chan # 2 bytes per int16 sample
698+
bin_file = Path(meta_file).with_suffix(".bin")
699+
if bin_file.exists():
700+
file_size = bin_file.stat().st_size
701+
else:
702+
file_size = int(meta["fileSizeBytes"])
703+
info["sample_length"] = file_size // 2 // num_chan # 2 bytes per int16 sample
701704
info["gate_num"] = gate_num
702705
info["trigger_num"] = trigger_num
703706
info["device"] = device

0 commit comments

Comments
 (0)