Loading bids_tools/cli/run.py +2 −2 Original line number Diff line number Diff line Loading @@ -81,9 +81,9 @@ def main(): if command == "sub.delete.file": return phdl.sub_delete_file(input_data=input_data) if command == "project.create": create_project(input_data=input_data) create_project(input_data=input_data, output_file=output_file) if command == "project.sub.import": import_subject(input_data=input_data) import_subject(input_data=input_data, output_file=output_file) if command == "project.doc.import": import_document(input_data=input_data) Loading bids_tools/handlers/project.py +21 −2 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ from pathlib import Path from sre_constants import SUCCESS from bids_tools.bids.dataset import create_empty_bids_dataset from bids_tools.bids.dataset import get_bidsdataset_content PROJECT_FOLDERS = [ Loading Loading @@ -52,7 +53,7 @@ def initialize_project_structure( f.writelines([f"# {project_title}\n\n", f"{project_description}"]) def create_project(input_data: str): def create_project(input_data: str, output_file: str): """Create a new Collaborative Project on the HIP initialized with directory/file structure. Parameters Loading @@ -76,6 +77,9 @@ def create_project(input_data: str): "DatasetDOI": "10.18112/openneuro.ds000000.v1.0.0" } } output_file : str Path to output file that will contain the JSON summary of the BIDS dataset of the project. """ # Load input data with open(input_data, "r") as f: Loading @@ -92,10 +96,16 @@ def create_project(input_data: str): bids_dir=(project_dir / "inputs" / "bids-dataset").absolute(), dataset_desc=input_data["datasetDescription"], ) # Create output file with summary of BIDS dataset dataset_content = get_bidsdataset_content( bids_dir=str((project_dir / "inputs" / "bids-dataset").absolute()), ) with open(output_file, "w") as f: json.dump(dataset_content, f, indent=4) print(SUCCESS) def import_subject(input_data: str): def import_subject(input_data: str, output_file: str): """Import a new subject from a BIDS dataset of the HIP Center space to the BIDS dataset of the HIP Collaborative Project. Parameters Loading @@ -109,6 +119,9 @@ def import_subject(input_data: str): "participantId": "sub-01", "targetDatasetPath": "/path/to/target/bids/dataset/directory", } output_file : str Path to output file that will contain the JSON summary of the BIDS dataset of the project. """ # Load input data with open(input_data, "r") as f: Loading Loading @@ -138,6 +151,12 @@ def import_subject(input_data: str): Path(input_data["targetDatasetPath"]) / "participants.tsv" ).absolute(), ) # Create output file with summary of BIDS dataset dataset_content = get_bidsdataset_content( bids_dir=str((Path(input_data["targetDatasetPath"])).absolute()), ) with open(output_file, "w") as f: json.dump(dataset_content, f, indent=4) print(SUCCESS) Loading Loading
bids_tools/cli/run.py +2 −2 Original line number Diff line number Diff line Loading @@ -81,9 +81,9 @@ def main(): if command == "sub.delete.file": return phdl.sub_delete_file(input_data=input_data) if command == "project.create": create_project(input_data=input_data) create_project(input_data=input_data, output_file=output_file) if command == "project.sub.import": import_subject(input_data=input_data) import_subject(input_data=input_data, output_file=output_file) if command == "project.doc.import": import_document(input_data=input_data) Loading
bids_tools/handlers/project.py +21 −2 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ from pathlib import Path from sre_constants import SUCCESS from bids_tools.bids.dataset import create_empty_bids_dataset from bids_tools.bids.dataset import get_bidsdataset_content PROJECT_FOLDERS = [ Loading Loading @@ -52,7 +53,7 @@ def initialize_project_structure( f.writelines([f"# {project_title}\n\n", f"{project_description}"]) def create_project(input_data: str): def create_project(input_data: str, output_file: str): """Create a new Collaborative Project on the HIP initialized with directory/file structure. Parameters Loading @@ -76,6 +77,9 @@ def create_project(input_data: str): "DatasetDOI": "10.18112/openneuro.ds000000.v1.0.0" } } output_file : str Path to output file that will contain the JSON summary of the BIDS dataset of the project. """ # Load input data with open(input_data, "r") as f: Loading @@ -92,10 +96,16 @@ def create_project(input_data: str): bids_dir=(project_dir / "inputs" / "bids-dataset").absolute(), dataset_desc=input_data["datasetDescription"], ) # Create output file with summary of BIDS dataset dataset_content = get_bidsdataset_content( bids_dir=str((project_dir / "inputs" / "bids-dataset").absolute()), ) with open(output_file, "w") as f: json.dump(dataset_content, f, indent=4) print(SUCCESS) def import_subject(input_data: str): def import_subject(input_data: str, output_file: str): """Import a new subject from a BIDS dataset of the HIP Center space to the BIDS dataset of the HIP Collaborative Project. Parameters Loading @@ -109,6 +119,9 @@ def import_subject(input_data: str): "participantId": "sub-01", "targetDatasetPath": "/path/to/target/bids/dataset/directory", } output_file : str Path to output file that will contain the JSON summary of the BIDS dataset of the project. """ # Load input data with open(input_data, "r") as f: Loading Loading @@ -138,6 +151,12 @@ def import_subject(input_data: str): Path(input_data["targetDatasetPath"]) / "participants.tsv" ).absolute(), ) # Create output file with summary of BIDS dataset dataset_content = get_bidsdataset_content( bids_dir=str((Path(input_data["targetDatasetPath"])).absolute()), ) with open(output_file, "w") as f: json.dump(dataset_content, f, indent=4) print(SUCCESS) Loading