Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: BIDS to JSON-LD #3

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
209 changes: 209 additions & 0 deletions BIDS2JSONLD.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# BIDS dataset to a JSON-LD BIDS dataset"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This document illustrates an example showing how to go from a bids dataset to a JSON-LD BIDS dataset. More specifically, one wants to : \n",
"- add gently context into existing json files : T1w.json, taskxxx.json\n",
"- create an other JSON file with attached JSON-LD context to store metadata only present in the BIDS directory (bids_context.json findable at that location: https://github.com/incf-nidash/bids-ld/pull/1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1st step : we review existing JSON files with the metadata types in BIDS and compare them to the NIDM-Experiment data. \n",
"--> we list the bids attributes, the path to bids terms, the nidm attributes and their links to nidm objects. \n",
"\n",
"2st step : we create a context file only for bids terms labelled 'bids_context.json'.\n",
"--> At this time there is still no URIs for BIDS, so one must create one with the following prefix: \n",
" \"bids\": \"https://bids.neuroimaging.io#\"\n",
" Then to describe bids attributes : \n",
" \"Name\" : \"https://bids.neuroimaging.io#Name\"\n",
" \n",
"3rd step : we add this gently context into existing json files. "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\r\n",
" \"@context\": {\r\n",
" \"@version\": 1.1,\r\n",
" \"records\": {\r\n",
" \"@id\": \"@graph\",\r\n",
" \"@container\": \"@type\"\r\n",
" },\r\n",
" \"bids\": \"https://bids.neuroimaging.io#\",\r\n",
" \"BIDSVersion\": \"https://bids.neuroimaging.io#BIDSVersion\",\r\n",
" \"Name\": \"https://bids.neuroimaging.io#Name\",\r\n",
" \"Acquisition Matrix\": \"https://bids.neuroimaging.io#AcquisitionMatrix\",\r\n",
" \"Coil Combination Method\": \"https://bids.neuroimaging.io#CoilCombinationMethod\",\r\n",
" \"Echo Time\": \"https://bids.neuroimaging.io#EchoTime\",\r\n",
" \"Field of View Dimensions\": \"https://bids.neuroimaging.io#FieldOfViewDimensions\", \r\n",
" \"Field of View Shape\": \"https://bids.neuroimaging.io#FieldOfViewShape\",\r\n",
" \"Flip Angle\": \"https://bids.neuroimaging.io#FlipAngle\",\r\n",
" \"Gradient Set Type\": \"https://bids.neuroimaging.io#GradientSetType\",\r\n",
" \"Inversion Time\": \"https://bids.neuroimaging.io#InversionTime\",\r\n",
" \"MatrixCoilMode\": \"https://bids.neuroimaging.io#MatrixCoilMode\",\r\n",
" \"Negative Contrast\": \"https://bids.neuroimaging.io#NegativeContrast\", \r\n",
" \"Number Of Slices\": \"https://bids.neuroimaging.io#NumberOfSlices\", \r\n",
" \"Number Shots\": \"https://bids.neuroimaging.io#NumberShots\",\r\n",
" \"Parallel Acquisition\": \"https://bids.neuroimaging.io#ParallelAcquisition\",\r\n",
" \"Parallel Acquisition Technique\": \"https://bids.neuroimaging.io#ParallelAcquisitionTechnique\",\r\n",
" \"Parallel Reduction Factor In-plane\": \"https://bids.neuroimaging.io#ParallelReductionFactorIn-plane\",\r\n",
" \"Phase Encoding Direction\": \"https://bids.neuroimaging.io#PhaseEncodingDirection\",\r\n",
" \"Pixel Bandwidth\": \"https://bids.neuroimaging.io#PixelBandwidth\",\r\n",
" \"Plane Orientation Sequence\": \"https://bids.neuroimaging.io#PlaneOrientationSequence\",\r\n",
" \"Receive Coil Type\": \"https://bids.neuroimaging.io#ReceiveCoilType\",\r\n",
" \"Receive Coil Name\": \"https://bids.neuroimaging.io#ReceiveCoilName\",\r\n",
" \"Scan Options\": \"https://bids.neuroimaging.io#ScanOptions\",\r\n",
" \"Scanning Sequence\": \"https://bids.neuroimaging.io#ScanningSequence\",\r\n",
" \"Sequence Name\": \"https://bids.neuroimaging.io#SequenceName\",\r\n",
" \"Sequence Variant\": \"https://bids.neuroimaging.io#SequenceVariant\",\r\n",
" \"Slice Acquisition Order\": \"https://bids.neuroimaging.io#SliceAcquisitionOrder\",\r\n",
" \"Slice Encoding Direction\": \"https://bids.neuroimaging.io#SliceEncodingDirection\",\r\n",
" \"Slice Thickness\": \"https://bids.neuroimaging.io#SliceThickness\",\r\n",
" \"Slice Timing\": \"https://bids.neuroimaging.io#SliceTiming\",\r\n",
" \"Spacing Between Slices\": \"https://bids.neuroimaging.io#SpacingBetweenSlices\",\r\n",
" \"Total Readout Time\": \"https://bids.neuroimaging.io#TotalReadoutTime\",\r\n",
" \"Manufacturer\": \"https://bids.neuroimaging.io#Manufacturer\",\r\n",
" \"Manufacturers Model Name\": \"https://bids.neuroimaging.io#ManufacturersModelName\",\r\n",
" \"Magnetic Field Strength\": \"https://bids.neuroimaging.io#MagneticFieldStrength\",\r\n",
" \"Device Serial Number\": \"https://bids.neuroimaging.io#DeviceSerialNumber\",\r\n",
" \"Software Versions\": \"https://bids.neuroimaging.io#SoftwareVersions\",\r\n",
" \"MR Transmit Coil Sequence\": \"https://bids.neuroimaging.io#MRTransmitCoilSequence\",\r\n",
" \"Partial Fourier\": \"https://bids.neuroimaging.io#PartialFourier\",\r\n",
" \"Partial Fourier Direction\": \"https://bids.neuroimaging.io#PartialFourierDirection\",\r\n",
" \"Effective Echo Spacing\": \"https://bids.neuroimaging.io#EffectiveEchoSpacing\",\r\n",
" \"Receive Coil Active Elements\": \"https://bids.neuroimaging.io#ReceiveCoilActiveElements\",\r\n",
" \"Non Linear Gradient Correction\": \"https://bids.neuroimaging.io#NonLinearGradientCorrection\",\r\n",
" \"Dwell Time\": \"https://bids.neuroimaging.io#DwellTime\",\r\n",
" \"Multiband Acceleration Factor\": \"https://bids.neuroimaging.io#MultibandAccelerationFactor\",\r\n",
" \"Anatomical Landmark Coordinates\": \"https://bids.neuroimaging.io#AnatomicalLandmarkCoordinates\",\r\n",
" \"Institution Name\": \"https://bids.neuroimaging.io#InstitutionName\",\r\n",
" \"Institution Address\": \"https://bids.neuroimaging.io#Institution Address\",\r\n",
" \"Institutional Department Name\": \"https://bids.neuroimaging.io#InstitutionalDepartmentName\",\r\n",
" \"Author\": \"https://bids.neuroimaging.io#Author\",\r\n",
" \"License\": \"https://bids.neuroimaging.io#License\",\r\n",
" \"Description\": \"https://bids.neuroimaging.io#Description\",\r\n",
" \"Age\": \"https://bids.neuroimaging.io#Age\",\r\n",
" \"Ethnicity\": \"https://bids.neuroimaging.io#Ethnicity\",\r\n",
" \"Family Name\": \"https://bids.neuroimaging.io#FamilyName\",\r\n",
" \"Handedness\": \"https://bids.neuroimaging.io#Handedness\",\r\n",
" \"Sex\": \"https://bids.neuroimaging.io#Sex\",\r\n",
" \"Race\": \"https://bids.neuroimaging.io#Race\",\r\n",
" \"Participant Id\": \"https://bids.neuroimaging.io#ParticipantId\",\r\n",
" \"Sampling Frequency\": \"https://bids.neuroimaging.io#SamplingFrequency\",\r\n",
" \"Trigger\": \"https://bids.neuroimaging.io#Trigger\",\r\n",
" \"Angiography\": \"https://bids.neuroimaging.io#Angiography\",\r\n",
" \"Combined Proton Density/T2\": \"https://bids.neuroimaging.io#CombinedProtonDensityT2\",\r\n",
" \"FLAIR\": \"https://bids.neuroimaging.io#FLAIR\",\r\n",
" \"FLASH\": \"https://bids.neuroimaging.io#FLASH\",\r\n",
" \"Proton Density Map\": \"https://bids.neuroimaging.io#ProtonDensityMap\",\r\n",
" \"T1 Map\": \"https://bids.neuroimaging.io#T1Map\",\r\n",
" \"T1 Rho Map\": \"https://bids.neuroimaging.io#T1RhoMap\",\r\n",
" \"T2 Map\": \"https://bids.neuroimaging.io#T2Map\",\r\n",
" \"Inplane T1\": \"https://bids.neuroimaging.io#InplaneT1\",\r\n",
" \"Inplane T2\": \"https://bids.neuroimaging.io#InplaneT2\",\r\n",
" \"Duration\": \"https://bids.neuroimaging.io#Duration\",\r\n",
" \"Onset\": \"https://bids.neuroimaging.io#Onset\",\r\n",
" \"Sample\": \"https://bids.neuroimaging.io#Sample\",\r\n",
" \"Response Time\": \"https://bids.neuroimaging.io#ResponseTime\",\r\n",
" \"Value\": \"https://bids.neuroimaging.io#Value\",\r\n",
" \"Trial Type\": \"https://bids.neuroimaging.io#TrialType\",\r\n",
" \"Acquisition Duration\": \"https://bids.neuroimaging.io#AcquisitionDuration\",\r\n",
" \"BOLD\": \"https://bids.neuroimaging.io#BOLD\",\r\n",
" \"Delay After Trigger\": \"https://bids.neuroimaging.io#DelayAfterTrigger\",\r\n",
" \"Delay Time\": \"https://bids.neuroimaging.io#DelayTime\",\r\n",
" \"Instructions\": \"https://bids.neuroimaging.io#Instructions\",\r\n",
" \"Number Of Volumes Discarded By Scanner\": \"https://bids.neuroimaging.io#NumberOfVolumesDiscardedByScanner\",\r\n",
" \"Number Of Volumes Discarded By User\": \"https://bids.neuroimaging.io#NumberOfVolumesDiscardedByUser\",\r\n",
" \"Phase\": \"https://bids.neuroimaging.io#Phase\",\r\n",
" \"Repetition Time\": \"https://bids.neuroimaging.io#RepetitionTime\",\r\n",
" \"Task Description\": \"https://bids.neuroimaging.io#TaskDescription\",\r\n",
" \"Task Name\": \"https://bids.neuroimaging.io#TaskName\",\r\n",
" \"Volume Timing\": \"https://bids.neuroimaging.io#VolumeTiming\",\r\n",
" \"CBV\": \"https://bids.neuroimaging.io#CBV\",\r\n",
" \"Cog Atlas ID\": \"https://bids.neuroimaging.io#CogAtlasID\",\r\n",
" \"CogPO ID\": \"https://bids.neuroimaging.io#CogPOID\",\r\n",
" \"b-value\": \"https://bids.neuroimaging.io#b-ValueFile\",\r\n",
" \"b-vector\": \"https://bids.neuroimaging.io#b-VectorFile\", \r\n",
" \"Cardiac\": \"https://bids.neuroimaging.io#HeartRateMonitor\",\r\n",
" \"Diffusion Tensor\": \"https://bids.neuroimaging.io#DiffusionTensor\",\r\n",
" \"Diffusion Weighted\": \"https://bids.neuroimaging.io#DiffusionWeighted\",\r\n",
" \"Gender\": \"https://bids.neuroimaging.io#Gender\",\r\n",
" \"Proton Density\": \"https://bids.neuroimaging.io#ProtonDensityWeighted\", \r\n",
" \"Respiratory\": \"https://bids.neuroimaging.io#RespirationRateMonitor\",\r\n",
" \"Session\": \"https://bids.neuroimaging.io#Session\",\r\n",
" \"Stimulus Response File\": \"https://bids.neuroimaging.io#StimulusResponseFile\",\r\n",
" \"T1 Weighted\": \"https://bids.neuroimaging.io#T1Weighted\",\r\n",
" \"T2-Star Weighted\": \"https://bids.neuroimaging.io#T2StarWeighted\",\r\n",
" \"T2 Weighted\": \"https://bids.neuroimaging.io#T2Weighted\",\r\n",
" \"Pulse Sequence Details\": \"https://bids.neuroimaging.io#PulseSequence\",\r\n",
" \"Pulse Sequence Type\": \"https://bids.neuroimaging.io#PulseType\",\r\n",
" \"Title\": \"https://bids.neuroimaging.io#title\",\r\n",
" \"Group\": \"https://bids.neuroimaging.io#Group\",\r\n",
" } \r\n",
"}\r\n",
"\r\n"
]
}
],
"source": [
"cat bids_context.json\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At that point, some bids terms present in the bids specification also appear in the nidm-experiment ontology such as: \"b-value\", \"b-vector\", \"T1 Weighted\" or \"Gender\" etc. We decided to not consider the existing prefixes, to avoid ambiguity. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"WIP: to adapt the code in BIDSMRI2NIDM.py to add properly the information from the json files. "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading