- MNE-Python version: 0.22.1
- operating system: windows 10
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
- 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,tmax=boundaries) # 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
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?
I’ve done some digging around and I found that my raw data object’s
meas_date is being set to None when I run these lines:
info = mne.create_info(ch_names=self.data.ch_names,sfreq=self.SFREQ,ch_types=ch_types)
self.data.info = info
I’ve tried, after these lines, to set the
info['meas_date'] manually to a UTC datetime object:
self.data.info['meas_date'] = datetime.utcnow().replace(tzinfo=timezone.utc)
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!
you should not touch the meas_data manually but use the set_meas_date method from Raw, Epochs or Evoked.
hopefully this will fix your problem
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?
this is a different (a new) issue than the one you initially described. Please open a new topic for the new question. Thanks!