# Converting EDF to SNIRF file

**URL:** <https://mne.discourse.group/t/converting-edf-to-snirf-file/8602>\
**Category:** Support & Discussions\
**Tags:** fnirs, data-import, file-formats, export, raw\
**Created:** [April 8, 2024, 6:37pm UTC](https://mne.discourse.group/t/converting-edf-to-snirf-file/8602 "2024-04-08T18:37:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![akontra](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/akontra/32/3580_2.png) [@akontra](https://mne.discourse.group/u/akontra)\
**Post date:** [April 8, 2024, 6:37pm UTC](https://mne.discourse.group/t/converting-edf-to-snirf-file/8602/1 "2024-04-08T18:37:04Z")

</div>

Hi, I need help converting an edf file to snirf.  
tldr; A fNIRS recording session was accidentally saved to an .edf file. I’m now helping researchers convert this to a snirf file format so they can analyse the data. They don’t have data in any other format.  
This is what I have tried:

```python
import mne
from mne_nirs.io.snirf import write_raw_snirf
# Path to the EDF file
edf_file = '/content/ZZ_nirs_MI.edf'
raw_edf = mne.io.read_raw_edf(edf_file, preload=True, infer_types=True)
snirf_file = '/content/ZZ_nirs_MI.snirf'
write_raw_snirf(raw_edf, snirf_file, add_montage=False)

```

Which results in an error:

```python
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-b99011d6dbd9> in <cell line: 2>()
      1 # Write EDF data to SNIRF file
----> 2 write_raw_snirf(raw_edf, snirf_file, add_montage=False)

2 frames
/usr/local/lib/python3.10/dist-packages/mne/_fiff/pick.py in _picks_str_to_idx(info, picks, exclude, with_ref_meg, return_kind, extra_repr, allow_empty, orig_picks)
   1407 if sum(any_found) == 0:
   1408 if not allow_empty:
-> 1409 raise ValueError(
   1410 "picks (%s) could not be interpreted as "
   1411 'channel names (no channel "%s"), channel types (no '

ValueError: picks (['fnirs_cw_amplitude', 'fnirs_od', 'hbo', 'hbr']) could not be interpreted as channel names (no channel "['fnirs_cw_amplitude', 'fnirs_od', 'hbo', 'hbr']"), channel types (no type "['fnirs_cw_amplitude', 'fnirs_od', 'hbo', 'hbr']" present), or a generic type (just "all" or "data")

```

If I print `raw_edf.info` I get this:

```python
<Info | 8 non-empty values
 bads: []
 ch_names: Rx1 - Tx1 O2Hb (, Rx1 - Tx1 HHb (h, Rx1 - Tx2 O2Hb (, Rx1 - Tx2 ...
 chs: 48 EEG
 custom_ref_applied: False
 highpass: 0.0 Hz
 lowpass: 25.0 Hz
 meas_date: 2024-03-12 10:53:33 UTC
 nchan: 48
 projs: []
 sfreq: 50.0 Hz
 subject_info: 3 items (dict)
>

```

I have no clue how to proceed.  
I don’t understand what shape the data has to be in to be able to be saved to a snirf file format.

If anyone here can help me, I’ll be eternaly grateful for your help. Please let me know if more information is needed.
