convert / convert-batch¶
Convert Bruker Paravision scans into NIfTI files, optionally writing JSON sidecars and applying hooks.
brkraw convert¶
Basic usage¶
Convert a single scan/reco:
brkraw convert /path/to/study --scan-id 3 --reco-id 1
If path is omitted, BRKRAW_PATH is used.
Scan and reco selection¶
--scan-id¶
Convert a single scan.
If omitted, BrkRaw converts all available scans.
--reco-id¶
Convert a single reconstruction within the scan.
If omitted, BrkRaw converts all available reconstructions for each scan.
Output control¶
-o, --output¶
Where to write outputs:
- Directory: write files under that directory.
- File path (
.nii/.nii.gz): treated as a base name in the file's parent directory. For multi-slicepack outputs, BrkRaw appends slicepack suffixes.
Examples:
brkraw convert /path/to/study --scan-id 3 -o out/
brkraw convert /path/to/study --scan-id 3 -o scan3.nii.gz
Notes:
- When
--scan-idis omitted (convert all scans),--outputmust be a directory. - If
--outputis a file path,--prefixcannot be used. - Output directories are created automatically.
--prefix¶
Override the base output name using a template.
The template supports {Key} tags from layout info (and can include / to build subfolders).
brkraw convert /path/to/study --scan-id 3 --prefix "{Protocol}_{ScanID}"
Name de-duplication¶
BrkRaw avoids overwriting existing outputs.
- If your layout or
--prefixcontains{Counter}, it will tryCounter=1..until names are unique. - If you do not use
{Counter}, BrkRaw appends_<N>(for example_2,_3, ...) when needed.
BrkRaw also sanitizes invalid characters in rendered names.
--no-compress¶
Write .nii instead of .nii.gz (default: compressed).
brkraw convert /path/to/study --scan-id 3 --no-compress
Sidecar metadata¶
--sidecar¶
Write a JSON sidecar next to each NIfTI output.
brkraw convert /path/to/study --scan-id 3 --sidecar
--no-convert¶
Skip NIfTI conversion and only write sidecar metadata (requires --sidecar).
brkraw convert /path/to/study --scan-id 3 --sidecar --no-convert
Context maps¶
--context-map¶
Apply a context map YAML for selection and mapping.
brkraw convert /path/to/study --scan-id 3 --context-map map.yaml --sidecar
Notes:
- Context map selectors may skip specific scan/reco pairs.
- Context maps can influence layout metadata (layout template/entries and slicepack suffix) for that run.
Hooks¶
--hook-arg¶
Pass a single hook argument (repeatable):
brkraw convert /path/to/study --scan-id 3 --hook-arg "<hook-name>:key=value"
Format:
HOOK:KEY=VALUE
Value coercion:
true/falseare parsed as booleans.- integers and floats are parsed when possible.
- otherwise values are treated as strings.
--hook-args-yaml¶
Load hook arguments from a YAML file (repeatable). CLI --hook-arg values override YAML.
brkraw convert /path/to/study --scan-id 3 --hook-args-yaml hook_args.yaml
Example YAML:
hooks:
<hook-name>:
key: value
Environment variables:
BRKRAW_CONVERT_HOOK_ARGS_YAML(comma-separated paths)BRKRAW_HOOK_ARGS_YAML(comma-separated paths)
Affines, units, and headers¶
--space¶
Select affine space:
rawscannersubject_ras(default)
brkraw convert /path/to/study --scan-id 3 --space subject_ras
--override-subject-type / --override-subject-pose¶
Override subject metadata used for subject-view affines (space=subject_ras only).
brkraw convert /path/to/study --scan-id 3 --override-subject-type Quadruped
brkraw convert /path/to/study --scan-id 3 --override-subject-pose Head_Supine
--xyz-units / --t-units¶
Set NIfTI header units (defaults: mm, sec).
brkraw convert /path/to/study --scan-id 3 --xyz-units mm --t-units sec
--header¶
Provide a YAML file containing NIfTI header overrides.
brkraw convert /path/to/study --scan-id 3 --header header.yaml
Multi-dimensional data¶
--flatten-fg¶
Flatten frame-group dimensions to 4D when data is 5D or higher.
brkraw convert /path/to/study --scan-id 3 --flatten-fg
--cycle-index / --cycle-count¶
Read only a subset of cycles from multi-cycle data (last axis).
brkraw convert /path/to/study --scan-id 3 --cycle-index 0 --cycle-count 10
If --cycle-count is set but --cycle-index is omitted, BrkRaw defaults cycle-index to 0.
brkraw convert-batch¶
Convert all datasets under a root folder.
brkraw convert-batch /path/to/datasets -o out/
Dataset discovery:
- subdirectories under the root folder
- zip files directly under the root folder
Notes:
--outputmust be a directory forconvert-batch.- failures in one dataset do not stop the whole batch, but a full run with zero successes is treated as an error.
Environment defaults¶
Many flags can be provided through environment variables (commonly set via brkraw session set).
Common ones:
BRKRAW_PATHBRKRAW_SCAN_IDBRKRAW_RECO_IDBRKRAW_CONVERT_OUTPUTBRKRAW_CONVERT_PREFIXBRKRAW_CONVERT_SIDECARBRKRAW_CONVERT_CONTEXT_MAPBRKRAW_CONVERT_SPACEBRKRAW_CONVERT_COMPRESSBRKRAW_CONVERT_FLATTEN_FGBRKRAW_CONVERT_CYCLE_INDEXBRKRAW_CONVERT_CYCLE_COUNTBRKRAW_CONVERT_OVERRIDE_SUBJECT_TYPEBRKRAW_CONVERT_OVERRIDE_SUBJECT_POSEBRKRAW_CONVERT_XYZ_UNITSBRKRAW_CONVERT_T_UNITSBRKRAW_CONVERT_HEADER