# Writting .mff files into BIDS, problems with write\_raw\_bids

**URL:** <https://mne.discourse.group/t/writting-mff-files-into-bids-problems-with-write-raw-bids/4999>\
**Category:** Support & Discussions\
**Tags:** mne-bids\
**Created:** [June 5, 2022, 2:53pm UTC](https://mne.discourse.group/t/writting-mff-files-into-bids-problems-with-write-raw-bids/4999 "2022-06-05T14:53:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevidiann](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/trevidiann/32/1542_2.png) [@trevidiann](https://mne.discourse.group/u/trevidiann)\
**Post date:** [June 5, 2022, 2:53pm UTC](https://mne.discourse.group/t/writting-mff-files-into-bids-problems-with-write-raw-bids/4999/1 "2022-06-05T14:53:50Z")

</div>

Hello, new to mne-python and could use some help. I’m currently trying to convert raw data from mff files into BIDS. At the moment I can read in and create a BIDS data structure with raw mff data, but I cannot convert a .bin file (from the mff file) into fif format.

**At the moment my program looks like this:**

```python
import matplotlib
import pathlib

import mne
import mne_bids

matplotlib.use('Qt5Agg')
mne.set_log_level('warning') 

raw_fname = pathlib.Path('subject_data') / 'WM_1_isi0_s1c_20191110_020011.mff'
raw = mne.io.read_raw_egi(raw_fname)

out_path = pathlib.Path('out_data2/sample_BIDS') #Into which directory the data should go

bids_path = mne_bids.BIDSPath(subject='01',
                              session='01',
                              task='WM1 isi0',
                              datatype='eeg',
                              root=out_path) 

mne_bids.write_raw_bids(raw, bids_path=bids_path, events_data=events, format='FIF', allow_preload=True,
                        event_id=event_id, overwrite=True)

```

**And spits out this error:**

```python
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Input In [6], in <cell line: 9>()
      1 out_path = pathlib.Path('out_data2/sample_BIDS') #Into which directory the data should go
      3 bids_path = mne_bids.BIDSPath(subject='01',
      4 session='01',
      5 task='WM1 isi0',
      6 datatype='eeg',
      7 root=out_path) #An object that specifies the location of BIDS files
----> 9 mne_bids.write_raw_bids(raw, bids_path=bids_path, events_data=events, format='FIF', allow_preload=True,
     10 event_id=event_id, overwrite=True)

File <decorator-gen-585>:12, in write_raw_bids(raw, bids_path, events_data, event_id, anonymize, format, symlink, empty_room, allow_preload, montage, acpc_aligned, overwrite, verbose)

File ~\anaconda3\envs\mne\lib\site-packages\mne_bids\write.py:1668, in write_raw_bids( ***failed resolving arguments*** )
   1663 make_dataset_description(bids_path.root, name=" ", overwrite=False)
   1665 _sidecar_json(raw, task=bids_path.task, manufacturer=manufacturer,
   1666 fname=sidecar_path.fpath, datatype=bids_path.datatype,
   1667 emptyroom_fname=associated_er_path, overwrite=overwrite)
-> 1668 _channels_tsv(raw, channels_path.fpath, overwrite)
   1670 # create parent directories if needed
   1671 _mkdir_p(os.path.dirname(data_path))

File ~\anaconda3\envs\mne\lib\site-packages\mne_bids\write.py:110, in _channels_tsv(raw, fname, overwrite)
    108 # get the manufacturer from the file in the Raw object
    109 _, ext = _parse_ext(raw.filenames[0])
--> 110 manufacturer = MANUFACTURERS[ext]
    112 ignored_channels = IGNORED_CHANNELS.get(manufacturer, list())
    114 status, ch_type, description = list(), list(), list()

KeyError: '.bin'

-----------------------------------

```

It appears that write\_raw\_bids is having problems converting .bin files into an fif format, though it could definitely be something else.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [June 7, 2022, 8:23am UTC](https://mne.discourse.group/t/writting-mff-files-into-bids-problems-with-write-raw-bids/4999/2 "2022-06-07T08:23:05Z")

</div>

Hello, I’m not familiar with this file format, is that generated by EGI systems?

Because there’s currently a pull request to add support for EGI to MNE-BIDS, meaning it’s not yet officially supported:

> <https://github.com/mne-tools/mne-bids/pull/1006>
>
> Added EGI as a manufacturer in the eeg\_manufacturers dict for extension '.bin' a…nd '.mff'. This PR closes issue #1005.

Also pinging @sappelhoff and @mscheltienne who probably followed this development more closely than I did! Also I think I remember @cbrnr was once dealing with MFF files, but I might be mistaken.

Handing out tags here like candy!!! 🍭

In any case,  
best of luck!

Richard

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [June 7, 2022, 8:38am UTC](https://mne.discourse.group/t/writting-mff-files-into-bids-problems-with-write-raw-bids/4999/3 "2022-06-07T08:38:12Z")

</div>

Sorry, I never worked with MFF (at least as far as I can remember 😆).

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [June 7, 2022, 12:09pm UTC](https://mne.discourse.group/t/writting-mff-files-into-bids-problems-with-write-raw-bids/4999/4 "2022-06-07T12:09:41Z")

</div>

Hello,

EEG datasets have to be converted to one of the formats for BIDS. Quoting the [`write_raw_bids` page](https://mne.tools/mne-bids/stable/generated/mne_bids.write_raw_bids.html):

> The original file is simply copied over if the original file format is BIDS-supported for that datatype. Otherwise, this function will convert to a BIDS-supported file format while warning the user. For EEG and iEEG data, conversion will be to BrainVision format; for MEG, conversion will be to FIFF.

And at the moment, `mne-bids` does not recognize what the `.bin` extension corresponds to and how to convert it to BrainVision format. I’m adding support in the PR linked by @richard but I still have to fix a couple of bugs… I’ll try to find time this week.

Best,  
Mathieu
