From e182f97c7db464b8f3d79df151afe1d5c334483a Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Mon, 14 Jul 2025 03:06:11 +0200 Subject: [PATCH 1/8] correction of lookup label --- bids2openminds/converter.py | 4 +- bids2openminds/main.py | 28 +++++----- test/bids_examples_ds005.jsonld | 96 ++++++++++++++++----------------- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/bids2openminds/converter.py b/bids2openminds/converter.py index b2f63ca..5dbff03 100644 --- a/bids2openminds/converter.py +++ b/bids2openminds/converter.py @@ -32,8 +32,10 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal dataset_description = utility.read_json(dataset_description_path.iat[0, 0]) + dataset_name_snake_case = dataset_description["Name"].replace(" ", "-") + [subjects_dict, subject_state_dict, subjects_list] = main.create_subjects( - subjects_id, layout_df, bids_layout, collection) + subjects_id, layout_df, bids_layout, collection, dataset_name_snake_case) behavioral_protocols, behavioral_protocols_dict = main.create_behavioral_protocol( bids_layout, collection) diff --git a/bids2openminds/main.py b/bids2openminds/main.py index 92401f4..fc31a50 100644 --- a/bids2openminds/main.py +++ b/bids2openminds/main.py @@ -315,7 +315,7 @@ def sex_openminds(data_subject: pd.DataFrame): return None -def create_subjects(subject_id, layout_df, layout, collection): +def create_subjects(subject_id, layout_df, layout, collection, dataset_name): sessions = layout.get_sessions() subjects_dict = {} @@ -333,9 +333,9 @@ def create_subjects(subject_id, layout_df, layout, collection): # dealing with condition that have no seasion if not sessions: state = omcore.SubjectState( - internal_identifier=f"Studied state {subject_name}".strip( - ), - lookup_label=f"Studied state {subject_name}".strip() + lookup_label=f"{dataset_name}_{subject_name}_state-01".strip(), + internal_identifier=f"{subject_name}_state-01".strip( + ) ) collection.add(state) state_cache_dict[""] = state @@ -345,9 +345,8 @@ def create_subjects(subject_id, layout_df, layout, collection): for session in sessions: if not (table_filter(table_filter(layout_df, session, "session"), subject, "subject").empty): state = omcore.SubjectState( - internal_identifier=f"Studied state {subject_name} {session}".strip( - ), - lookup_label=f"Studied state {subject_name} {session}".strip( + lookup_label=f"{dataset_name}_{subject_name}_state-{session}".strip(), + internal_identifier=f"{subject_name}_state-{session}".strip( ) ) collection.add(state) @@ -355,7 +354,7 @@ def create_subjects(subject_id, layout_df, layout, collection): state_cache.append(state) subject_state_dict[f"{subject}"] = state_cache_dict subject_cache = omcore.Subject( - lookup_label=f"{subject_name}", + lookup_label=f"{dataset_name}_{subject_name}", internal_identifier=f"{subject_name}", studied_states=state_cache ) @@ -380,8 +379,9 @@ def create_subjects(subject_id, layout_df, layout, collection): state = omcore.SubjectState( age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), - internal_identifier=f"Studied state {subject_name}".strip(), - lookup_label=f"Studied state {subject_name}".strip() + internal_identifier=f"{subject_name}_state-01".strip( + ), + lookup_label=f"{dataset_name}_{subject_name}_state-01".strip() ) collection.add(state) state_cache_dict[""] = state @@ -392,10 +392,8 @@ def create_subjects(subject_id, layout_df, layout, collection): state = omcore.SubjectState( age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), - internal_identifier=f"Studied state {subject_name} {session}".strip( - ), - lookup_label=f"Studied state {subject_name} {session}".strip( - ) + internal_identifier=f"{subject_name}_state-{session}".strip(), + lookup_label=f"{dataset_name}_{subject_name}_state-{session}".strip() ) collection.add(state) state_cache_dict[f"{session}"] = state @@ -403,7 +401,7 @@ def create_subjects(subject_id, layout_df, layout, collection): subject_state_dict[f"{subject}"] = state_cache_dict subject_cache = omcore.Subject( biological_sex=sex_openminds(data_subject), - lookup_label=f"{subject_name}", + lookup_label=f"{dataset_name}_{subject_name}", internal_identifier=f"{subject_name}", # TODO species should default to homo sapiens species=spices_openminds(data_subject), diff --git a/test/bids_examples_ds005.jsonld b/test/bids_examples_ds005.jsonld index a3793d4..f07a1a0 100644 --- a/test/bids_examples_ds005.jsonld +++ b/test/bids_examples_ds005.jsonld @@ -13,8 +13,8 @@ }, "value": 28 }, - "internalIdentifier": "Studied state sub-01", - "lookupLabel": "Studied state sub-01" + "internalIdentifier": "sub-01_state-01", + "lookupLabel": "Mixed-gambles-task_sub-01_state-01" }, { "@id": "https://openminds.ebrains.eu/instances/unitOfMeasurement/year", @@ -28,7 +28,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-01", - "lookupLabel": "sub-01", + "lookupLabel": "Mixed-gambles-task_sub-01", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -71,8 +71,8 @@ }, "value": 21 }, - "internalIdentifier": "Studied state sub-02", - "lookupLabel": "Studied state sub-02" + "internalIdentifier": "sub-02_state-01", + "lookupLabel": "Mixed-gambles-task_sub-02_state-01" }, { "@id": "_:000006", @@ -81,7 +81,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-02", - "lookupLabel": "sub-02", + "lookupLabel": "Mixed-gambles-task_sub-02", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -110,8 +110,8 @@ }, "value": 27 }, - "internalIdentifier": "Studied state sub-03", - "lookupLabel": "Studied state sub-03" + "internalIdentifier": "sub-03_state-01", + "lookupLabel": "Mixed-gambles-task_sub-03_state-01" }, { "@id": "_:000009", @@ -120,7 +120,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-03", - "lookupLabel": "sub-03", + "lookupLabel": "Mixed-gambles-task_sub-03", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -140,8 +140,8 @@ }, "value": 25 }, - "internalIdentifier": "Studied state sub-04", - "lookupLabel": "Studied state sub-04" + "internalIdentifier": "sub-04_state-01", + "lookupLabel": "Mixed-gambles-task_sub-04_state-01" }, { "@id": "_:000011", @@ -150,7 +150,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-04", - "lookupLabel": "sub-04", + "lookupLabel": "Mixed-gambles-task_sub-04", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -170,8 +170,8 @@ }, "value": 20 }, - "internalIdentifier": "Studied state sub-05", - "lookupLabel": "Studied state sub-05" + "internalIdentifier": "sub-05_state-01", + "lookupLabel": "Mixed-gambles-task_sub-05_state-01" }, { "@id": "_:000013", @@ -180,7 +180,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-05", - "lookupLabel": "sub-05", + "lookupLabel": "Mixed-gambles-task_sub-05", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -200,8 +200,8 @@ }, "value": 20 }, - "internalIdentifier": "Studied state sub-06", - "lookupLabel": "Studied state sub-06" + "internalIdentifier": "sub-06_state-01", + "lookupLabel": "Mixed-gambles-task_sub-06_state-01" }, { "@id": "_:000015", @@ -210,7 +210,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-06", - "lookupLabel": "sub-06", + "lookupLabel": "Mixed-gambles-task_sub-06", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -230,8 +230,8 @@ }, "value": 24 }, - "internalIdentifier": "Studied state sub-07", - "lookupLabel": "Studied state sub-07" + "internalIdentifier": "sub-07_state-01", + "lookupLabel": "Mixed-gambles-task_sub-07_state-01" }, { "@id": "_:000017", @@ -240,7 +240,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-07", - "lookupLabel": "sub-07", + "lookupLabel": "Mixed-gambles-task_sub-07", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -260,8 +260,8 @@ }, "value": 25 }, - "internalIdentifier": "Studied state sub-08", - "lookupLabel": "Studied state sub-08" + "internalIdentifier": "sub-08_state-01", + "lookupLabel": "Mixed-gambles-task_sub-08_state-01" }, { "@id": "_:000019", @@ -270,7 +270,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-08", - "lookupLabel": "sub-08", + "lookupLabel": "Mixed-gambles-task_sub-08", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -290,8 +290,8 @@ }, "value": 19 }, - "internalIdentifier": "Studied state sub-09", - "lookupLabel": "Studied state sub-09" + "internalIdentifier": "sub-09_state-01", + "lookupLabel": "Mixed-gambles-task_sub-09_state-01" }, { "@id": "_:000021", @@ -300,7 +300,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-09", - "lookupLabel": "sub-09", + "lookupLabel": "Mixed-gambles-task_sub-09", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -320,8 +320,8 @@ }, "value": 20 }, - "internalIdentifier": "Studied state sub-10", - "lookupLabel": "Studied state sub-10" + "internalIdentifier": "sub-10_state-01", + "lookupLabel": "Mixed-gambles-task_sub-10_state-01" }, { "@id": "_:000023", @@ -330,7 +330,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-10", - "lookupLabel": "sub-10", + "lookupLabel": "Mixed-gambles-task_sub-10", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -350,8 +350,8 @@ }, "value": 20 }, - "internalIdentifier": "Studied state sub-11", - "lookupLabel": "Studied state sub-11" + "internalIdentifier": "sub-11_state-01", + "lookupLabel": "Mixed-gambles-task_sub-11_state-01" }, { "@id": "_:000025", @@ -360,7 +360,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-11", - "lookupLabel": "sub-11", + "lookupLabel": "Mixed-gambles-task_sub-11", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -380,8 +380,8 @@ }, "value": 21 }, - "internalIdentifier": "Studied state sub-12", - "lookupLabel": "Studied state sub-12" + "internalIdentifier": "sub-12_state-01", + "lookupLabel": "Mixed-gambles-task_sub-12_state-01" }, { "@id": "_:000027", @@ -390,7 +390,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-12", - "lookupLabel": "sub-12", + "lookupLabel": "Mixed-gambles-task_sub-12", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -410,8 +410,8 @@ }, "value": 22 }, - "internalIdentifier": "Studied state sub-13", - "lookupLabel": "Studied state sub-13" + "internalIdentifier": "sub-13_state-01", + "lookupLabel": "Mixed-gambles-task_sub-13_state-01" }, { "@id": "_:000029", @@ -420,7 +420,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-13", - "lookupLabel": "sub-13", + "lookupLabel": "Mixed-gambles-task_sub-13", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -440,8 +440,8 @@ }, "value": 19 }, - "internalIdentifier": "Studied state sub-14", - "lookupLabel": "Studied state sub-14" + "internalIdentifier": "sub-14_state-01", + "lookupLabel": "Mixed-gambles-task_sub-14_state-01" }, { "@id": "_:000031", @@ -450,7 +450,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-14", - "lookupLabel": "sub-14", + "lookupLabel": "Mixed-gambles-task_sub-14", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -470,8 +470,8 @@ }, "value": 20 }, - "internalIdentifier": "Studied state sub-15", - "lookupLabel": "Studied state sub-15" + "internalIdentifier": "sub-15_state-01", + "lookupLabel": "Mixed-gambles-task_sub-15_state-01" }, { "@id": "_:000033", @@ -480,7 +480,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-15", - "lookupLabel": "sub-15", + "lookupLabel": "Mixed-gambles-task_sub-15", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -500,8 +500,8 @@ }, "value": 22 }, - "internalIdentifier": "Studied state sub-16", - "lookupLabel": "Studied state sub-16" + "internalIdentifier": "sub-16_state-01", + "lookupLabel": "Mixed-gambles-task_sub-16_state-01" }, { "@id": "_:000035", @@ -510,7 +510,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-16", - "lookupLabel": "sub-16", + "lookupLabel": "Mixed-gambles-task_sub-16", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, From 41c709ecebba876daae5d9ff2bb5608a6f14eb52 Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Tue, 15 Jul 2025 14:23:11 +0200 Subject: [PATCH 2/8] using regex to exclude non ascii characters --- bids2openminds/converter.py | 6 +++++- test/bids_examples_ds005.jsonld | 2 +- test/bids_examples_eeg_rest_fmri.jsonld | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bids2openminds/converter.py b/bids2openminds/converter.py index 5dbff03..11eabcf 100644 --- a/bids2openminds/converter.py +++ b/bids2openminds/converter.py @@ -3,6 +3,7 @@ from openminds import Collection import os import click +import re from . import main from . import utility from . import report @@ -32,7 +33,10 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal dataset_description = utility.read_json(dataset_description_path.iat[0, 0]) - dataset_name_snake_case = dataset_description["Name"].replace(" ", "-") + dataset_name_snake_case = re.sub( + r'[^a-zA-Z]+', '-', dataset_description["Name"]) + if dataset_name_snake_case[-1] == "-": + dataset_name_snake_case = dataset_name_snake_case[0:-1] [subjects_dict, subject_state_dict, subjects_list] = main.create_subjects( subjects_id, layout_df, bids_layout, collection, dataset_name_snake_case) diff --git a/test/bids_examples_ds005.jsonld b/test/bids_examples_ds005.jsonld index f07a1a0..b7479e6 100644 --- a/test/bids_examples_ds005.jsonld +++ b/test/bids_examples_ds005.jsonld @@ -561,7 +561,7 @@ { "@id": "_:000039", "@type": "https://openminds.ebrains.eu/core/FileRepository", - "IRI": "file:///home/peyman-user/Desktop/data/bids_test/bids-examples/ds005", + "IRI": "PREFIX", "format": { "@id": "https://openminds.ebrains.eu/instances/contentTypes/application_vnd.bids" }, diff --git a/test/bids_examples_eeg_rest_fmri.jsonld b/test/bids_examples_eeg_rest_fmri.jsonld index 0067dfd..05eafdb 100644 --- a/test/bids_examples_eeg_rest_fmri.jsonld +++ b/test/bids_examples_eeg_rest_fmri.jsonld @@ -6,14 +6,14 @@ { "@id": "_:000000", "@type": "https://openminds.ebrains.eu/core/SubjectState", - "internalIdentifier": "Studied state sub-32", - "lookupLabel": "Studied state sub-32" + "internalIdentifier": "sub-32_state-01", + "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-32_state-01" }, { "@id": "_:000001", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-32", - "lookupLabel": "sub-32", + "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-32", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -40,14 +40,14 @@ { "@id": "_:000003", "@type": "https://openminds.ebrains.eu/core/SubjectState", - "internalIdentifier": "Studied state sub-35", - "lookupLabel": "Studied state sub-35" + "internalIdentifier": "sub-35_state-01", + "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-35_state-01" }, { "@id": "_:000004", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-35", - "lookupLabel": "sub-35", + "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-35", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -60,14 +60,14 @@ { "@id": "_:000005", "@type": "https://openminds.ebrains.eu/core/SubjectState", - "internalIdentifier": "Studied state sub-36", - "lookupLabel": "Studied state sub-36" + "internalIdentifier": "sub-36_state-01", + "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-36_state-01" }, { "@id": "_:000006", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-36", - "lookupLabel": "sub-36", + "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-36", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -118,7 +118,7 @@ { "@id": "_:000010", "@type": "https://openminds.ebrains.eu/core/FileRepository", - "IRI": "file:///home/peyman-user/Desktop/Code/bids-examples/eeg_rest_fmri", + "IRI": "PREFIX", "format": { "@id": "https://openminds.ebrains.eu/instances/contentTypes/application_vnd.bids" }, From 3f18f64ab9e77a8e913a1292599701dbdfbcd3ce Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Tue, 5 Aug 2025 15:49:36 +0200 Subject: [PATCH 3/8] short name prompt --- bids2openminds/converter.py | 31 +++++++---- bids2openminds/main.py | 8 +-- bids2openminds/report.py | 3 +- bids2openminds/utility.py | 71 +++++++++++++++++++++++++ docs/source/usage.rst | 29 ++++++---- test/bids_examples_ds005.jsonld | 68 +++++++++++------------ test/bids_examples_eeg_rest_fmri.jsonld | 14 ++--- test/test_bids_examples.py | 3 +- test/test_example_datasets_click.py | 7 +-- test/test_thorough_bids_example.py | 3 +- 10 files changed, 165 insertions(+), 72 deletions(-) diff --git a/bids2openminds/converter.py b/bids2openminds/converter.py index 11eabcf..40f1e1e 100644 --- a/bids2openminds/converter.py +++ b/bids2openminds/converter.py @@ -9,7 +9,7 @@ from . import report -def convert(input_path, save_output=False, output_path=None, multiple_files=False, include_empty_properties=False, quiet=False): +def convert(input_path, save_output=False, output_path=None, multiple_files=False, include_empty_properties=False, quiet=False, short_name=None): if not (os.path.isdir(input_path)): raise NotADirectoryError( f"The input directory is not valid, you have specified {input_path} which is not a directory." @@ -33,13 +33,23 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal dataset_description = utility.read_json(dataset_description_path.iat[0, 0]) - dataset_name_snake_case = re.sub( - r'[^a-zA-Z]+', '-', dataset_description["Name"]) - if dataset_name_snake_case[-1] == "-": - dataset_name_snake_case = dataset_name_snake_case[0:-1] + # Handle if short_name is explicitly set to False (i.e., wants auto-generation) + if short_name is False: + short_name = utility.create_short_name(dataset_description["Name"]) + + # If no short_name provided (i.e., None), prompt the user + if short_name is None: + short_name = utility.create_short_name(dataset_description["Name"]) + print(short_name) + input_name = input( + f"To convert this dataset, a short name is required. Currently, '{short_name}' was automatically assigned to your dataset.\n" + f"Please enter a more informative short name, or press Enter to keep the current one:\n" + ) + if input_name.strip(): + short_name = input_name.strip() [subjects_dict, subject_state_dict, subjects_list] = main.create_subjects( - subjects_id, layout_df, bids_layout, collection, dataset_name_snake_case) + subjects_id, layout_df, bids_layout, collection, short_name) behavioral_protocols, behavioral_protocols_dict = main.create_behavioral_protocol( bids_layout, collection) @@ -48,10 +58,10 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal layout_df, input_path, collection) dataset_version = main.create_dataset_version( - bids_layout, dataset_description, layout_df, subjects_list, file_repository, behavioral_protocols, collection) + bids_layout, dataset_description, layout_df, subjects_list, file_repository, behavioral_protocols, short_name, collection) dataset = main.create_dataset( - dataset_description, dataset_version, collection) + dataset_description, dataset_version, short_name, collection) failures = collection.validate(ignore=["required", "value"]) assert len(failures) == 0 @@ -83,9 +93,10 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal @click.option("--multiple-files", "multiple_files", flag_value=True, help="Each node is saved into a separate file within the specified directory. 'output-path' if specified, must be a directory.") @click.option("-e", "--include-empty-properties", is_flag=True, default=False, help="Whether to include empty properties in the final file.") @click.option("-q", "--quiet", is_flag=True, default=False, help="Not generate the final report and no warning.") -def convert_click(input_path, output_path, multiple_files, include_empty_properties, quiet): +@click.option("-n", "--short-name", default=None, help="Short name for the dataset. Set to False to auto-generate.") +def convert_click(input_path, output_path, multiple_files, include_empty_properties, quiet, short_name): convert(input_path, save_output=True, output_path=output_path, - multiple_files=multiple_files, include_empty_properties=include_empty_properties, quiet=quiet) + multiple_files=multiple_files, include_empty_properties=include_empty_properties, quiet=quiet, short_name=short_name) if __name__ == "__main__": diff --git a/bids2openminds/main.py b/bids2openminds/main.py index fc31a50..e56763f 100644 --- a/bids2openminds/main.py +++ b/bids2openminds/main.py @@ -184,7 +184,7 @@ def create_openminds_age(data_subject): return None -def create_dataset_version(bids_layout, dataset_description, layout_df, studied_specimens, file_repository, behavioral_protocols, collection): +def create_dataset_version(bids_layout, dataset_description, layout_df, studied_specimens, file_repository, behavioral_protocols, short_name, collection): # Fetch the dataset type from dataset description file @@ -236,7 +236,7 @@ def create_dataset_version(bids_layout, dataset_description, layout_df, studied_ dataset_version = omcore.DatasetVersion( digital_identifier=digital_identifier, experimental_approaches=experimental_approaches, - short_name=dataset_description["Name"], + short_name=short_name, full_name=dataset_description["Name"], studied_specimens=studied_specimens, authors=authors, @@ -254,13 +254,13 @@ def create_dataset_version(bids_layout, dataset_description, layout_df, studied_ return dataset_version -def create_dataset(dataset_description, dataset_version, collection): +def create_dataset(dataset_description, dataset_version, short_name, collection): dataset = omcore.Dataset( digital_identifier=dataset_version.digital_identifier, authors=dataset_version.authors, full_name=dataset_version.full_name, - short_name=dataset_version.short_name, + short_name=short_name, has_versions=dataset_version ) diff --git a/bids2openminds/report.py b/bids2openminds/report.py index 440a158..17aefb9 100644 --- a/bids2openminds/report.py +++ b/bids2openminds/report.py @@ -62,7 +62,8 @@ def create_report(dataset, dataset_version, collection, dataset_description, inp ================= Conversion was successful, the openMINDS file is in {output_path} -Dataset title : {dataset.full_name} +Dataset full name : {dataset.full_name} +Dataset short name: {dataset.short_name} Experimental approaches detected: diff --git a/bids2openminds/utility.py b/bids2openminds/utility.py index de02208..bfb1ac5 100644 --- a/bids2openminds/utility.py +++ b/bids2openminds/utility.py @@ -175,3 +175,74 @@ def detect_nifti_version(file_name, extension, file_size): return ContentType.by_name("application/vnd.nifti.2") return None + + +def create_short_name(full_name: str) -> str: + """ + Generate short name from a full name. + + Args: + full_name (str): A full name like "EEG, fMRI and NODDI at rest" + + Returns: + str: Either the full name or a shortened version "EEG-fMRI-&-NODDI-@R" + """ + substitutions = { + "and": "&", + "plus": "+", + "vs": "vs", + "versus": "vs", + "to": "→", + "from": "←", + "with": "+", + "without": "w/o", + "between": "↔", + "greater": ">", + "less": "<", + "equals": "=", + "equal": "=", + "not": "!", + "no": "!", + "or": "|", + "of": "", + "in": "@", + "at": "@", + "for": "4", + "by": "/", + "per": "/" + } + + # Return the full name as the short name, since shortening an already short dataset is not useful. + if len(full_name) < 10: + return full_name + + parts = re.split(r"[ \-\']+", full_name.strip()) + short_name = [] + if not parts: + return None + else: + for word in parts: + clean_word = word.strip(",.()") # Remove punctuation + if not clean_word: + continue + + word_lc = clean_word.lower() + + # 1. Substitution first + if word_lc in substitutions: + symbol = substitutions[word_lc] + if symbol: # Skip empty substitution like "of" + short_name.append(symbol) + continue + + # 2. Keep full word if it has ≥2 uppercase letters + num_upper = sum(1 for c in clean_word if c.isupper()) + if num_upper >= 2: + short_name.append(f"-{clean_word}-") + continue + + # 3. Default: First capital letter + short_name.append(clean_word[0].upper()) + + # Join, then clean up multiple dashes (e.g., in case of start/end) + return re.sub(r"-{2,}", "-", "".join(short_name)).strip("-") diff --git a/docs/source/usage.rst b/docs/source/usage.rst index d0e17f8..e1bb89f 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -13,7 +13,7 @@ The ``convert`` function processes a Brain Imaging Data Structure (BIDS) directo Function Signature ################## ->>> def convert(input_path, save_output=False, output_path=None, multiple_files=False, include_empty_properties=False, quiet=False): +>>> def convert(input_path, save_output=False, output_path=None, short_name=None, multiple_files=False, include_empty_properties=False, quiet=False): Parameters ########## @@ -23,6 +23,7 @@ Parameters - ``multiple_files`` (bool, default=False): If True, the OpenMINDS data will be saved into multiple files within the specified output_path. - ``include_empty_properties`` (bool, default=False): If True, includes all the openMINDS properties with empty values in the final output. Otherwise includes only properties that have a non `None` value. - ``quiet`` (bool, default=False): If True, suppresses warnings and the final report output. Only prints success messages. +- ``short_name`` (str or bool, default=None): A short name for this dataset. If set to a string, it will be used as the dataset's short name. If set to False, a short name will be assigned automatically. If None, the user will be prompted to enter one during conversion. Returns ####### @@ -32,7 +33,7 @@ Example Usage ############# >>> import bids2openminds.converter as converter >>> input_path = "/path/to/BIDS/dataset" ->>> collection = converter.convert(input_path, save_output=True, output_path="/path/to/output", multiple_files=False, include_empty_properties=False, quiet=False) +>>> collection = converter.convert(input_path, save_output=True, short_name=False, output_path="/path/to/output", multiple_files=False, include_empty_properties=False, quiet=False) Or one can chose the default parmetrs as following: @@ -48,14 +49,20 @@ This function is also accessible via a command-line interface using the `click` Usage: bids2openminds [OPTIONS] INPUT_PATH - Arguments: - input-path Path to the BIDS directory. - Options: - -o, --output-path PATH The output path or filename for OpenMINDS file/files. - --single-file Save the entire collection into a single file (default). - --multiple-files Save each node into a separate file within the specified directory. - -e, --include-empty-properties - Include empty properties in the final file. - -q, --quiet Suppress warnings and reports. + -o, --output-path PATH The output path or filename for OpenMINDS + file/files. + --single-file Save the entire collection into a single + file (default). + --multiple-files Each node is saved into a separate file + within the specified directory. 'output- + path' if specified, must be a directory. + -e, --include-empty-properties Whether to include empty properties in the + final file. + -q, --quiet Not generate the final report and no + warning. + -n, --short-name TEXT Short name for the dataset. Set to False to + auto-generate. + --help Show this message and exit. + diff --git a/test/bids_examples_ds005.jsonld b/test/bids_examples_ds005.jsonld index b7479e6..2f70fd5 100644 --- a/test/bids_examples_ds005.jsonld +++ b/test/bids_examples_ds005.jsonld @@ -14,7 +14,7 @@ "value": 28 }, "internalIdentifier": "sub-01_state-01", - "lookupLabel": "Mixed-gambles-task_sub-01_state-01" + "lookupLabel": "MGT_sub-01_state-01" }, { "@id": "https://openminds.ebrains.eu/instances/unitOfMeasurement/year", @@ -28,7 +28,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-01", - "lookupLabel": "Mixed-gambles-task_sub-01", + "lookupLabel": "MGT_sub-01", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -72,7 +72,7 @@ "value": 21 }, "internalIdentifier": "sub-02_state-01", - "lookupLabel": "Mixed-gambles-task_sub-02_state-01" + "lookupLabel": "MGT_sub-02_state-01" }, { "@id": "_:000006", @@ -81,7 +81,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-02", - "lookupLabel": "Mixed-gambles-task_sub-02", + "lookupLabel": "MGT_sub-02", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -111,7 +111,7 @@ "value": 27 }, "internalIdentifier": "sub-03_state-01", - "lookupLabel": "Mixed-gambles-task_sub-03_state-01" + "lookupLabel": "MGT_sub-03_state-01" }, { "@id": "_:000009", @@ -120,7 +120,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-03", - "lookupLabel": "Mixed-gambles-task_sub-03", + "lookupLabel": "MGT_sub-03", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -141,7 +141,7 @@ "value": 25 }, "internalIdentifier": "sub-04_state-01", - "lookupLabel": "Mixed-gambles-task_sub-04_state-01" + "lookupLabel": "MGT_sub-04_state-01" }, { "@id": "_:000011", @@ -150,7 +150,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-04", - "lookupLabel": "Mixed-gambles-task_sub-04", + "lookupLabel": "MGT_sub-04", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -171,7 +171,7 @@ "value": 20 }, "internalIdentifier": "sub-05_state-01", - "lookupLabel": "Mixed-gambles-task_sub-05_state-01" + "lookupLabel": "MGT_sub-05_state-01" }, { "@id": "_:000013", @@ -180,7 +180,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-05", - "lookupLabel": "Mixed-gambles-task_sub-05", + "lookupLabel": "MGT_sub-05", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -201,7 +201,7 @@ "value": 20 }, "internalIdentifier": "sub-06_state-01", - "lookupLabel": "Mixed-gambles-task_sub-06_state-01" + "lookupLabel": "MGT_sub-06_state-01" }, { "@id": "_:000015", @@ -210,7 +210,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-06", - "lookupLabel": "Mixed-gambles-task_sub-06", + "lookupLabel": "MGT_sub-06", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -231,7 +231,7 @@ "value": 24 }, "internalIdentifier": "sub-07_state-01", - "lookupLabel": "Mixed-gambles-task_sub-07_state-01" + "lookupLabel": "MGT_sub-07_state-01" }, { "@id": "_:000017", @@ -240,7 +240,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-07", - "lookupLabel": "Mixed-gambles-task_sub-07", + "lookupLabel": "MGT_sub-07", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -261,7 +261,7 @@ "value": 25 }, "internalIdentifier": "sub-08_state-01", - "lookupLabel": "Mixed-gambles-task_sub-08_state-01" + "lookupLabel": "MGT_sub-08_state-01" }, { "@id": "_:000019", @@ -270,7 +270,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-08", - "lookupLabel": "Mixed-gambles-task_sub-08", + "lookupLabel": "MGT_sub-08", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -291,7 +291,7 @@ "value": 19 }, "internalIdentifier": "sub-09_state-01", - "lookupLabel": "Mixed-gambles-task_sub-09_state-01" + "lookupLabel": "MGT_sub-09_state-01" }, { "@id": "_:000021", @@ -300,7 +300,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-09", - "lookupLabel": "Mixed-gambles-task_sub-09", + "lookupLabel": "MGT_sub-09", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -321,7 +321,7 @@ "value": 20 }, "internalIdentifier": "sub-10_state-01", - "lookupLabel": "Mixed-gambles-task_sub-10_state-01" + "lookupLabel": "MGT_sub-10_state-01" }, { "@id": "_:000023", @@ -330,7 +330,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-10", - "lookupLabel": "Mixed-gambles-task_sub-10", + "lookupLabel": "MGT_sub-10", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -351,7 +351,7 @@ "value": 20 }, "internalIdentifier": "sub-11_state-01", - "lookupLabel": "Mixed-gambles-task_sub-11_state-01" + "lookupLabel": "MGT_sub-11_state-01" }, { "@id": "_:000025", @@ -360,7 +360,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-11", - "lookupLabel": "Mixed-gambles-task_sub-11", + "lookupLabel": "MGT_sub-11", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -381,7 +381,7 @@ "value": 21 }, "internalIdentifier": "sub-12_state-01", - "lookupLabel": "Mixed-gambles-task_sub-12_state-01" + "lookupLabel": "MGT_sub-12_state-01" }, { "@id": "_:000027", @@ -390,7 +390,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-12", - "lookupLabel": "Mixed-gambles-task_sub-12", + "lookupLabel": "MGT_sub-12", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -411,7 +411,7 @@ "value": 22 }, "internalIdentifier": "sub-13_state-01", - "lookupLabel": "Mixed-gambles-task_sub-13_state-01" + "lookupLabel": "MGT_sub-13_state-01" }, { "@id": "_:000029", @@ -420,7 +420,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-13", - "lookupLabel": "Mixed-gambles-task_sub-13", + "lookupLabel": "MGT_sub-13", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -441,7 +441,7 @@ "value": 19 }, "internalIdentifier": "sub-14_state-01", - "lookupLabel": "Mixed-gambles-task_sub-14_state-01" + "lookupLabel": "MGT_sub-14_state-01" }, { "@id": "_:000031", @@ -450,7 +450,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-14", - "lookupLabel": "Mixed-gambles-task_sub-14", + "lookupLabel": "MGT_sub-14", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -471,7 +471,7 @@ "value": 20 }, "internalIdentifier": "sub-15_state-01", - "lookupLabel": "Mixed-gambles-task_sub-15_state-01" + "lookupLabel": "MGT_sub-15_state-01" }, { "@id": "_:000033", @@ -480,7 +480,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-15", - "lookupLabel": "Mixed-gambles-task_sub-15", + "lookupLabel": "MGT_sub-15", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -501,7 +501,7 @@ "value": 22 }, "internalIdentifier": "sub-16_state-01", - "lookupLabel": "Mixed-gambles-task_sub-16_state-01" + "lookupLabel": "MGT_sub-16_state-01" }, { "@id": "_:000035", @@ -510,7 +510,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-16", - "lookupLabel": "Mixed-gambles-task_sub-16", + "lookupLabel": "MGT_sub-16", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -5530,7 +5530,7 @@ "repository": { "@id": "_:000039" }, - "shortName": "Mixed-gambles task", + "shortName": "MGT", "studiedSpecimen": [ { "@id": "_:000002" @@ -5648,7 +5648,7 @@ "@id": "_:000229" } ], - "shortName": "Mixed-gambles task" + "shortName": "MGT" } ] } diff --git a/test/bids_examples_eeg_rest_fmri.jsonld b/test/bids_examples_eeg_rest_fmri.jsonld index 05eafdb..10ed38d 100644 --- a/test/bids_examples_eeg_rest_fmri.jsonld +++ b/test/bids_examples_eeg_rest_fmri.jsonld @@ -7,13 +7,13 @@ "@id": "_:000000", "@type": "https://openminds.ebrains.eu/core/SubjectState", "internalIdentifier": "sub-32_state-01", - "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-32_state-01" + "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-32_state-01" }, { "@id": "_:000001", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-32", - "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-32", + "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-32", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -41,13 +41,13 @@ "@id": "_:000003", "@type": "https://openminds.ebrains.eu/core/SubjectState", "internalIdentifier": "sub-35_state-01", - "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-35_state-01" + "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-35_state-01" }, { "@id": "_:000004", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-35", - "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-35", + "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-35", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -61,13 +61,13 @@ "@id": "_:000005", "@type": "https://openminds.ebrains.eu/core/SubjectState", "internalIdentifier": "sub-36_state-01", - "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-36_state-01" + "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-36_state-01" }, { "@id": "_:000006", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-36", - "lookupLabel": "EEG-fMRI-and-NODDI-at-rest_sub-36", + "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-36", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -1838,7 +1838,7 @@ "repository": { "@id": "_:000010" }, - "shortName": "EEG, fMRI and NODDI at rest'", + "shortName": "EEG-fMRI-&-NODDI-@R", "studiedSpecimen": [ { "@id": "_:000001" diff --git a/test/test_bids_examples.py b/test/test_bids_examples.py index 7f3ed24..c517243 100644 --- a/test/test_bids_examples.py +++ b/test/test_bids_examples.py @@ -17,7 +17,8 @@ @pytest.mark.parametrize("dataset_label, dataset_subject_number, dataset_subject_state_number, dataset_person_number, dataset_files_number, dataset_file_bundles_number, dataset_behavioral_protocol_number", example_dataset) def test_example_datasets(dataset_label, dataset_subject_number, dataset_subject_state_number, dataset_person_number, dataset_files_number, dataset_file_bundles_number, dataset_behavioral_protocol_number): test_dir = os.path.join("bids-examples", dataset_label) - bids2openminds.converter.convert(test_dir, save_output=True) + bids2openminds.converter.convert( + test_dir, save_output=True, short_name=False) c = Collection() c.load(os.path.join(test_dir, "openminds.jsonld")) diff --git a/test/test_example_datasets_click.py b/test/test_example_datasets_click.py index 3c32416..47d6dd5 100644 --- a/test/test_example_datasets_click.py +++ b/test/test_example_datasets_click.py @@ -10,7 +10,7 @@ def test_example_datasets_click(): test_dir = os.path.join("bids-examples", test_data_set) runner = CliRunner() - result = runner.invoke(convert_click, [test_dir]) + result = runner.invoke(convert_click, [test_dir, "--short-name", "False"]) assert result.exit_code == 0 c = Collection() c.load(os.path.join(test_dir, "openminds.jsonld")) @@ -22,7 +22,8 @@ def test_example_datasets_click_seperate_files(): if os.path.isdir(path_openminds): shutil.rmtree(path_openminds) runner = CliRunner() - result = runner.invoke(convert_click, ["--multiple-files", test_dir]) + result = runner.invoke( + convert_click, ["--multiple-files", test_dir, "--short-name", "False"]) assert result.exit_code == 0 numer_of_files = len(os.listdir(path_openminds)) assert numer_of_files == number_of_openminds_files @@ -33,7 +34,7 @@ def test_example_datasets_click_output_location(): openminds_file = os.path.join("bids-examples", "test_openminds.jsonld") runner = CliRunner() result = runner.invoke( - convert_click, ["-o", openminds_file, test_dir]) + convert_click, ["-o", openminds_file, test_dir, "--short-name", "False"]) assert result.exit_code == 0 c = Collection() c.load(openminds_file) diff --git a/test/test_thorough_bids_example.py b/test/test_thorough_bids_example.py index 9360221..47e9841 100644 --- a/test/test_thorough_bids_example.py +++ b/test/test_thorough_bids_example.py @@ -33,7 +33,8 @@ def load_collections(): reference_collection = Collection() reference_collection.load(tempdir+test_standard_name) - bids2openminds.converter.convert(test_dataset, save_output=True) + bids2openminds.converter.convert( + test_dataset, save_output=True, short_name=False) generated_collection = Collection() generated_collection.load(os.path.join( test_dataset, "openminds.jsonld")) From b845c3234290c77a2ee01d3bad2387ff84f7d08d Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Tue, 5 Aug 2025 15:57:22 +0200 Subject: [PATCH 4/8] dataset_name->dataset_short_name --- bids2openminds/main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bids2openminds/main.py b/bids2openminds/main.py index e56763f..0bb8c8b 100644 --- a/bids2openminds/main.py +++ b/bids2openminds/main.py @@ -315,7 +315,7 @@ def sex_openminds(data_subject: pd.DataFrame): return None -def create_subjects(subject_id, layout_df, layout, collection, dataset_name): +def create_subjects(subject_id, layout_df, layout, collection, dataset_short_name): sessions = layout.get_sessions() subjects_dict = {} @@ -333,7 +333,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_name): # dealing with condition that have no seasion if not sessions: state = omcore.SubjectState( - lookup_label=f"{dataset_name}_{subject_name}_state-01".strip(), + lookup_label=f"{dataset_short_name}_{subject_name}_state-01".strip(), internal_identifier=f"{subject_name}_state-01".strip( ) ) @@ -345,7 +345,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_name): for session in sessions: if not (table_filter(table_filter(layout_df, session, "session"), subject, "subject").empty): state = omcore.SubjectState( - lookup_label=f"{dataset_name}_{subject_name}_state-{session}".strip(), + lookup_label=f"{dataset_short_name}_{subject_name}_state-{session}".strip(), internal_identifier=f"{subject_name}_state-{session}".strip( ) ) @@ -354,7 +354,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_name): state_cache.append(state) subject_state_dict[f"{subject}"] = state_cache_dict subject_cache = omcore.Subject( - lookup_label=f"{dataset_name}_{subject_name}", + lookup_label=f"{dataset_short_name}_{subject_name}", internal_identifier=f"{subject_name}", studied_states=state_cache ) @@ -381,7 +381,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_name): handedness=handedness_openminds(data_subject), internal_identifier=f"{subject_name}_state-01".strip( ), - lookup_label=f"{dataset_name}_{subject_name}_state-01".strip() + lookup_label=f"{dataset_short_name}_{subject_name}_state-01".strip() ) collection.add(state) state_cache_dict[""] = state @@ -393,7 +393,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_name): age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), internal_identifier=f"{subject_name}_state-{session}".strip(), - lookup_label=f"{dataset_name}_{subject_name}_state-{session}".strip() + lookup_label=f"{dataset_short_name}_{subject_name}_state-{session}".strip() ) collection.add(state) state_cache_dict[f"{session}"] = state @@ -401,7 +401,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_name): subject_state_dict[f"{subject}"] = state_cache_dict subject_cache = omcore.Subject( biological_sex=sex_openminds(data_subject), - lookup_label=f"{dataset_name}_{subject_name}", + lookup_label=f"{dataset_short_name}_{subject_name}", internal_identifier=f"{subject_name}", # TODO species should default to homo sapiens species=spices_openminds(data_subject), From 367e48d6784919de941840a5b3b0f39650ec76c6 Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Tue, 5 Aug 2025 15:59:34 +0200 Subject: [PATCH 5/8] Arguments --- docs/source/usage.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index e1bb89f..8d43262 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -49,6 +49,9 @@ This function is also accessible via a command-line interface using the `click` Usage: bids2openminds [OPTIONS] INPUT_PATH + Arguments: + input-path Path to the BIDS directory. + Options: -o, --output-path PATH The output path or filename for OpenMINDS file/files. From fc671691ad01585f9bce5be935bd53023a6da39e Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Fri, 8 Aug 2025 13:07:37 +0200 Subject: [PATCH 6/8] Read the Docs --- docs/source/usage.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 8d43262..7cd7710 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -23,7 +23,7 @@ Parameters - ``multiple_files`` (bool, default=False): If True, the OpenMINDS data will be saved into multiple files within the specified output_path. - ``include_empty_properties`` (bool, default=False): If True, includes all the openMINDS properties with empty values in the final output. Otherwise includes only properties that have a non `None` value. - ``quiet`` (bool, default=False): If True, suppresses warnings and the final report output. Only prints success messages. -- ``short_name`` (str or bool, default=None): A short name for this dataset. If set to a string, it will be used as the dataset's short name. If set to False, a short name will be assigned automatically. If None, the user will be prompted to enter one during conversion. +- ``short_name`` (str or bool, default=None): A short name for this dataset. If set to a string, it will be used as the dataset's short name. If set to ``False``, a short name will be assigned automatically. If ``None``, the user will be prompted to enter one during conversion. Returns ####### @@ -47,7 +47,7 @@ This function is also accessible via a command-line interface using the `click` .. code-block:: console - Usage: bids2openminds [OPTIONS] INPUT_PATH + Usage: bids2openminds INPUT_PATH [OPTIONS] Arguments: input-path Path to the BIDS directory. From 48e76ea084745fb1077662830dd9d8ad2ed6c4a9 Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Mon, 3 Nov 2025 12:10:22 +0100 Subject: [PATCH 7/8] Modifying to ses and etc --- bids2openminds/converter.py | 53 +++++++++++++++++++-------- bids2openminds/main.py | 26 ++++++++------ bids2openminds/report.py | 4 +-- bids2openminds/utility.py | 71 ------------------------------------- docs/source/usage.rst | 16 ++++----- 5 files changed, 64 insertions(+), 106 deletions(-) diff --git a/bids2openminds/converter.py b/bids2openminds/converter.py index 40f1e1e..80cf578 100644 --- a/bids2openminds/converter.py +++ b/bids2openminds/converter.py @@ -33,20 +33,39 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal dataset_description = utility.read_json(dataset_description_path.iat[0, 0]) - # Handle if short_name is explicitly set to False (i.e., wants auto-generation) - if short_name is False: - short_name = utility.create_short_name(dataset_description["Name"]) - - # If no short_name provided (i.e., None), prompt the user if short_name is None: - short_name = utility.create_short_name(dataset_description["Name"]) - print(short_name) - input_name = input( - f"To convert this dataset, a short name is required. Currently, '{short_name}' was automatically assigned to your dataset.\n" - f"Please enter a more informative short name, or press Enter to keep the current one:\n" - ) - if input_name.strip(): - short_name = input_name.strip() + while True: + input_name = input( + "To convert this dataset, a short name is required.\n" + "Please enter an informative short name (less than 10 characters).\n" + "If you don't want to assign one now, press Enter, " + "lookup labels and internal identifiers will be the same.\n> " + ).strip() + + # User pressed Enter → skip assigning + if not input_name: + short_name = None + break + + # Check length + if len(input_name) < 10: + short_name = input_name + break + else: + print( + "The short name must be fewer than 10 characters. Please try again.\n") + + elif short_name is False: + # Explicit opt-out — skip prompt + short_name = None + + else: + # Ensure the short name has no spaces and is under 10 characters + short_name = short_name.replace(" ", "") + if len(short_name) > 10: + while len(short_name) > 10: + short_name = input( + "The short name must be fewer than 10 characters. Please try again.").strip() [subjects_dict, subject_state_dict, subjects_list] = main.create_subjects( subjects_id, layout_df, bids_layout, collection, short_name) @@ -76,9 +95,13 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal collection.save(output_path, individual_files=multiple_files, include_empty_properties=include_empty_properties) + save_text = f"the openMINDS file is in {output_path}" + else: + save_text = save_text = "No files were saved; the function returned the output collection instead." + if not quiet: print(report.create_report(dataset, dataset_version, collection, - dataset_description, input_path, output_path)) + dataset_description, input_path, save_text)) else: print("Conversion was successful") @@ -93,7 +116,7 @@ def convert(input_path, save_output=False, output_path=None, multiple_files=Fal @click.option("--multiple-files", "multiple_files", flag_value=True, help="Each node is saved into a separate file within the specified directory. 'output-path' if specified, must be a directory.") @click.option("-e", "--include-empty-properties", is_flag=True, default=False, help="Whether to include empty properties in the final file.") @click.option("-q", "--quiet", is_flag=True, default=False, help="Not generate the final report and no warning.") -@click.option("-n", "--short-name", default=None, help="Short name for the dataset. Set to False to auto-generate.") +@click.option("-n", "--short-name", default=None, help="Short name for the dataset (less than 10 characters). If None, you'll be prompted (default); if False, no short name will be assigned.") def convert_click(input_path, output_path, multiple_files, include_empty_properties, quiet, short_name): convert(input_path, save_output=True, output_path=output_path, multiple_files=multiple_files, include_empty_properties=include_empty_properties, quiet=quiet, short_name=short_name) diff --git a/bids2openminds/main.py b/bids2openminds/main.py index 0bb8c8b..ce79777 100644 --- a/bids2openminds/main.py +++ b/bids2openminds/main.py @@ -317,6 +317,12 @@ def sex_openminds(data_subject: pd.DataFrame): def create_subjects(subject_id, layout_df, layout, collection, dataset_short_name): + if dataset_short_name: + dataset_short_name_ = dataset_short_name + "_" + else: + # If there is no short name, assign an empty string so lookup labels don’t include it + dataset_short_name_ = "" + sessions = layout.get_sessions() subjects_dict = {} subjects_list = [] @@ -333,8 +339,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam # dealing with condition that have no seasion if not sessions: state = omcore.SubjectState( - lookup_label=f"{dataset_short_name}_{subject_name}_state-01".strip(), - internal_identifier=f"{subject_name}_state-01".strip( + lookup_label=f"{dataset_short_name_}{subject_name}".strip(), + internal_identifier=f"{subject_name}".strip( ) ) collection.add(state) @@ -345,8 +351,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam for session in sessions: if not (table_filter(table_filter(layout_df, session, "session"), subject, "subject").empty): state = omcore.SubjectState( - lookup_label=f"{dataset_short_name}_{subject_name}_state-{session}".strip(), - internal_identifier=f"{subject_name}_state-{session}".strip( + lookup_label=f"{dataset_short_name_}{subject_name}_session-{session}".strip(), + internal_identifier=f"{subject_name}_session-{session}".strip( ) ) collection.add(state) @@ -354,7 +360,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam state_cache.append(state) subject_state_dict[f"{subject}"] = state_cache_dict subject_cache = omcore.Subject( - lookup_label=f"{dataset_short_name}_{subject_name}", + lookup_label=f"{dataset_short_name_}{subject_name}", internal_identifier=f"{subject_name}", studied_states=state_cache ) @@ -379,9 +385,9 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam state = omcore.SubjectState( age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), - internal_identifier=f"{subject_name}_state-01".strip( + internal_identifier=f"{subject_name}".strip( ), - lookup_label=f"{dataset_short_name}_{subject_name}_state-01".strip() + lookup_label=f"{dataset_short_name_}{subject_name}".strip() ) collection.add(state) state_cache_dict[""] = state @@ -392,8 +398,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam state = omcore.SubjectState( age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), - internal_identifier=f"{subject_name}_state-{session}".strip(), - lookup_label=f"{dataset_short_name}_{subject_name}_state-{session}".strip() + internal_identifier=f"{subject_name}_session-{session}".strip(), + lookup_label=f"{dataset_short_name_}{subject_name}_session-{session}".strip() ) collection.add(state) state_cache_dict[f"{session}"] = state @@ -401,7 +407,7 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam subject_state_dict[f"{subject}"] = state_cache_dict subject_cache = omcore.Subject( biological_sex=sex_openminds(data_subject), - lookup_label=f"{dataset_short_name}_{subject_name}", + lookup_label=f"{dataset_short_name_}{subject_name}", internal_identifier=f"{subject_name}", # TODO species should default to homo sapiens species=spices_openminds(data_subject), diff --git a/bids2openminds/report.py b/bids2openminds/report.py index 17aefb9..f984006 100644 --- a/bids2openminds/report.py +++ b/bids2openminds/report.py @@ -1,7 +1,7 @@ import os -def create_report(dataset, dataset_version, collection, dataset_description, input_path, output_path): +def create_report(dataset, dataset_version, collection, dataset_description, input_path, save_text): subject_number = 0 subject_state_numbers = [] file_bundle_number = 0 @@ -60,7 +60,7 @@ def create_report(dataset, dataset_version, collection, dataset_description, inp report = f""" Conversion Report ================= -Conversion was successful, the openMINDS file is in {output_path} +Conversion was successful, {save_text} Dataset full name : {dataset.full_name} Dataset short name: {dataset.short_name} diff --git a/bids2openminds/utility.py b/bids2openminds/utility.py index bfb1ac5..de02208 100644 --- a/bids2openminds/utility.py +++ b/bids2openminds/utility.py @@ -175,74 +175,3 @@ def detect_nifti_version(file_name, extension, file_size): return ContentType.by_name("application/vnd.nifti.2") return None - - -def create_short_name(full_name: str) -> str: - """ - Generate short name from a full name. - - Args: - full_name (str): A full name like "EEG, fMRI and NODDI at rest" - - Returns: - str: Either the full name or a shortened version "EEG-fMRI-&-NODDI-@R" - """ - substitutions = { - "and": "&", - "plus": "+", - "vs": "vs", - "versus": "vs", - "to": "→", - "from": "←", - "with": "+", - "without": "w/o", - "between": "↔", - "greater": ">", - "less": "<", - "equals": "=", - "equal": "=", - "not": "!", - "no": "!", - "or": "|", - "of": "", - "in": "@", - "at": "@", - "for": "4", - "by": "/", - "per": "/" - } - - # Return the full name as the short name, since shortening an already short dataset is not useful. - if len(full_name) < 10: - return full_name - - parts = re.split(r"[ \-\']+", full_name.strip()) - short_name = [] - if not parts: - return None - else: - for word in parts: - clean_word = word.strip(",.()") # Remove punctuation - if not clean_word: - continue - - word_lc = clean_word.lower() - - # 1. Substitution first - if word_lc in substitutions: - symbol = substitutions[word_lc] - if symbol: # Skip empty substitution like "of" - short_name.append(symbol) - continue - - # 2. Keep full word if it has ≥2 uppercase letters - num_upper = sum(1 for c in clean_word if c.isupper()) - if num_upper >= 2: - short_name.append(f"-{clean_word}-") - continue - - # 3. Default: First capital letter - short_name.append(clean_word[0].upper()) - - # Join, then clean up multiple dashes (e.g., in case of start/end) - return re.sub(r"-{2,}", "-", "".join(short_name)).strip("-") diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 7cd7710..0583fd9 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -23,7 +23,7 @@ Parameters - ``multiple_files`` (bool, default=False): If True, the OpenMINDS data will be saved into multiple files within the specified output_path. - ``include_empty_properties`` (bool, default=False): If True, includes all the openMINDS properties with empty values in the final output. Otherwise includes only properties that have a non `None` value. - ``quiet`` (bool, default=False): If True, suppresses warnings and the final report output. Only prints success messages. -- ``short_name`` (str or bool, default=None): A short name for this dataset. If set to a string, it will be used as the dataset's short name. If set to ``False``, a short name will be assigned automatically. If ``None``, the user will be prompted to enter one during conversion. +- ``short_name`` (str or bool, default=None): A short name for the dataset (less than 10 characters). If None, you'll be prompted (default); if False, no short name will be assigned. Returns ####### @@ -33,7 +33,7 @@ Example Usage ############# >>> import bids2openminds.converter as converter >>> input_path = "/path/to/BIDS/dataset" ->>> collection = converter.convert(input_path, save_output=True, short_name=False, output_path="/path/to/output", multiple_files=False, include_empty_properties=False, quiet=False) +>>> collection = converter.convert(input_path, save_output=True, short_name=ShortName, output_path="/path/to/output", multiple_files=False, include_empty_properties=False, quiet=False) Or one can chose the default parmetrs as following: @@ -47,10 +47,7 @@ This function is also accessible via a command-line interface using the `click` .. code-block:: console - Usage: bids2openminds INPUT_PATH [OPTIONS] - - Arguments: - input-path Path to the BIDS directory. + Usage: bids2openminds [OPTIONS] INPUT_PATH Options: -o, --output-path PATH The output path or filename for OpenMINDS @@ -64,8 +61,11 @@ This function is also accessible via a command-line interface using the `click` final file. -q, --quiet Not generate the final report and no warning. - -n, --short-name TEXT Short name for the dataset. Set to False to - auto-generate. + -n, --short-name TEXT Short name for the dataset (less than 10 + characters). If None, you'll be prompted + (default); if False, no short name will be + assigned. --help Show this message and exit. + From 186c42d6d919c855381726988d10a12609c7e122 Mon Sep 17 00:00:00 2001 From: Peyman-N Date: Mon, 3 Nov 2025 12:10:45 +0100 Subject: [PATCH 8/8] modifying tests --- bids2openminds/main.py | 18 +++--- test/bids_examples_ds005.jsonld | 84 ++++++++++--------------- test/bids_examples_eeg_rest_fmri.jsonld | 19 +++--- 3 files changed, 48 insertions(+), 73 deletions(-) diff --git a/bids2openminds/main.py b/bids2openminds/main.py index ce79777..45dff61 100644 --- a/bids2openminds/main.py +++ b/bids2openminds/main.py @@ -339,9 +339,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam # dealing with condition that have no seasion if not sessions: state = omcore.SubjectState( - lookup_label=f"{dataset_short_name_}{subject_name}".strip(), - internal_identifier=f"{subject_name}".strip( - ) + lookup_label=f"{dataset_short_name_}{subject_name}_ses-01".strip(), + internal_identifier=None ) collection.add(state) state_cache_dict[""] = state @@ -351,8 +350,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam for session in sessions: if not (table_filter(table_filter(layout_df, session, "session"), subject, "subject").empty): state = omcore.SubjectState( - lookup_label=f"{dataset_short_name_}{subject_name}_session-{session}".strip(), - internal_identifier=f"{subject_name}_session-{session}".strip( + lookup_label=f"{dataset_short_name_}{subject_name}_ses-{session}".strip(), + internal_identifier=f"{subject_name}_ses-{session}".strip( ) ) collection.add(state) @@ -385,9 +384,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam state = omcore.SubjectState( age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), - internal_identifier=f"{subject_name}".strip( - ), - lookup_label=f"{dataset_short_name_}{subject_name}".strip() + internal_identifier=None, + lookup_label=f"{dataset_short_name_}{subject_name}_ses-01".strip() ) collection.add(state) state_cache_dict[""] = state @@ -398,8 +396,8 @@ def create_subjects(subject_id, layout_df, layout, collection, dataset_short_nam state = omcore.SubjectState( age=create_openminds_age(data_subject), handedness=handedness_openminds(data_subject), - internal_identifier=f"{subject_name}_session-{session}".strip(), - lookup_label=f"{dataset_short_name_}{subject_name}_session-{session}".strip() + internal_identifier=f"{subject_name}_ses-{session}".strip(), + lookup_label=f"{dataset_short_name_}{subject_name}_ses-{session}".strip() ) collection.add(state) state_cache_dict[f"{session}"] = state diff --git a/test/bids_examples_ds005.jsonld b/test/bids_examples_ds005.jsonld index 2f70fd5..7095924 100644 --- a/test/bids_examples_ds005.jsonld +++ b/test/bids_examples_ds005.jsonld @@ -13,8 +13,7 @@ }, "value": 28 }, - "internalIdentifier": "sub-01_state-01", - "lookupLabel": "MGT_sub-01_state-01" + "lookupLabel": "sub-01_ses-01" }, { "@id": "https://openminds.ebrains.eu/instances/unitOfMeasurement/year", @@ -28,7 +27,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-01", - "lookupLabel": "MGT_sub-01", + "lookupLabel": "sub-01", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -71,8 +70,7 @@ }, "value": 21 }, - "internalIdentifier": "sub-02_state-01", - "lookupLabel": "MGT_sub-02_state-01" + "lookupLabel": "sub-02_ses-01" }, { "@id": "_:000006", @@ -81,7 +79,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-02", - "lookupLabel": "MGT_sub-02", + "lookupLabel": "sub-02", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -110,8 +108,7 @@ }, "value": 27 }, - "internalIdentifier": "sub-03_state-01", - "lookupLabel": "MGT_sub-03_state-01" + "lookupLabel": "sub-03_ses-01" }, { "@id": "_:000009", @@ -120,7 +117,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-03", - "lookupLabel": "MGT_sub-03", + "lookupLabel": "sub-03", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -140,8 +137,7 @@ }, "value": 25 }, - "internalIdentifier": "sub-04_state-01", - "lookupLabel": "MGT_sub-04_state-01" + "lookupLabel": "sub-04_ses-01" }, { "@id": "_:000011", @@ -150,7 +146,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-04", - "lookupLabel": "MGT_sub-04", + "lookupLabel": "sub-04", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -170,8 +166,7 @@ }, "value": 20 }, - "internalIdentifier": "sub-05_state-01", - "lookupLabel": "MGT_sub-05_state-01" + "lookupLabel": "sub-05_ses-01" }, { "@id": "_:000013", @@ -180,7 +175,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-05", - "lookupLabel": "MGT_sub-05", + "lookupLabel": "sub-05", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -200,8 +195,7 @@ }, "value": 20 }, - "internalIdentifier": "sub-06_state-01", - "lookupLabel": "MGT_sub-06_state-01" + "lookupLabel": "sub-06_ses-01" }, { "@id": "_:000015", @@ -210,7 +204,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-06", - "lookupLabel": "MGT_sub-06", + "lookupLabel": "sub-06", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -230,8 +224,7 @@ }, "value": 24 }, - "internalIdentifier": "sub-07_state-01", - "lookupLabel": "MGT_sub-07_state-01" + "lookupLabel": "sub-07_ses-01" }, { "@id": "_:000017", @@ -240,7 +233,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-07", - "lookupLabel": "MGT_sub-07", + "lookupLabel": "sub-07", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -260,8 +253,7 @@ }, "value": 25 }, - "internalIdentifier": "sub-08_state-01", - "lookupLabel": "MGT_sub-08_state-01" + "lookupLabel": "sub-08_ses-01" }, { "@id": "_:000019", @@ -270,7 +262,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-08", - "lookupLabel": "MGT_sub-08", + "lookupLabel": "sub-08", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -290,8 +282,7 @@ }, "value": 19 }, - "internalIdentifier": "sub-09_state-01", - "lookupLabel": "MGT_sub-09_state-01" + "lookupLabel": "sub-09_ses-01" }, { "@id": "_:000021", @@ -300,7 +291,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-09", - "lookupLabel": "MGT_sub-09", + "lookupLabel": "sub-09", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -320,8 +311,7 @@ }, "value": 20 }, - "internalIdentifier": "sub-10_state-01", - "lookupLabel": "MGT_sub-10_state-01" + "lookupLabel": "sub-10_ses-01" }, { "@id": "_:000023", @@ -330,7 +320,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-10", - "lookupLabel": "MGT_sub-10", + "lookupLabel": "sub-10", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -350,8 +340,7 @@ }, "value": 20 }, - "internalIdentifier": "sub-11_state-01", - "lookupLabel": "MGT_sub-11_state-01" + "lookupLabel": "sub-11_ses-01" }, { "@id": "_:000025", @@ -360,7 +349,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-11", - "lookupLabel": "MGT_sub-11", + "lookupLabel": "sub-11", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -380,8 +369,7 @@ }, "value": 21 }, - "internalIdentifier": "sub-12_state-01", - "lookupLabel": "MGT_sub-12_state-01" + "lookupLabel": "sub-12_ses-01" }, { "@id": "_:000027", @@ -390,7 +378,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-12", - "lookupLabel": "MGT_sub-12", + "lookupLabel": "sub-12", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -410,8 +398,7 @@ }, "value": 22 }, - "internalIdentifier": "sub-13_state-01", - "lookupLabel": "MGT_sub-13_state-01" + "lookupLabel": "sub-13_ses-01" }, { "@id": "_:000029", @@ -420,7 +407,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-13", - "lookupLabel": "MGT_sub-13", + "lookupLabel": "sub-13", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -440,8 +427,7 @@ }, "value": 19 }, - "internalIdentifier": "sub-14_state-01", - "lookupLabel": "MGT_sub-14_state-01" + "lookupLabel": "sub-14_ses-01" }, { "@id": "_:000031", @@ -450,7 +436,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-14", - "lookupLabel": "MGT_sub-14", + "lookupLabel": "sub-14", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -470,8 +456,7 @@ }, "value": 20 }, - "internalIdentifier": "sub-15_state-01", - "lookupLabel": "MGT_sub-15_state-01" + "lookupLabel": "sub-15_ses-01" }, { "@id": "_:000033", @@ -480,7 +465,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/female" }, "internalIdentifier": "sub-15", - "lookupLabel": "MGT_sub-15", + "lookupLabel": "sub-15", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -500,8 +485,7 @@ }, "value": 22 }, - "internalIdentifier": "sub-16_state-01", - "lookupLabel": "MGT_sub-16_state-01" + "lookupLabel": "sub-16_ses-01" }, { "@id": "_:000035", @@ -510,7 +494,7 @@ "@id": "https://openminds.ebrains.eu/instances/biologicalSex/male" }, "internalIdentifier": "sub-16", - "lookupLabel": "MGT_sub-16", + "lookupLabel": "sub-16", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -5530,7 +5514,6 @@ "repository": { "@id": "_:000039" }, - "shortName": "MGT", "studiedSpecimen": [ { "@id": "_:000002" @@ -5647,8 +5630,7 @@ { "@id": "_:000229" } - ], - "shortName": "MGT" + ] } ] } diff --git a/test/bids_examples_eeg_rest_fmri.jsonld b/test/bids_examples_eeg_rest_fmri.jsonld index 10ed38d..c7166c3 100644 --- a/test/bids_examples_eeg_rest_fmri.jsonld +++ b/test/bids_examples_eeg_rest_fmri.jsonld @@ -6,14 +6,13 @@ { "@id": "_:000000", "@type": "https://openminds.ebrains.eu/core/SubjectState", - "internalIdentifier": "sub-32_state-01", - "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-32_state-01" + "lookupLabel": "sub-32_ses-01" }, { "@id": "_:000001", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-32", - "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-32", + "lookupLabel": "sub-32", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -40,14 +39,13 @@ { "@id": "_:000003", "@type": "https://openminds.ebrains.eu/core/SubjectState", - "internalIdentifier": "sub-35_state-01", - "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-35_state-01" + "lookupLabel": "sub-35_ses-01" }, { "@id": "_:000004", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-35", - "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-35", + "lookupLabel": "sub-35", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -60,14 +58,13 @@ { "@id": "_:000005", "@type": "https://openminds.ebrains.eu/core/SubjectState", - "internalIdentifier": "sub-36_state-01", - "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-36_state-01" + "lookupLabel": "sub-36_ses-01" }, { "@id": "_:000006", "@type": "https://openminds.ebrains.eu/core/Subject", "internalIdentifier": "sub-36", - "lookupLabel": "EEG-fMRI-&-NODDI-@R_sub-36", + "lookupLabel": "sub-36", "species": { "@id": "https://openminds.ebrains.eu/instances/species/homoSapiens" }, @@ -1838,7 +1835,6 @@ "repository": { "@id": "_:000010" }, - "shortName": "EEG-fMRI-&-NODDI-@R", "studiedSpecimen": [ { "@id": "_:000001" @@ -1937,8 +1933,7 @@ { "@id": "_:000085" } - ], - "shortName": "EEG, fMRI and NODDI at rest'" + ] } ] }