open-ephys / open-ephys-python-tools

Python code for interacting with the Open Ephys GUI
MIT License
29 stars 17 forks source link

Error when loading samples: 'could not broadcast input array from shape (38370304,) into shape (38371328,)' #37

Open stef1029 opened 1 month ago

stef1029 commented 1 month ago

Hi, I think something has gone wrong with my data acquisition at some point and a bunch of my files are giving this error when I try and load the samples:

Traceback (most recent call last):
  File "Y:\Behaviour code\2407_July_WT_cohort\Analysis\NAP\July_cohort_scripts\analysis_manager.py", line 36, in __init__
    self.ingest_behaviour_data()
  File "Y:\Behaviour code\2407_July_WT_cohort\Analysis\NAP\July_cohort_scripts\analysis_manager.py", line 83, in ingest_behaviour_data
    self.OEAB_data = process_ADC_Recordings(self.OEAB_folder, self.rig_id)
  File "Y:\Behaviour code\2407_July_WT_cohort\Analysis\NAP\July_cohort_scripts\Preliminary_analysis_scripts\process_ADC_recordings.py", line 28, in __init__
    self.extract_ADC_data()
  File "Y:\Behaviour code\2407_July_WT_cohort\Analysis\NAP\July_cohort_scripts\Preliminary_analysis_scripts\process_ADC_recordings.py", line 36, in extract_ADC_data
    self.samples = self.recording.samples   # raw samples, not in microvolts
  File "C:\Users\Public\.conda\July_cohort\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py", line 92, in samples
    self._load_samples()
  File "C:\Users\Public\.conda\July_cohort\lib\site-packages\open_ephys\analysis\formats\OpenEphysRecording.py", line 200, in _load_samples
    self._samples[:,channel_idx] = samples
ValueError: could not broadcast input array from shape (38370304,) into shape (38371328,)

I am just wondering if this is something that can be fixed to salvage the data? I'm not exactly sure what the issue at the time was, but I was having some issues with the recording buffer overflowing and causing a stop in the recording. Thanks for any help you can give, Stefan

medengineer commented 1 month ago

Hi,

An overflow can prevent the buffer from flushing completely before closing the file. Assuming that's the only issue, all but the last few ms should be recoverable.

If you can send a link to one of these recordings to pavel@open-ephys.org I can confirm the failure mode and send back a script to load the data.