Repository navigation
Extract metadata from CITATION.cff #90
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
Merged
apdavison
merged 14 commits into
openMetadataInitiative:main
from
Raphael-Gazzotti:citation-file-handling
May 31, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cdac4be
Extract metadata from CITATION.cff: doi, authors (orcid, affiliation)…
Raphael-Gazzotti cfe30fd
Removal of print.
Raphael-Gazzotti d72ea0e
Update bids2openminds/main.py
Raphael-Gazzotti f87d886
Correct Affiliation and add email.
Raphael-Gazzotti 183c256
Handle multiple affiliations separated by semicolon.
Raphael-Gazzotti 4d74da0
Add unit tests for CITATION.cff metadata extraction.
Raphael-Gazzotti e55c0ca
Add unit test for CITATION.cff DOI extraction.
Raphael-Gazzotti 1d8acc8
Updated to arrays.
Raphael-Gazzotti e8efa81
Add comment
Raphael-Gazzotti 593ab2c
Merge branch 'main' into citation-file-handling
Raphael-Gazzotti 288308f
Update to ancpbids
Raphael-Gazzotti bbab687
Reorder _ROOT_BIDS_FILES entries in converter.py
Raphael-Gazzotti 7fd41c4
Update bids2openminds/converter.py
Raphael-Gazzotti 0dcd580
Apply suggestions from @apdavison
Raphael-Gazzotti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import pytest | ||
|
|
||
| import pandas as pd | ||
| from openminds import Collection | ||
| import openminds.v4.core as omcore | ||
|
|
||
| from bids2openminds.main import create_dataset_version | ||
|
|
||
| # Mock BIDS layout DataFrame | ||
| layout_df = pd.DataFrame({ | ||
| "suffix": ["T1w", "T2w", "bold"], | ||
| "path": ["sub-01/anat/sub-01_T1w.nii.gz", "sub-01/anat/sub-01_T2w.nii.gz", "sub-01/func/sub-01_task-rest_bold.nii.gz"], | ||
| "datatype": ["anat", "anat", "func"] | ||
| }) | ||
|
|
||
|
|
||
| def test_create_dataset_version_citation(): | ||
|
Raphael-Gazzotti marked this conversation as resolved.
Resolved
|
||
| # Mock loaded CITATION.cff | ||
| citation = { | ||
|
Raphael-Gazzotti marked this conversation as resolved.
Resolved
|
||
| "title": "My Dataset", | ||
| "version": "1.05.9", | ||
| "doi": "10.5281/zenodo.123456", | ||
| "license": "Apache-2.0" | ||
| } | ||
|
|
||
| citation_dataset_version = create_dataset_version( | ||
| "", citation, {}, layout_df, [], [], [], Collection() | ||
| ) | ||
|
|
||
| expected = omcore.DatasetVersion( | ||
| digital_identifier=omcore.DOI(identifier="10.5281/zenodo.123456"), | ||
| full_name="My Dataset", | ||
| short_name="My Dataset", | ||
| license=omcore.License.apache_2_0, | ||
| version_identifier="1.05.9" | ||
| ) | ||
|
|
||
| for field in ["full_name", "short_name", "version_identifier", "license"]: | ||
| assert getattr(citation_dataset_version, field) == getattr(expected, field) | ||
| assert citation_dataset_version.digital_identifier.identifier == expected.digital_identifier.identifier | ||
|
|
||
|
|
||
| def test_create_dataset_version_without_citation(): | ||
| # Mock missing CITATION.cff | ||
| citation = None | ||
| dataset_description = { | ||
| "Name": "My Dataset", | ||
| "DatasetDOI": "10.5281/zenodo.123456" | ||
| } | ||
|
|
||
| dataset_version = create_dataset_version( | ||
| "", citation, dataset_description, layout_df, [], [], [], Collection() | ||
| ) | ||
|
|
||
| expected = omcore.DatasetVersion( | ||
| digital_identifier=omcore.DOI(identifier="10.5281/zenodo.123456"), | ||
| full_name="My Dataset", | ||
| short_name="My Dataset" | ||
| ) | ||
|
|
||
| for field in ["full_name", "short_name"]: | ||
| assert getattr(dataset_version, field) == getattr(expected, field) | ||
| assert dataset_version.digital_identifier.identifier == expected.digital_identifier.identifier | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.