Add public convert_to_bids method to BaseDataset for clean BIDS export#988
Conversation
…ut cache hash Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
convert_dataset_to_bids function for clean BIDS export
|
@bruAristimunha could we make |
|
@copilot, work on the last suggestion |
Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
Done in a0ae65d. The BIDS conversion logic is now a dataset = AlexMI()
bids_root = dataset.convert_to_bids(path='/data/bids', subjects=[1, 2])The standalone |
convert_dataset_to_bids function for clean BIDS exportconvert_to_bids method to BaseDataset for clean BIDS export
Co-authored-by: Pierre Guetschel <25532709+PierreGtch@users.noreply.github.com> Signed-off-by: Bru <b.aristimunha@gmail.com>
Co-authored-by: Pierre Guetschel <25532709+PierreGtch@users.noreply.github.com> Signed-off-by: Bru <b.aristimunha@gmail.com>
Co-authored-by: Pierre Guetschel <25532709+PierreGtch@users.noreply.github.com> Signed-off-by: Bru <b.aristimunha@gmail.com>
Add enhancement entry in whats_new.rst for the new convert_to_bids method. Fix versionadded from 1.1.0 to 1.5 in the docstring.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a0df1c352
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Update _BIDSInterfaceRawEDFNoDesc docstring to reference BaseDataset.convert_to_bids instead of the removed convert_dataset_to_bids function.
- Validate subjects against subject_list before the loop so invalid subjects are caught before any data is erased. - When overwrite=False, check for preexisting subject directories (e.g. from cache_config) to avoid writing duplicate BIDS files.
|
And the lock file @copilot? Should not exist within this function |
Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
Fixed in 9c58f2d.
|
- Set DatasetType to "raw" for public BIDS export (was "derivative") - Skip SourceDatasets DOI when None to avoid JSON schema violation - Write *_electrodes.json sidecar with SpatialReference (required by BIDS) - Move make_dataset_description after write loop with overwrite=True so it is not clobbered by mne_bids.write_raw_bids internal calls
The SpatialReference error was only triggered because DatasetType was "derivative". With DatasetType correctly set to "raw", the BIDS validator does not require SpatialReference in electrodes sidecars for raw EEG data. mne-bids handles everything needed.
Allow users to choose the output file format (EDF, BrainVision, BDF, EEGLAB) instead of always writing EDF. The format is propagated through BIDSInterfaceRawEDF to mne_bids.write_raw_bids, and the file-existence skip check uses the correct extension for the chosen format.
pybv >= 0.7.3 is required by mne-bids for converting files to BrainVision format, fixing CI ImportError in test_convert_to_bids_format.
BIDS conversion was only accessible via
get_data(cache_config=...), coupling it to the caching system and embedding a processing-pipeline hash (desc-<hash>) in all filenames — unsuitable for producing shareable BIDS datasets.Changes
BaseDataset.convert_to_bids(path=None, subjects=None, overwrite=False, verbose=None)method — the canonical public API for BIDS conversiondesc-<hash>entities in filenamesoverwrite=False(checks for existing EDF files); erases and re-saves onoverwrite=TruePath_BIDSInterfaceRawEDFNoDescsubclass — overridesdesc → None, overrides_write_lock_file()as a no-op, and replaceserase()withshutil.rmtreeon the subject directoryBIDSInterfaceBase.save()refactored to extract lock file writing into a_write_lock_file()method, allowing subclasses to opt outBIDSInterfaceBase.__repr__fixed to handledesc=Nonewithout aTypeErrorUsage
For pseudo-BIDS caching of epochs/arrays,
get_data(cache_config=...)remains the appropriate path.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.