I am using a PyQt5 GUI with MNE-Python running in the background with the current setup:
User opens interactive plot to set annotations (using interactive plotting that raw_data.plot does)
User sets annotations, which are saved to a .json
Upon analysis, MNE loads EDF and crops data according to the preset annotations (loaded from json).
Upon running the following line of code:
boundaries = [float(item) for item in self.current_session.boundaries[1:-1].split(', ')] # parse boundaries (since its a string lets cut off the ends and split)
self.data.crop(tmin=boundaries[0],tmax=boundaries[1]) # crop data by aforementioned boundaries
I get the following error:
Traceback (most recent call last):
... [traceback calls] ...
File "D:\anaconda3\envs\mne\lib\site-packages\mne\io\base.py", line 1283, in crop
self.set_annotations(self.annotations, False)
File "D:\anaconda3\envs\mne\lib\site-packages\mne\io\base.py", line 642, in set_annotations
raise RuntimeError('Ambiguous operation. Setting an Annotation'
RuntimeError: Ambiguous operation. Setting an Annotation object with known ``orig_time`` to a raw object which has ``meas_date`` set to None is ambiguous. Please, either set a meaningful ``meas_date`` to the raw object; or set ``orig_time`` to None in which case the annotation onsets would be taken in reference to the first sample of the raw object.
So some discrepancy between the info and annotations of my raw data object is preventing cropping.
Is there a workaround for this, or is this a deeper issue?
But this gives me blank topographies and PSD measurements, and prevents connectivity from running. If anyone has ideas, I’d really appreciate any feedback you might have!
Thank you for getting back. I have used set_meas_date to manually set the meas_date in my Raw and Epochs objects with the following lines of code:
meas_date = data.info['meas_date']
[lines of code where meas_date is being set to None, which I’ve described in my previous comment] data.set_meas_date(meas_date) # re-set meas_date to what it was before epochs.set_meas_date(meas_date) # re-set meas_date to what it was before
However, when I run spectral_connectivity I now have the following error: ValueError('zero-size array to reduction operation maximum which has no identity')
I will be doing some more debugging, but at first glance my Epochs object looks fine: <Epochs | 19 events (all good), 0 - 14.998 sec, baseline off, ~33.7 MB, data loaded, '1': 19>
Any ideas as to how to fix this, or which attributes of an Epochs object I should look into?