Skip to content

Commit 186961c

Browse files
authored
Assorted minor fixes (#62)
* last minutes fixes * adding test
1 parent 465880b commit 186961c

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

bids2openminds/main.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def create_openminds_person(full_name):
2525

2626
# Handle the situation in which there is no given name or the given name consists of unwanted characters.
2727
if not (given_name and name_regex.match(given_name)):
28-
return None
28+
if not (len(family_name) > 0 and len(given_name) == 1):
29+
return None
2930

3031
# Handle the situation in which the family name consists of unwanted characters.
3132
if not (name_regex.match(family_name)):
@@ -66,8 +67,9 @@ def create_persons(dataset_description, collection):
6667
openminds_list = []
6768
for person in person_list:
6869
openminds_person = create_openminds_person(person)
69-
openminds_list.append(openminds_person)
70-
collection.add(openminds_person)
70+
if openminds_person is not None:
71+
openminds_list.append(openminds_person)
72+
collection.add(openminds_person)
7173

7274
return openminds_list
7375

@@ -172,6 +174,11 @@ def create_dataset_version(bids_layout, dataset_description, layout_df, studied_
172174
else:
173175
how_to_cite = None
174176

177+
if ("DatasetType" in dataset_description) and (dataset_description == "derivative"):
178+
dataset_type = controlled_terms.SemanticDataType.derived_data
179+
else:
180+
dataset_type = controlled_terms.SemanticDataType.raw_data
181+
175182
# TODO funding
176183
# if "Funding" in dataset_description:
177184
# funding=funding_openMINDS(dataset_description["Funding"])
@@ -194,12 +201,14 @@ def create_dataset_version(bids_layout, dataset_description, layout_df, studied_
194201
digital_identifier=digital_identifier,
195202
experimental_approaches=experimental_approaches,
196203
short_name=dataset_description["Name"],
204+
full_name=dataset_description["Name"],
197205
studied_specimens=studied_specimens,
198206
authors=authors,
199207
techniques=techniques,
200208
how_to_cite=how_to_cite,
201209
repository=file_repository,
202-
behavioral_protocols=behavioral_protocols
210+
behavioral_protocols=behavioral_protocols,
211+
data_types=dataset_type
203212
# other_contributions=other_contribution # needs to be a Contribution object
204213
# version_identifier
205214
)
@@ -211,15 +220,12 @@ def create_dataset_version(bids_layout, dataset_description, layout_df, studied_
211220

212221
def create_dataset(dataset_description, dataset_version, collection):
213222

214-
if "DatasetDOI" in dataset_description:
215-
digital_identifier = omcore.DOI(
216-
identifier=dataset_description["DatasetDOI"])
217-
else:
218-
digital_identifier = None
219-
220223
dataset = omcore.Dataset(
221-
digital_identifier=digital_identifier, full_name=dataset_description[
222-
"Name"], has_versions=dataset_version
224+
digital_identifier=dataset_version.digital_identifier,
225+
authors=dataset_version.authors,
226+
full_name=dataset_version.full_name,
227+
short_name=dataset_version.short_name,
228+
has_versions=dataset_version
223229
)
224230

225231
collection.add(dataset)

test/test_person.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
("Bilbo Baggins", "Bilbo", "Baggins"),
99
("Xue, G.", "G.", "Xue"),
1010
("Arndís Þórarinsdóttir", "Arndís", "Þórarinsdóttir"),
11-
("Loïc Le Clézio", "Loïc", "Le Clézio")]
11+
("Loïc Le Clézio", "Loïc", "Le Clézio"),
12+
("P Gandolf", "P", "Gandolf")]
1213

1314
example_not_names = ["42", "#", "", "A34 hajb"]
1415

0 commit comments

Comments
 (0)