Skip to content

Commit b320026

Browse files
committed
add examples for within, outside, remote
1 parent a159e53 commit b320026

1 file changed

Lines changed: 78 additions & 3 deletions

File tree

src/02-common-principles.md

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,85 @@ the location of the data that is being pointed to changes.
379379
For these reasons, starting with BIDS version 1.6.1, using "relative paths" for
380380
all fields pointing to a separate file is [DEPRECATED][].
381381
382-
Instead, the following scheme should be used to point to files within and outside
383-
of BIDS datasets.
382+
Instead, the following [URI][uniform-resource-indicator] scheme SHOULD be
383+
used to point to files within and outside of BIDS datasets, as elaborated below.
384384
385-
... to be done
385+
`bids:<dataset-name>:/absolute/path/within/dataset`
386+
387+
Here, `bids:` is the URI scheme, and `<dataset-name>:/absolute/path/within/dataset`
388+
is the path to the file, consisting of the name of a dataset, a colon, and the absolute
389+
path within that dataset that MUST start with a forward slash `/`.
390+
391+
The location of a dataset with the name `<dataset-name>` MUST be specified in the
392+
[`dataset_description.json` file](./03-modality-agnostic-files.md#dataset-description)
393+
under the `DatasetLinks` field, which is an [object][] of [strings][], as shown in
394+
the examples below.
395+
Note that the `<dataset-name>`: `"local"` is a reserved value that may only be
396+
used to refer to the current dataset.
397+
398+
### Refer to a file within a dataset
399+
400+
To link for example to a derivative file that is stored in a nested `derivatives/`
401+
directory within a dataset:
402+
`bids:deriv1:/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz`
403+
404+
```json
405+
{
406+
"DatasetLinks": {
407+
"deriv1": "file://derivatives/derivative1
408+
}
409+
410+
}
411+
```
412+
413+
Note that this is the same as specifying the following pointer:
414+
`bids:local:/derivatives/derivative1/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz`
415+
Because the reserved `<dataset-name>`: `"local"` always points to the
416+
root of the current dataset.
417+
The `DatasetLinks` metadata does not have to be specified if `local` is the
418+
only `<dataset-name>` that occurs throughout the dataset.
419+
420+
### Refer to a file outside of a dataset but on the same host
421+
422+
To link for example to a derivative file that is stored in a `derivatives/`
423+
directory that is NOT nested in the raw BIDS directory:
424+
425+
`bids:deriv2:/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz`
426+
427+
```json
428+
{
429+
"DatasetLinks": {
430+
"deriv2": "file://../some-local-path/derivative2
431+
}
432+
}
433+
```
434+
435+
Instead of specifying the path for `deriv2` from the example above relative
436+
to the current dataset, you MAY specify the path as an absolute path on the
437+
current host using the following syntax:
438+
439+
```json
440+
{
441+
"DatasetLinks": {
442+
"deriv2": "file:///some-other-local-path/derivative2
443+
}
444+
}
445+
```
446+
447+
### Refer to a remote dataset
448+
449+
To link for example to a derivative file that is stored in a `derivatives/`
450+
directory that is stored on a remote server called `mydatahost.com`.
451+
452+
`bids:deriv3:/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz`
453+
454+
```json
455+
{
456+
"DatasetLinks": {
457+
"deriv3": "https://mydatahost.com/some-path/derivative3
458+
}
459+
}
460+
```
386461

387462
## The Inheritance Principle
388463

0 commit comments

Comments
 (0)