Skip to content

Commit 927e39e

Browse files
authored
Merge pull request #198 from FZJ-INM1-BDA/bugfix_parcsEbrainDoi
bugfix: parcellation ebrains doi
2 parents 2907c66 + c706dfb commit 927e39e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

siibra/core/parcellation.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ def model_id(self):
570570
return self.id
571571

572572
def to_model(self, **kwargs) -> SiibraParcellationModel:
573+
574+
dois = [url.get("doi") if url.get("doi").startswith("http") else f"https://doi.org/{url.get('doi')}"
575+
for info in self.infos
576+
if hasattr(info, 'urls')
577+
for url in info.urls
578+
if url.get("doi")]
579+
ebrains_doi = dois[0] if len(dois) > 0 else None
573580
return SiibraParcellationModel(
574581
id=self.model_id,
575582
type=SIIBRA_PARCELLATION_MODEL_TYPE,
@@ -608,7 +615,11 @@ def to_model(self, **kwargs) -> SiibraParcellationModel:
608615
release_date=date(1970,1,1),
609616
short_name=self.name[:30],
610617
version_identifier=f"{self.version} in {spc.to_model().full_name}",
611-
version_innovation="",
618+
version_innovation=self.description,
619+
digital_identifier={
620+
"@id": ebrains_doi,
621+
"@type": "https://openminds.ebrains.eu/core/DOI"
622+
} if ebrains_doi is not None else None
612623
) for spc in self.supported_spaces],
613624
version=self.version.to_model(**kwargs) if self.version is not None else None
614625
)

test/core/test_parcellation.py

+16
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ def test_should_be_able_to_fetch_map(atlas_id,space_id,parc_id,map_type):
9595

9696
parc.get_map(space, map_type)
9797

98+
parc_has_ebrains_doi = [
99+
("human", "julich brain 2.9")
100+
]
101+
102+
@pytest.mark.parametrize('atlas_id,parc_id', parc_has_ebrains_doi)
103+
def test_should_have_ebrains_doi(atlas_id,parc_id):
104+
105+
atlas = siibra.atlases[atlas_id]
106+
parc = atlas.parcellations[parc_id]
107+
model = parc.to_model()
108+
all(
109+
ver.digital_identifier is not None
110+
and ver.digital_identifier.get("@type") == "https://openminds.ebrains.eu/core/DOI"
111+
and ver.digital_identifier.get("@id").startswith("https://doi.org")
112+
for ver in model.brain_atlas_versions
113+
)
98114

99115
if __name__ == "__main__":
100116
unittest.main()

0 commit comments

Comments
 (0)