JSON lines protocol¶
Unless --no-jsonl is given, the reconstruction programs report progress as JSON lines: one JSON object per line, written to stderr by default (see Progress output). forgeview and FORGE Studio both read this stream.
Every object has a type field.
Message types¶
type |
Fields | Sent |
|---|---|---|
start |
app, version |
Once, first |
log |
ts (ISO 8601 time), level (trace, debug, info, warn, error or critical), file, line, msg |
For each log message at or above --log-level |
progress |
action, id, and more fields by action (below) |
As stages start, advance and finish |
metrics |
bar_id, iter, error_norm, penalty, and in CUDA builds dev_free_mb, dev_total_mb |
Once per conjugate gradient iteration |
image_preview |
bar_id, iter, planes |
Once per iteration, from forgeSense, forgePcSense and forgePcSenseTimeSeg |
exit |
code |
Once, last. code is the exit code. |
progress¶
action |
Extra fields |
|---|---|
add |
label, max: a new progress bar with this many steps |
tick |
current, postfix: the bar has reached step current. postfix is a short status such as iter 4/20 err=3.5e-02. |
done |
optional error: the bar is finished, with an error message if it failed |
id identifies the bar. metrics and image_preview messages carry the id of the solver's bar in bar_id.
image_preview¶
planes is an array of objects with label (Image, Axial, Coronal or Sagittal), nx, ny and data. data is the base64 encoding of nx × ny 32-bit floats in the machine's byte order (little-endian on every supported platform), row-major, scaled to [0, 1]. 3D reconstructions send three orthogonal planes.
Example¶
{"type":"start","app":"forgeSense","version":"0.14.0"}
{"type":"progress","action":"add","id":0,"label":"PCG","max":20}
{"type":"progress","action":"tick","id":0,"current":1,"postfix":"iter 1/20 err=9.3618e-05"}
{"type":"metrics","bar_id":0,"iter":1,"error_norm":9.361785e-05,"penalty":0.000000e+00}
{"type":"progress","action":"done","id":0}
{"type":"exit","code":0}
Reading the stream¶
Lines that are not valid JSON can appear on the same stream, for example from a library that prints directly to stderr. forgeview shows them as plain log text, and other readers should skip them rather than stop.