@@ -48,8 +48,35 @@ def create_openminds_person(full_name):
4848
4949
5050def create_persons (dataset_description , collection ):
51+ # citation.cff case
52+ if "authors" in dataset_description :
53+ person_list = dataset_description ["authors" ]
54+ openminds_list = []
55+ for person in person_list :
56+ person_orcid = None
57+ person_affiliation = None
58+ person_contact_information = None
59+ if 'orcid' in person :
60+ person_orcid = [omcore .ORCID (identifier = person ['orcid' ])]
61+ if 'email' in person :
62+ person_contact_information = omcore .ContactInformation (email = person ['email' ])
63+ if 'affiliation' in person :
64+ # Handle multiple affiliations separated by semicolon
65+ affiliation_list = [item .strip () for item in person ['affiliation' ].split (';' )]
66+ person_affiliation = []
67+ for affiliation in affiliation_list :
68+ person_affiliation .append (omcore .Affiliation (
69+ member_of = omcore .Organization (full_name = affiliation )))
70+
71+ openminds_person = omcore .Person (
72+ affiliations = person_affiliation , digital_identifiers = person_orcid , given_name = person ['given-names' ],
73+ family_name = person ['family-names' ], contact_information = person_contact_information )
74+ openminds_list .append (openminds_person )
75+ collection .add (openminds_person )
76+ return openminds_list
5177
52- if "Authors" in dataset_description :
78+ # dataset_description.json case
79+ elif "Authors" in dataset_description :
5380 person_list = dataset_description ["Authors" ]
5481 else :
5582 return None
@@ -185,21 +212,39 @@ def create_openminds_age(data_subject):
185212 return None
186213
187214
188- def create_dataset_version (bids_layout , dataset_description , layout_df , studied_specimens , file_repository , behavioral_protocols , collection ):
215+ def create_dataset_version (bids_layout , citation , dataset_description , layout_df , studied_specimens , file_repository , behavioral_protocols , collection ):
189216
190217 # Fetch the dataset type from dataset description file
191218
192219 # dataset_type=bids2openminds_instance(dataset_description.get("DatasetType",None))
193-
194- # Fetch the digitalIdentifier from dataset description file
195-
196- if "DatasetDOI" in dataset_description :
197- digital_identifier = omcore .DOI (
198- identifier = dataset_description ["DatasetDOI" ])
220+ license = None
221+ digital_identifier = None
222+ name = None
223+ version_identifier = None
224+ # General rules on the usage of CITATION.cff and dataset_description.json
225+ # https://bids-specification.readthedocs.io/en/stable/modality-agnostic-files/dataset-description.html#citationcff
226+ if citation :
227+ if 'doi' in citation :
228+ digital_identifier = omcore .DOI (identifier = citation ['doi' ])
229+ if 'license' in citation :
230+ license = omcore .License .by_name (citation ['license' ])
231+ if license is None :
232+ warn (f"Could not resolve license '{ citation ['license' ]} ' "
233+ "to an openMINDS License."
234+ )
235+ if 'title' in citation :
236+ name = citation ['title' ]
237+ if 'version' in citation :
238+ version_identifier = citation ['version' ]
239+ authors = create_persons (citation , collection )
199240 else :
200- digital_identifier = None
241+ # if CITATION.cff is present, the "Authors" field of dataset_description.json MUST be omitted
242+ authors = create_persons (dataset_description , collection )
201243
202- authors = create_persons (dataset_description , collection )
244+ name = dataset_description ["Name" ] if name is None else name
245+ # Fetch the digitalIdentifier from dataset description file
246+ if digital_identifier is None and "DatasetDOI" in dataset_description :
247+ digital_identifier = omcore .DOI (identifier = dataset_description ["DatasetDOI" ])
203248
204249 if "Acknowledgements" in dataset_description :
205250 other_contribution = dataset_description ["Acknowledgements" ]
@@ -235,19 +280,20 @@ def create_dataset_version(bids_layout, dataset_description, layout_df, studied_
235280 experimental_approaches = create_approaches (layout_df )
236281
237282 dataset_version = omcore .DatasetVersion (
283+ authors = authors ,
284+ behavioral_protocols = behavioral_protocols ,
285+ data_types = dataset_type ,
238286 digital_identifier = digital_identifier ,
239287 experimental_approaches = experimental_approaches ,
240- short_name = dataset_description ["Name" ],
241- full_name = dataset_description ["Name" ],
242- studied_specimens = studied_specimens ,
243- authors = authors ,
244- techniques = techniques ,
288+ full_name = name ,
245289 how_to_cite = how_to_cite ,
290+ license = license ,
246291 repository = file_repository ,
247- behavioral_protocols = behavioral_protocols ,
248- data_types = dataset_type
292+ short_name = name ,
293+ studied_specimens = studied_specimens ,
294+ techniques = techniques ,
295+ version_identifier = version_identifier ,
249296 # other_contributions=other_contribution # needs to be a Contribution object
250- # version_identifier
251297 )
252298
253299 collection .add (dataset_version )
0 commit comments