# Using mne-bids to convert CTF data to bids format

**URL:** <https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336>\
**Category:** Support & Discussions\
**Tags:** mne-bids, mne-bids-pipeline\
**Created:** [July 27, 2022, 11:46am UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336 "2022-07-27T11:46:47Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![tghafari](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tghafari/32/1779_2.png) [@tghafari](https://mne.discourse.group/u/tghafari)\
**Post date:** [August 3, 2022, 1:19pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/22 "2022-08-03T13:19:20Z")

</div>

Now I upgraded to mne\_bids: 0.11.dev0, there’s an error with the BIDSPath:

```python
from mne_bids import BIDSPath, write_raw_bids

output_path = r'Z:\MEG_data\MNE-pilot-data-bids'
bids_path = BIDSPath(subject=subject, session=session,
                     task=task, run=run, root=output_path)

write_raw_bids(raw, bids_path, events_data=events_data, 
               event_id=events_id, overwrite=True)
Traceback (most recent call last):

  File "C:\Users\ghafarit\AppData\Local\Temp\ipykernel_23084\1508003131.py", line 1, in <module>
    write_raw_bids(raw, bids_path, events_data=events_data,

  File "<decorator-gen-611>", line 12, in write_raw_bids

  File "C:\Users\ghafarit\Anaconda3\envs\mne\lib\site-packages\mne_bids\write.py", line 1504, in write_raw_bids
    raise RuntimeError('"bids_path" must be a BIDSPath object. Please '

RuntimeError: "bids_path" must be a BIDSPath object. Please instantiate using mne_bids.BIDSPath().

```

What do you suggest I do now?

---

<div class="post-metadata">

**Author:** ![sappelhoff](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/sappelhoff/32/3276_2.png) [@sappelhoff](https://mne.discourse.group/u/sappelhoff)\
**Post date:** [August 3, 2022, 2:34pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/23 "2022-08-03T14:34:07Z")

</div>

No idea 🤷 from what you shared it’s not clear what the error could be. Progress with one error message at a time … anyhow, if this is a different issue, I suggest you investigate first and try to solve it. If you really hit a wall and cannot progress further or if you think you have identified a bug, please open a new report either here or on [Issues · mne-tools/mne-bids · GitHub](https://github.com/mne-tools/mne-bids/issues)

---

<div class="post-metadata">

**Author:** ![tghafari](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tghafari/32/1779_2.png) [@tghafari](https://mne.discourse.group/u/tghafari)\
**Post date:** [August 3, 2022, 3:14pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/24 "2022-08-03T15:14:34Z")

</div>

In order to convert the ctf data to bids format, I upgraded mne\_bids and that was the only thing I changed, everything else was the same as before (there was no error regarding BIDSPath when I was using mne\_bids:0.10). Basically the MWE is still the same as the one I shared with you before.

This error is the reason I can’t try the developer’s version of mne\_bids to see if on windows I can convert CTF data to bids format. and I could not solve it unfortunately.

That’s why I asked if you have any ideas how to solve it and move forward in converting ctf data to bids.

---

<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:** [August 3, 2022, 3:24pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/25 "2022-08-03T15:24:25Z")

</div>

Can you insert these lines directly above the call to `write_raw_bids()` please, and tell us the output it produces?

```python
print(type(bids_path))
print(bids_path)

```

Thanks!

---

<div class="post-metadata">

**Author:** ![tghafari](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tghafari/32/1779_2.png) [@tghafari](https://mne.discourse.group/u/tghafari)\
**Post date:** [August 3, 2022, 3:27pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/26 "2022-08-03T15:27:18Z")

</div>

Hi Richard,

Thanks for your reply.  
below please find the output and error:

```python
<class 'mne_bids.path.BIDSPath'>
Z:/MEG_data/MNE-pilot-data-bids/sub-02/ses-01/meg/sub-02_ses-01_task-SpAtt_run-01_meg.ds
Traceback (most recent call last):

  File "C:\Users\ghafarit\AppData\Local\Temp\ipykernel_23084\1067814209.py", line 3, in <module>
    write_raw_bids(raw, bids_path, events_data=events_data,

  File "<decorator-gen-611>", line 12, in write_raw_bids

  File "C:\Users\ghafarit\Anaconda3\envs\mne\lib\site-packages\mne_bids\write.py", line 1504, in write_raw_bids
    raise RuntimeError('"bids_path" must be a BIDSPath object. Please '

RuntimeError: "bids_path" must be a BIDSPath object. Please instantiate using mne_bids.BIDSPath().

```

thanks,  
Tara

---

<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:** [August 3, 2022, 5:22pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/27 "2022-08-03T17:22:41Z")

</div>

@tghafari Thank you!

@sappelhoff The type of the BIDSPath object looks kinda weird, no? Why does it have an entire “path to the namespace” (sorry, idk how to properly call this) prepended? I’ve never seen anything like this… this probably also explains why the check fails. I wonder if there are multiple MNE-BIDS installations interacting with each other in unforeseen ways?

---

<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:** [August 3, 2022, 5:27pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/28 "2022-08-03T17:27:42Z")

</div>

@tghafari Could you please share the output of:

```python
import mne_bids
print(mne_bids. __file__ )

```

Thank you so much!

---

<div class="post-metadata">

**Author:** ![sappelhoff](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/sappelhoff/32/3276_2.png) [@sappelhoff](https://mne.discourse.group/u/sappelhoff)\
**Post date:** [August 3, 2022, 6:32pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/29 "2022-08-03T18:32:39Z")

</div>

Could it also be some Windows specific stuff that we are not testing appropriately? 🤔

I couldn’t reproduce this issue on Ubuntu 18.04

---

<div class="post-metadata">

**Author:** ![tghafari](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tghafari/32/1779_2.png) [@tghafari](https://mne.discourse.group/u/tghafari)\
**Post date:** [August 4, 2022, 1:24pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/30 "2022-08-04T13:24:50Z")

</div>

thanks for following this up @richard

here’s the output:

```python
import mne_bids
print(mne_bids. __file__ )
C:\Users\ghafarit\Anaconda3\envs\mne\lib\site-packages\mne_bids\ __init__.py

```

---

<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:** [August 4, 2022, 1:41pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/31 "2022-08-04T13:41:43Z")

</div>

@sappelhoff

In any case:

- we should raise a `TypeError` instead of a `RuntimeError` here
- we should print what which type we actually received when we expected the `BIDSPath`

> [@tghafari](#):
>
> ```python
> RuntimeError: "bids_path" must be a BIDSPath object. Please instantiate using mne_bids.BIDSPath().
> 
> ```

---

<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:** [August 4, 2022, 1:42pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/32 "2022-08-04T13:42:23Z")

</div>

Thank you, I will look into this.

---

<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:** [August 4, 2022, 5:37pm UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/33 "2022-08-04T17:37:31Z")

</div>

> [@richard](#):
>
> @sappelhoff The type of the BIDSPath object looks kinda weird, no? Why does it have an entire “path to the namespace” (sorry, idk how to properly call this) prepended? I’ve never seen anything like this… this probably also explains why the check fails

Actually this is not correct; I get the same behavior on macOS:

```python
In [9]: from mne_bids import BIDSPath

In [10]: BIDSPath
Out[10]: mne_bids.path.BIDSPath

```

So this is not it.

@tghafari I suspect something with your installation is broken … I’d suggest you wait for the MNE-BIDS 0.11 release and then do a fresh install of everything.

Sorry I cannot be of more help.

Richard

---

<div class="post-metadata">

**Author:** ![tghafari](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tghafari/32/1779_2.png) [@tghafari](https://mne.discourse.group/u/tghafari)\
**Post date:** [August 5, 2022, 9:24am UTC](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/34 "2022-08-05T09:24:07Z")

</div>

Thanks @richard,

I hope I don’t have to wait for long. I am making all my scripts BIDS compatible at the moment, I will continue to use mne-bids 0.10 for .fif data for now until the next version is released.

Just to be clear, by “fresh install of everything” you mean uninstalling and installing mne-bids, right?

Bests,  
Tara

[Previous page](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336.md?page=1)
