Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: bids-standard/bids2nda
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: brown-bnc/bids2nda
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 9 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 1, 2024

  1. update to 11/15/2023 image03

    Also automatically fill NDA experiment ID field if file provided
    elizabethlorenc committed Apr 1, 2024
    Copy the full SHA
    029ad5b View commit details
  2. Update setup.py

    Refer to bnc git repo for install
    elizabethlorenc committed Apr 1, 2024
    Copy the full SHA
    2aa6b90 View commit details
  3. Copy the full SHA
    9b308f4 View commit details
  4. Copy the full SHA
    8000a6b View commit details
  5. Copy the full SHA
    5eb9eba View commit details

Commits on Apr 3, 2024

  1. Copy the full SHA
    5a44422 View commit details

Commits on Apr 4, 2024

  1. Update README.md

    elizabethlorenc authored Apr 4, 2024
    Copy the full SHA
    7256313 View commit details

Commits on Oct 2, 2024

  1. feat: allow passing a lookup csv to populate or overwrite values

    In the case that values extracted from the BIDS data are missing or incorrect, you can pass a --lookup_csv file and a list of --lookup_fields . For every field listed, the value for that participant is grabbed from the lookup csv and included in the image03.csv instead of the value deduced from the BIDS data.
    elizabethlorenc committed Oct 2, 2024
    Copy the full SHA
    ea6313b View commit details
  2. Merge pull request #1 from brown-bnc/feat-lookup-csv

    feat: allow passing a lookup csv to populate or overwrite values
    elizabethlorenc authored Oct 2, 2024
    Copy the full SHA
    d18f805 View commit details
Showing with 296 additions and 262 deletions.
  1. +43 −16 README.md
  2. +240 −101 bids2nda/main.py
  3. +10 −0 examples/image03.csv
  4. +0 −142 examples/image03.txt
  5. +3 −3 setup.py
59 changes: 43 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,65 @@
# BIDS2NDA
Extract NIMH Data Archive compatible metadata from Brain Imaging Data Structure (BIDS) compatible datasets
Extract NIMH Data Archive compatible metadata from Brain Imaging Data Structure (BIDS) compatible datasets. Adapted and extended from https://github.com/bids-standard/bids2nda to also:
* zip and include stimulus files referenced in events.tsv files
* populate experiment ID column using a BIDS taskname to NDA experiment ID mapping text file

## Installation


pip install https://github.com/INCF/BIDS2NDA/archive/master.zip
pip install https://github.com/brown-bnc/bids2nda/archive/master.zip


## Usage

usage: bids2nda [-h] [-v] BIDS_DIRECTORY GUID_MAPPING OUTPUT_DIRECTORY

usage: bids2nda [-h] [-e EXPID_MAPPING] [--lookup_csv LOOKUP_CSV] [--lookup_fields LOOKUP_FIELDS [LOOKUP_FIELDS ...]] BIDS_DIRECTORY GUID_MAPPING OUTPUT_DIRECTORY
BIDS to NDA converter.

