This tool is designed to transform RADx-rad CSV metadata files into the JSON-LD format suitable for upload to Data Hub.
You need to specify:
-
Input Metadata CSV Path [Required] (c): Specify the path to your input csv file containing the metadata you need to transform. The input path can be either a file path or a directory path. If it is a directory path, the tool will transform all CSV files within that directory. Therefore, please ensure that any non-relevant CSV files are removed beforehand.
-
Output Transformed Metadata Directory [Required] (o): Specify the directory path where you want the transformed metadata files to be saved.
-
RADx Metadata Specification Path [Optional] (t): Provide the path to the RADx Metadata Specification JSON file. If not provided, the default version of the RADx Metadata Specification will be used.
-
CSV to Template Mappings Path [Optional] (m): Indicate the path to the spreadsheet that contains the mapping instructions. These instructions dictate how the input metadata fields correspond to the RADx Metadata Specification. If not provided, the default mappings will be used.
The spreadsheet is organized into two main columns:
RADx-rad Field Label
andRADx Metadata Specification Path
. For instance, thenih_project_id
field is matched with theStudy Identifier
within theData File Parent Studies
element. Hence, the entry for the RADx Metadata Specification Path column should be/Data File Parent Studies/Study Identifier
.
Here is an example mappings spreadsheet.
The repository includes a tool for metadata transformation. The tool is packaged in a zip file rrmc.zip, which contains the shell script (rrmc) and two essential files for the transformation process: the RADx Metadata Specification and a spreadsheet that mapping the fields in radx-rad CSV template to CEDAR template. Download rrmc.zip and then unzip. Move the extracted rrmc tool to into a location on your executable path.
- Navigate to the directory where the
rrmc
shell script is located.
cd /user/local/bin/
- Make the script executable:
chmod +x rrmc
Type ./rrmc -h
to show options.
e.g., for transforming all spreadsheets stored in a folder named radx-rad-spreadsheets, and saving all transformed metadata in a folder named radx-rad-output, use the command:
./rrmc \
-c ../radx-rad-metadata \
-t ../RADxTemplate.json \
-m ../radx-rad-mapping.xlsx \
-o ../radx-rad-output
For transforming a single spreadsheet RADxRadExampleSheet.xlsx to the JSON-LD format:
./rrmc \
-c ../RADxRadExampleSheet.csv \
-t ../RADxTemplate.json \
-m ../radx-rad-mapping.xlsx \
-o ../radx-rad-output"
You can use the tool for metadata transformation directly by executing the JAR file. The JAR file can be downloaded from the following link:
Download radx-rad-metadata-compiler.jar
After downloading the JAR file, you can execute it via the command line using the following syntax:
java -jar radx-rad-metadata-compiler.jar -c=<Input_Metadata_CSV_Path> -o=<Output_Directory> [-t=<Metadata_Specification_Path>] [-m=<CSV_to_Template_Mappings_Path>]
To build the code in this repository you must have the following items installed:
Get a copy of the latest code:
git clone https://github.com/bmir-radx/radx-rad-metadata-compiler.git
Change into the radx-rad-metadata-compiler
directory:
cd radx-rad-metadata-compiler
Then, build it with Maven:
mvn clean install
First, navigate to the Application Directory
cd radx-rad-metadata-compiler
To transform your spreadsheet to JSON-LD, use the following Maven command.
mvn exec:java \
-Dexec.args="-s <input_metadata_spreadsheet_path> \
-t <RADx_metadata_specification_path> \
-m <mappings_spreadsheet_path> \
-o <output_transformed_metadata_directory>"
e.g., for transforming all spreadsheets stored in a folder named radx-rad-spreadsheets, and saving all transformed metadata in a folder named radx-rad-output, use the command:
mvn exec:java \
-Dexec.args="-s ../radx-rad-spreadsheets \
-t ../RADxTemplate.json \
-m ../radx-rad-mapping.xlsx \
-o ../radx-rad-output"
For transforming a single spreadsheet RADxRadExampleSheet.xlsx to the JSON-LD format:
mvn exec:java \
-Dexec.args="-s ../RADxRadExampleSheet.xlsx \
-t ../RADxTemplate.json \
-m ../radx-rad-mapping.xlsx \
-o ../radx-rad-output"