NIfTI endpoints¶
Two endpoints for NIfTI files (.nii, .nii.gz).
POST /nifti/metadata¶
Extract metadata from an uploaded NIfTI file.
Request: multipart/form-data
| Field | Type | Description |
|---|---|---|
file |
file | A .nii or .nii.gz file |
Response: application/json
{
"filename": "scan.nii.gz",
"format": "nifti",
"shape": [64, 64, 30],
"voxel_sizes": [3.0, 3.0, 4.0],
"data_dtype": "float32",
"affine": [[...], ...],
"header": { "...": "..." }
}
Example:
import httpx
with open("bold.nii.gz", "rb") as f:
response = httpx.post(
"http://127.0.0.1:8000/nifti/metadata",
files={"file": f},
)
print(response.json()["shape"])
POST /nifti/preview¶
Generate a PNG slice preview from an uploaded NIfTI file.
Request: multipart/form-data + query parameters
| Field | Type | Description |
|---|---|---|
file |
file | A .nii or .nii.gz file |
| Query param | Type | Required | Description |
|---|---|---|---|
plane |
string | Yes | One of axial, coronal, sagittal |
slice_index |
integer | No | Slice index; defaults to centre |
Response: image/png
Example: