Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have branched the forked repo and provided the following script. It currently delivers all but derivatives for the test ds004733 case.
Summary of the Script
The BIDStoNDAConfigGenerator is a Python script designed to automate the generation of JSON and YAML configuration files required for submitting neuroimaging data (specifically BIDS datasets) to the National Institute of Mental Health (NIMH) Data Archive (NDA). This script simplifies the process of converting BIDS-compliant datasets into NDA-compliant formats, focusing on PET and other neuroimaging modalities.
How the Script Works
o The script initializes by accepting the path to a BIDS dataset as a command-line argument.
o It uses the BIDSLayout from the pybids library to organize and interact with the dataset.
o The script defines mappings for scan types (e.g., anat, pet) and image modalities (e.g., MRI, PET).
o The script uses a regular expression pattern to extract components (such as X, Y, Z) from the filenames within the BIDS dataset. These components are crucial for generating the correct NDA configuration files.
o The prepare_json_contents method generates JSON files for each relevant scan in the dataset.
o These JSON files contain placeholders ({SUBJECT}, {SESSION}) that will be filled in when the data is uploaded to the NDA.
o The fetch_scan_type method identifies the appropriate scan type based on the Y and Z components extracted from the filename.
o The prepare_yaml_contents method generates YAML files, which include metadata such as scan type, image modality, and file format.
o The fetch_Z_value method extracts unique Z values from the dataset’s files, which are then used to generate the correct filenames for the JSON and YAML files.
o The run method iterates through the dataset, generating and saving JSON and YAML files in specified directories.
o The output directories are automatically created if they do not already exist.
Instructions for Use
o Ensure you have the necessary dependencies installed, such as pybids.
o Place yourself in the directory where the script is located and execute the following command:
bash
Copy code
python3 prepare_files.py /path/to/bids/dataset
o Replace /path/to/bids/dataset with the actual path to your BIDS dataset.
o The script generates JSON and YAML files in directories named prepared_jsons and prepared_yamls, respectively.
o These directories are created in the parent directory of the BIDS dataset.
Next Steps
This script forms the basis of a tool aimed at automating the process of submitting datasets from OpenNeuro and OpenNeuroPET into the NIMH Data Archive. Future enhancements could include:
• Customizable Output Directories: Allowing users to specify output directories for the generated files via command-line arguments.
• Support for Additional Data Types: Extending support to other neuroimaging modalities beyond PET and MRI.
• Integration with NDA Submission Tools: Automating the actual submission process to the NDA, including manifest file creation.
Additional Notes
This tool is part of a broader project aimed at streamlining the data submission process for neuroimaging studies, particularly for datasets in BIDS format. By automating the creation of necessary configuration files, this tool reduces the manual effort required and ensures compliance with NDA requirements.