You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I attempted to programmatically delete a .bin file I had used after performing operations using a BinaryRecordingExtractor object, but was getting an exception saying that the file was in use by another process.
Brief pseudo-code example:
# create BinaryRecordingExtractor instance
recording = si.read_binary("file.bin", num_channels=256, sampling_frequency=40000, dtype='int16')
# Perform an operation
recording.save_to_folder(folder='saved', overwrite=True)
# attempting to delete the .bin file fails
os.remove(binfile)
I found that the BinaryRecordingSegment class (used within BinaryRecordingExtractor) opens the binary file when it's instanced, but never closes it.
I moved the file open operation to the get_traces() method, wrapping the relevant code in a 'with open()' statement, which fixed the problem. I will submit a PR shortly.