positional arguments:
BIDS_DIRECTORY Location of the root of your BIDS compatible directory.
GUID_MAPPING Path to a text file with participant_id to GUID mapping.
You will need to use the GUID Tool
(https://ndar.nih.gov/contribute.html) to generate GUIDs
for your participants.
OUTPUT_DIRECTORY Directory where NDA files will be stored.
BIDS_DIRECTORY Location of the root of your BIDS compatible directory
GUID_MAPPING Path to a text file with participant_id to GUID mapping. You will need to use the GUID Tool (https://ndar.nih.gov/contribute.html) to generate GUIDs for
your participants.
OUTPUT_DIRECTORY Directory where NDA files will be stored

optional arguments:
-h, --help Show this help message and exit.
options:
-h, --help show this help message and exit
-e EXPID_MAPPING, --expid_mapping EXPID_MAPPING
Path to a text file with experiment name to NDA experiment ID mapping.
--lookup_csv LOOKUP_CSV
Path to a csv with data we need for the image03.csv, i.e. ndar_subject01.csv
--lookup_fields LOOKUP_FIELDS [LOOKUP_FIELDS ...]
List of column names to grab from the lookup csv. i.e. --lookup_fields interview_age sex


## GUID_MAPPING file format
The is the file format produced by the GUID Tool, one line per subject in the format:
This is the file format produced by the GUID Tool, one line per subject in the format:

`<participant_id> - <GUID>`

## EXPID_MAPPING file format
This is a text file with one line per task present in the dataset in the format:

`<BIDS task name> - <NDA experiment ID number>`

The BIDS task name should match the value associated with the "task-" key in the .nii filename.

The NDA experiment ID number(s) are received from NDA after setting the study up through the NDA website [here](https://ndar.nih.gov/user/dashboard/collections.html).

## LOOKUP_CSV
This can be any csv file, including something like the ndar_subject01.csv, with data
you want to use to populate the image03.csv file.

This is useful in cases where the BIDS-derived data is missing or incorrect, such as
the calculation of interview_age in months, which is only approximated based on age in years
from the BIDS data.

## LOOKUP_FIELDS
If you pass a lookup csv, you need to specify which columns you want to use to populate
the image03.csv. The column names must match, so if you're trying to populate the interview_age
column in the image03.csv, your lookup csv must have a column with the same name.

You can pass more than one value, separated by spaces, like:
--lookup_fields interview_age gender

## Example outputs
See [/examples](/examples)

## Notes:
Column `'experiment_id'` must be manually filled in for now.
This is based on experiment IDs received from NDA after setting the study up through the NDA website [here](https://ndar.nih.gov/user/dashboard/collections.html).
341 changes: 240 additions & 101 deletions bids2nda/main.py

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions examples/image03.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"image","3"
"subjectkey","src_subject_id","interview_date","interview_age","gender","image_file","experiment_id","taskname","abbrev_taskname","image_description","scan_type","scan_object","image_file_format","image_modality","scanner_manufacturer_pd","scanner_type_pd","scanner_software_versions_pd","magnetic_field_strength","mri_echo_time_pd","flip_angle","receive_coil","image_orientation","transformation_performed","transformation_type","image_num_dimensions","image_extent1","image_extent2","image_extent3","image_extent4","extent4_type","acquisition_matrix","image_resolution1","image_resolution2","image_resolution3","image_slice_thickness","photomet_interpret","image_resolution4","image_unit1","image_unit2","image_unit3","mri_repetition_time_pd","slice_timing","image_unit4","mri_field_of_view_pd","patient_position","visit","data_file2","data_file2_type","bvecfile","bvalfile","bvek_bval_files","deviceserialnumber","procdate","visnum","manifest","emission_wavelingth","objective_magnification","objective_na","immersion","exposure_time","camera_sn","block_number","level","cut_thickness","stain","stain_details","pipeline_stage","deconvolved","decon_software","decon_method","psf_type","psf_file","decon_snr","decon_iterations","micro_temmplate_name","in_stack","decon_template_name","stack","slices","slice_number","slice_thickness","type_of_microscopy","comments_misc","image_thumbnail_file","transmit_coil","image_history","qc_outcome","qc_description","qc_fail_quest_reason","decay_correction","frame_end_times","frame_end_unit","frame_start_times","frame_start_unit","pet_isotope","pet_tracer","time_diff_inject_to_image","time_diff_units","pulse_seq","slice_acquisition","software_preproc","study","week","experiment_description","year_mta","timepoint_label","aqi","fd_mean","dvars_std","tsnr","fetal_age","fetal_age_type","accession_number","ageyears","iti_onset","stim1","stim2","stim1_side","stim1_magnitude","stim2_magnitude","choice_side","computer_choice","stim1_outcome","session_fmri","choice_fmri","outcome_fmri","rt_fmri","task__version","block_sv","trial_num","options_onset","cue_onset","interval_onset","monitor_onset","session_det","gbc","vtca","vtcan","eventname","vendor","image_extent5","extent5_type","image_unit5","image_resolution5","excitation_wavelength"
"LKJSFIJLW","002","06/25/2021","636","M","bids/sub-002/ses-01/anat/sub-002_ses-01_acq-memprageRMS_T1w.nii.gz","","","","T1w","MR structural (T1)","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.00169","7","HeadNeck_64","Sagittal","Yes","BIDS2NDA","3","176","256","256","","","176 x 256","1.0","1.0","1.0","1.0","MONOCHROME2","","Millimeters","Millimeters","Millimeters","2.53","","","1 x 1 Millimeters","head first-supine","01","nda_output/sub-002_ses-01_acq-memprageRMS_T1w.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LKJSFIJLW","002","06/25/2021","636","M","bids/sub-002/ses-01/func/sub-002_ses-01_task-checks_run-01_bold.nii.gz","2590","checks","","bold checks","fMRI","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.03","62","HeadNeck_64","Axial","Yes","BIDS2NDA","4","96","96","60","72","time","96 x 96","2.0","2.0","2.0","2.0","MONOCHROME2","2.0","Millimeters","Millimeters","Millimeters","2.0","[1.4525, 0, 0.99, 0.0675, 1.0575, 0.1325, 1.1225, 0.2, 1.19, 0.265, 1.255, 0.33, 1.32, 0.3975, 1.3875, 0.53, 1.5175, 0.595, 1.585, 0.66, 1.65, 0.7275, 1.7175, 0.7925, 1.7825, 0.86, 1.8475, 0.925, 1.915, 0.4625, 1.4525, 0, 0.99, 0.0675, 1.0575, 0.1325, 1.1225, 0.2, 1.19, 0.265, 1.255, 0.33, 1.32, 0.3975, 1.3875, 0.53, 1.5175, 0.595, 1.585, 0.66, 1.65, 0.7275, 1.7175, 0.7925, 1.7825, 0.86, 1.8475, 0.925, 1.915, 0.4625]","Seconds","2 x 2 Millimeters","head first-supine","01","nda_output/sub-002_ses-01_task-checks_run-01_bold.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LKJSFIJLW","002","06/25/2021","636","M","bids/sub-002/ses-01/func/sub-002_ses-01_task-checks_run-02_bold.nii.gz","2590","checks","","bold checks","fMRI","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.03","62","HeadNeck_64","Axial","Yes","BIDS2NDA","4","96","96","60","72","time","96 x 96","2.0","2.0","2.0","2.0","MONOCHROME2","2.0","Millimeters","Millimeters","Millimeters","2.0","[1.45, 0, 0.9875, 0.065, 1.055, 0.13, 1.12, 0.1975, 1.1875, 0.2625, 1.2525, 0.3275, 1.3175, 0.395, 1.385, 0.5275, 1.5175, 0.5925, 1.5825, 0.6575, 1.6475, 0.725, 1.715, 0.79, 1.78, 0.8575, 1.8475, 0.9225, 1.9125, 0.46, 1.45, 0, 0.9875, 0.065, 1.055, 0.13, 1.12, 0.1975, 1.1875, 0.2625, 1.2525, 0.3275, 1.3175, 0.395, 1.385, 0.5275, 1.5175, 0.5925, 1.5825, 0.6575, 1.6475, 0.725, 1.715, 0.79, 1.78, 0.8575, 1.8475, 0.9225, 1.9125, 0.46]","Seconds","2 x 2 Millimeters","head first-supine","01","nda_output/sub-002_ses-01_task-checks_run-02_bold.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LKJSFIJLW","002","06/25/2021","636","M","bids/sub-002/ses-01/func/sub-002_ses-01_task-resting_bold.nii.gz","2590","resting","","bold resting","fMRI","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.03","62","HeadNeck_64","Axial","Yes","BIDS2NDA","4","96","96","60","475","time","96 x 96","2.0","2.0","2.0","2.0","MONOCHROME2","1.0","Millimeters","Millimeters","Millimeters","1.0","[0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.785, 0.3275, 0.85, 0.3925, 0.915, 0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.785, 0.3275, 0.85, 0.3925, 0.915, 0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.785, 0.3275, 0.85, 0.3925, 0.915, 0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.785, 0.3275, 0.85, 0.3925, 0.915]","Seconds","2 x 2 Millimeters","head first-supine","01","nda_output/sub-002_ses-01_task-resting_bold.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LJFOIJWEL","001","05/28/2021","684","M","bids/sub-001/ses-01/anat/sub-001_ses-01_acq-memprageRMS_T1w.nii.gz","","","","T1w","MR structural (T1)","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.00169","7","HeadNeck_64","Sagittal","Yes","BIDS2NDA","3","176","256","256","","","176 x 256","1.0","1.0","1.0","1.0","MONOCHROME2","","Millimeters","Millimeters","Millimeters","2.53","","","1 x 1 Millimeters","head first-supine","01","nda_output/sub-001_ses-01_acq-memprageRMS_T1w.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LJFOIJWEL","001","05/28/2021","684","M","bids/sub-001/ses-01/func/sub-001_ses-01_task-resting_bold.nii.gz","2590","resting","","bold resting","fMRI","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.03","62","HeadNeck_64","Axial","Yes","BIDS2NDA","4","96","96","60","475","time","96 x 96","2.0","2.0","1.9999998807907104","2.0","MONOCHROME2","1.0","Millimeters","Millimeters","Millimeters","1.0","[0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.7825, 0.325, 0.85, 0.3925, 0.915, 0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.7825, 0.325, 0.85, 0.3925, 0.915, 0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.7825, 0.325, 0.85, 0.3925, 0.915, 0.4575, 0, 0.5225, 0.065, 0.5875, 0.13, 0.6525, 0.195, 0.7175, 0.26, 0.7825, 0.325, 0.85, 0.3925, 0.915]","Seconds","2 x 2 Millimeters","head first-supine","01","nda_output/sub-001_ses-01_task-resting_bold.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LJFOIJWEL","001","05/28/2021","684","M","bids/sub-001/ses-01/func/sub-001_ses-01_task-checks_run-01_bold.nii.gz","2590","checks","","bold checks","fMRI","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.03","62","HeadNeck_64","Axial","Yes","BIDS2NDA","4","96","96","60","72","time","96 x 96","2.0","2.0","1.9999998807907104","2.0","MONOCHROME2","2.0","Millimeters","Millimeters","Millimeters","2.0","[1.4525, 0, 0.99, 0.065, 1.055, 0.1325, 1.1225, 0.1975, 1.1875, 0.265, 1.255, 0.33, 1.32, 0.395, 1.385, 0.5275, 1.5175, 0.595, 1.585, 0.66, 1.65, 0.725, 1.715, 0.7925, 1.7825, 0.8575, 1.8475, 0.925, 1.915, 0.4625, 1.4525, 0, 0.99, 0.065, 1.055, 0.1325, 1.1225, 0.1975, 1.1875, 0.265, 1.255, 0.33, 1.32, 0.395, 1.385, 0.5275, 1.5175, 0.595, 1.585, 0.66, 1.65, 0.725, 1.715, 0.7925, 1.7825, 0.8575, 1.8475, 0.925, 1.915, 0.4625]","Seconds","2 x 2 Millimeters","head first-supine","01","nda_output/sub-001_ses-01_task-checks_run-01_bold.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
"LJFOIJWEL","001","05/28/2021","684","M","bids/sub-001/ses-01/func/sub-001_ses-01_task-checks_run-02_bold.nii.gz","2590","checks","","bold checks","fMRI","Live","NIFTI","MRI","Siemens","Prisma_fit","syngo_MR_E11","3","0.03","62","HeadNeck_64","Axial","Yes","BIDS2NDA","4","96","96","60","72","time","96 x 96","2.0","2.0","1.9999998807907104","2.0","MONOCHROME2","2.0","Millimeters","Millimeters","Millimeters","2.0","[1.45, 0, 0.99, 0.065, 1.055, 0.1325, 1.12, 0.1975, 1.1875, 0.2625, 1.2525, 0.33, 1.32, 0.395, 1.385, 0.5275, 1.5175, 0.5925, 1.5825, 0.66, 1.65, 0.725, 1.715, 0.79, 1.78, 0.8575, 1.8475, 0.9225, 1.9125, 0.46, 1.45, 0, 0.99, 0.065, 1.055, 0.1325, 1.12, 0.1975, 1.1875, 0.2625, 1.2525, 0.33, 1.32, 0.395, 1.385, 0.5275, 1.5175, 0.5925, 1.5825, 0.66, 1.65, 0.725, 1.715, 0.79, 1.78, 0.8575, 1.8475, 0.9225, 1.9125, 0.46]","Seconds","2 x 2 Millimeters","head first-supine","01","nda_output/sub-001_ses-01_task-checks_run-02_bold.metadata.zip","ZIP file with additional metadata from Brain Imaging Data Structure (http://bids.neuroimaging.io)","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
142 changes: 0 additions & 142 deletions examples/image03.txt

This file was deleted.

6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# http://packaging.python.org/en/latest/tutorial.html#version
version='0.2.0',
version='0.2.1',

description="Command line tool generating NDA compatible description from a Brain Imaging Data Structure "
"compatible dataset.",
long_description="Command line tool generating NDA compatible description from a Brain Imaging Data Structure "
"compatible dataset.",
"compatible dataset. An extension of the bids2nda tool from https://github.com/bids-standard/bids2nda",

# The project URL.
url='https://github.com/INCF/BIDS2NDA',
url='https://github.com/brown-bnc/bids2nda',

# Choose your license
license='BSD',