# Issue when saving raw files loaded with mne\_bids.read\_raw\_bids

**URL:** <https://mne.discourse.group/t/issue-when-saving-raw-files-loaded-with-mne-bids-read-raw-bids/11345>\
**Category:** Support & Discussions\
**Tags:** preprocessing, meg, mne-bids, mne-bids-pipeline\
**Created:** [July 7, 2025, 9:38am UTC](https://mne.discourse.group/t/issue-when-saving-raw-files-loaded-with-mne-bids-read-raw-bids/11345 "2025-07-07T09:38:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nissauce](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nissauce/32/3052_2.png) [@nissauce](https://mne.discourse.group/u/nissauce)\
**Post date:** [July 7, 2025, 9:38am UTC](https://mne.discourse.group/t/issue-when-saving-raw-files-loaded-with-mne-bids-read-raw-bids/11345/1 "2025-07-07T09:38:02Z")

</div>

Hi,

I’m encountering an issue saving raw files loaded with `mne_bids.read_raw_bids()`.

When I use this function and I want to save my raw file like that :

```python
bids_path = BIDSPath(subject=subject, session='01', task='task', run='01', split='01', root='path/to/bids')
raw = read_raw_bids(bids_path=bids_path, verbose=True)
raw.crop(tmin=0, tmax=10) 
raw.save('example_raw.fif', overwrite=True, verbose=True)

```

I get this error:

```python
ValueError Traceback (most recent call last)
Cell In[39], line 9
      7 raw = read_raw_bids(bids_path=bids_path, verbose=True)
      8 raw.crop(tmin=0, tmax=10) 
----> 9 raw.save('example_raw.fif', overwrite=True, verbose=True)

File <decorator-gen-197>:10, in save(self, fname, picks, tmin, tmax, buffer_size_sec, drop_small_buffer, proj, fmt, overwrite, split_size, split_naming, verbose)

File ~/path/to/.venv/lib/python3.10/site-packages/mne/io/base.py:1836, in BaseRaw.save(self, fname, picks, tmin, tmax, buffer_size_sec, drop_small_buffer, proj, fmt, overwrite, split_size, split_naming, verbose)
   1834 cfg = _RawFidWriterCfg(buffer_size, split_size, drop_small_buffer, fmt)
   1835 raw_fid_writer = _RawFidWriter(self, info, picks, projector, start, stop, cfg)
-> 1836 filenames = _write_raw(raw_fid_writer, fname, split_naming, overwrite)
   1837 return filenames

File ~/path/to/.venv/lib/python3.10/site-packages/mne/io/base.py:2777, in _write_raw(raw_fid_writer, fpath, split_naming, overwrite)
   2775 logger.info(f"Writing {use_fpath}")
   2776 with start_and_end_file(use_fpath) as fid, reserved_ctx:
-> 2777 is_next_split = raw_fid_writer.write(fid, part_idx, prev_fname, next_fname)
   2778 logger.info(f"Closing {use_fpath}")
   2779 if bids_special_behavior and is_next_split:

File ~/path/to/.venv/lib/python3.10/site-packages/mne/io/base.py:2850, in _RawFidWriter.write(self, fid, part_idx, prev_fname, next_fname)
   2848 self._check_start_stop_within_bounds()
   2849 start_block(fid, FIFF.FIFFB_MEAS)
...
    999 or dt.tzinfo is not timezone.utc
   1000 ):
-> 1001 raise ValueError(f"Date must be datetime object in UTC: {repr(dt)}")

ValueError: Date must be datetime object in UTC: None

```

Manually setting `info["meas_date"]` to an arbitrary date before saving does not change the error, which makes me think this is an issue unrelated to `meas_date`, but something else?

```python
raw.set_meas_date(datetime.now(timezone.utc))
print("MEAS DATE:", raw.info['meas_date'])
print(raw.info['meas_date'].tzinfo is timezone.utc)

```

> MEAS DATE: 2025-07-07 09:06:09.673433+00:00  
> True

And if I load the info from the file and set it to the raw before saving, it solves the problem :

```python
info = mne.io.read_info('path/to/bids_file_meg.fif')
raw.info = info
raw.save('example_raw.fif', overwrite=True, verbose=True)

```

I could apply this fix, but it prevents me from using the **MNE-BIDS-Pipeline** for preprocessing, where the same issue occurs.

The data has been acquired using a **MEGIN Triux Neo** machine.

- MNE version: 1.9.0
- MNE-BIDS version: 0.16.0
- MNE-BIDS-pipeline version : dev
- operating system: macOS 15.5

---

<div class="post-metadata">

**Author:** ![nissauce](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nissauce/32/3052_2.png) [@nissauce](https://mne.discourse.group/u/nissauce)\
**Post date:** [July 7, 2025, 10:01am UTC](https://mne.discourse.group/t/issue-when-saving-raw-files-loaded-with-mne-bids-read-raw-bids/11345/2 "2025-07-07T10:01:28Z")

</div>

Fixed it by swapping to dev versions for MNE (1.10) and MNE-BIDS (0.17) after seeing this : [[BUG] Saving anonymized helium info still produces error · Issue #13055 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/issues/13055)!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [July 14, 2025, 10:02am UTC](https://mne.discourse.group/t/issue-when-saving-raw-files-loaded-with-mne-bids-read-raw-bids/11345/3 "2025-07-14T10:02:29Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
