Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with conversion of BTI datasets #1155

Closed
nugenta opened this issue Jul 31, 2023 · 4 comments · Fixed by #1158
Closed

Problems with conversion of BTI datasets #1155

nugenta opened this issue Jul 31, 2023 · 4 comments · Fixed by #1158
Labels
Milestone

Comments

@nugenta
Copy link

nugenta commented Jul 31, 2023

Description of the problem

There are two problems with the conversion of BTI/4D data to BIDS format. The first is that if there is no headshape data, mne_bids.write_raw_bids will fail (in function copyfile_bti_mod).

The second issue is both an MNE bids and an MNE issue - not sure if I should replicate this issue there? When reading in a 4D dataset, raw.__init_kwargs is correctly populated with the full path for the dataset, i.e.

raw._init_kwargs['pdf_fname'] = '/path_to_file/4D/c,rfDC'

but the field for the config file

raw._init_kwargs['config_fname'] = 'config'

Without the full path to the config file, copyfile_bti_mod will fail.

Steps to reproduce

#requires definition of the 'meg_fname' filepath and 'topdir' filepath

raw=mne.io.read_raw_bti(meg_fname, head_shape_fname=None, convert=False)
bids_path = BIDSPath(subject=subjid, session='1', task='rest',
                    run='01', root=topdir, suffix='meg')
write_raw_bids(raw, bids_path, overwrite=True)

Expected results

I expect it to copy the files to the BIDS directory rather than erroring out

Actual results

Error because full path for config file is not specified:

Traceback (most recent call last):

Cell In[7], line 48
write_raw_bids(raw, bids_path, overwrite=True)

File :12 in write_raw_bids

File ~/mambaforge/envs/enigma_meg/lib/python3.11/site-packages/mne_bids/write.py:1979 in write_raw_bids
copyfile_bti(raw_orig, raw_dir)

File ~/mambaforge/envs/enigma_meg/lib/python3.11/site-packages/mne_bids/copyfiles.py:600 in copyfile_bti
sh.copyfile(raw._init_kwargs['config_fname'],

File ~/mambaforge/envs/enigma_meg/lib/python3.11/shutil.py:256 in copyfile
with open(src, 'rb') as fsrc:

FileNotFoundError: [Errno 2] No such file or directory: 'config'

Additional information

Using mne version 1.4.2 and mne-bids 0.12

@nugenta nugenta added the bug label Jul 31, 2023
@welcome
Copy link

welcome bot commented Jul 31, 2023

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

@sappelhoff
Copy link
Member

Hi, thanks for the report!

The second issue is both an MNE bids and an MNE issue - not sure if I should replicate this issue there? When reading in a 4D dataset, raw.__init_kwargs is correctly populated with the full path for the dataset, i.e.

please open an MNE-Python issue on the MNE-Python repository 👍

The first is that if there is no headshape data, mne_bids.write_raw_bids will fail (in function copyfile_bti_mod).

why do you not have a headshape file for your data? Have you had a look at the mne-bids codebase to identify the potential problem?

@nugenta
Copy link
Author

nugenta commented Jul 31, 2023

This is HCP data that I'm trying to get into a format resembling BIDS. Since the HCP did not distribute the data with the headshape or the locations of the fiducial points, I'm limited to organizing the data more-or-less in BIDS format with the -trans.fif file for coregistration. It will make it easier for me to modify software designed to work on BIDS format data if I have the HCP data in something close to BIDS.

@nugenta
Copy link
Author

nugenta commented Jul 31, 2023

Oh - and in response to the suggestion of identifying the source of the problem in the mne-bids codebase, it's just that copyfile_bti fails on line 602 of copyfiles.py:

sh.copyfile(raw._init_kwargs['head_shape_fname'],
                    op.join(dest, 'hs_file'))

It returns an error that sh.copyfile cannot accept an argument of type None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants