kineuroExperimental Neuroradiology Research
Karolinska Institutet

Install the engine

Take the static binary or build one, put it where you want it, take the packs beside it, and give it the tools, pipelines and workflows it runs.

The wizard does this for you. This page is what it does, for when you would rather do it yourself.

The engine is one binary, nils. One command installs it for you; this page is what that command does, and what to do when you would rather do it yourself.

Take the release

v=v1.0.0-beta.27          # the newest tag on the releases page
os=linux; cpu=x86_64      # or macos, and arm64
base=https://github.com/kineuro/nils/releases/download/$v
curl -fsSLO $base/nils-$os-$cpu
curl -fsSL $base/SHA256SUMS | grep " nils-$os-$cpu$" | sha256sum -c -
sudo install -m 755 nils-$os-$cpu /usr/local/bin/nils
nils --version

Name the version rather than saying latest. GitHub’s latest skips a prerelease, and until 1.0.0 that is all there is, so a latest/download/... URL answers 404. The releases page has the newest tag.

Since 1.0.0-beta.2 the Linux binaries are static. nils-linux-x86_64 and nils-linux-arm64 are built for the musl targets with every C dependency compiled in, so each runs on any Linux of its architecture, whatever its C library. A cluster on an enterprise Linux 9 runs the binary as it is and needs no container for it; before, the binary built on Ubuntu 24.04 needed a glibc that distribution does not have. The release checks that each binary is static and runs both inside a Rocky Linux 9 container before it is published. The artifact names are unchanged.

The packs, the rule sets that decide what a scan is, come from the same release:

curl -fsSLO $base/packs.tar.gz
mkdir -p ~/.local/share/nils/packs
tar xzf packs.tar.gz -C ~/.local/share/nils/packs --strip-components=1

The engine looks there by itself, so --pack-dir is only needed for packs kept somewhere else. The wizard does this step for you.

Or build it

The repository pins the toolchain, so rustup fetches the right version by itself.

git clone https://github.com/kineuro/nils
cd nils/engine
cargo build --release -p nils

That leaves target/release/nils, about 140 MB unstripped and with no runtime dependency beyond the C library. Put it on the path:

sudo install -m 755 target/release/nils /usr/local/bin/nils
nils --version

The build takes a few minutes and about 4 GB of memory. A Linux build made this way links the machine’s C library and runs on any distribution with glibc 2.39 or newer. For anything older, take the release’s static binary, or use the container.

Where the packs live

A pack is the rule set that decides what a scan is: which axis values a stack carries, how the rules vote, what evidence they leave. Packs are data, not code, and they ship both in the release and in the repository under packs/.

Without a --pack-dir the engine looks in $NILS_PACK_DIR, then the registry’s own packs directory, then $XDG_DATA_HOME/nils/packs (else ~/.local/share/nils/packs), then /usr/local/share/nils/packs, then /usr/share/nils/packs, and last share/nils/packs beside the binary’s own prefix. It takes the first that holds a pack, and nils serve names the directory it took. Without any packs at all it still runs, digests and answers questions; it just cannot classify anything.

Where things will live

Nothing is written outside what you name. A typical layout, all owned by the user the engine runs as:

/srv/nils/registry     the registry: nils.toml, the databases, the key store
/srv/nils/packs        the rule sets
/srv/nils/backups      where the backup job writes archives

The DICOM files themselves stay where they are. The engine reads them and records what it found; it never copies them in.

dcm2niix

A release to NIfTI or BIDS converts with dcm2niix. The wizard places the build this engine pins. To do it yourself, install it as one package of the software place:

nils software install dcm2niix
nils tools list

The install downloads the pinned build, checks its sha256, unpacks it into the registry’s tools/ folder and asks its version. nils tools list says whether dcm2niix is here, where, which build, and how it was found. nils tools install dcm2niix, the command before 1.0.0-beta.2, stays as an alias for one release. A run that fails for a missing converter, a release that cannot run it and the pre-flight’s converter check all name nils software install dcm2niix, or the desk’s Settings > Software.

Where the machine cannot reach GitHub, nils tools list names the archive to fetch, with its address and its sha256. Fetch it on a machine that can, and give it to the engine:

nils tools install dcm2niix --from dcm2niix_lnx.zip

The archive is checked against the pinned sha256 before anything is unpacked, and installed as the download would be; any other file is refused, with the archive it takes named. In the desk the same is Install from a file on Settings > Software (Settings, Parts, Tools before 1.0.0-beta.2).

The software place

Since 1.0.0-beta.2 the tools the engine runs live in one place, for NILS and for the people on the machine: a place of role software in the setup record, else software/ under the pipelines’ working place.

nils setup --place NAME=DIR,role=software
nils place add NAME DIR --role software

It is laid out as a site’s shared software folder is: <app>/<version>/image, a manifest.json beside it, bin/<cmd> for each entry point, <app>/bin/<app>-run, bin/ links for people’s PATH, modules/<app>/<version>.lua for Lmod, licences/<app>/ and externals.yaml for the installs the site registered. The wrappers find the place from their own location, so a moved folder still runs. An install pulls a tool’s image by its digest from its pack’s source (or --source, or the catalog’s pin), builds it into the place under apptainer or leaves it in the docker or podman store, and fails unless the digest it got is the digest it asked for:

nils software install freesurfer@8.2.0
nils software list

A registration records an install the site holds already, as it is, with no byte changed. --kind is sif, sandbox or image. The engine never updates or removes a registered install, and remove on it is refused:

nils software register freesurfer@8.2.0 --kind sandbox --path /opt/freesurfer/8.2.0

Since 1.0.0-beta.6 a software place declared outside every working place is the site’s shared folder: the engine writes its installs, wrappers, modules, licences and externals.yaml into a subfolder of its own, <place>/nils, and leaves the rest of the folder as it is. One place has the role; nils place set ID --path DIR moves it, or retire it and add another. What the declared place already holds is listed under “found in the place”: the Apptainer sandboxes (a folder with .singularity.d/labels.json) and SIF files that are not installs of the engine’s, each with the image it was built from as its labels say it, and the packages whose pinned image that is. Only the declared place is looked at, three levels down, never the default place and never any other path. Registering such a copy for the package it matches is one command per package, the pack taken from the catalog’s pipeline; one path may stand for several packages, as a FreeSurfer sandbox stands for every pipeline that pins its image, and a sandbox built from the pinned image is the pinned image for the results’ comparability key. A package whose image is already on the machine, though nothing in the place holds it, says “image cached, adopted at the next run”.

nils software list
nils software register synthstrip@freesurfer-8.2.0 --kind sandbox --path /shared/software/freesurfer/8.2.0/image --pack-from synthstrip@3

Both ways are verified, and nils software verify <app>@<version> verifies again: the pack’s version probe, the fingerprint (the sha256 of a SIF, or of the pack’s key files in a sandbox or a home, so a viewer’s libraries change nothing) and the pack’s test run. The dependencies are checked at install as the pre-flight checks them (the runtime, the image, memory, the GPU, disk, the converter, the licence), each ok, warn or missing with its fix. A run uses the install whose digest is its pipeline’s, verified before it runs, builds its image into the place where there is none, and records which install, version and fingerprint made each result. A run refuses an install whose last verification failed, with the fix.

Licences are recorded acceptances: who, when, which terms and the licence file’s sha256, never its content. Until an administrator accepts a tool’s terms, or places the licence file it needs, a run of the tool is refused before it starts.

nils software accept freesurfer@8.2.0 --terms URL
nils software accept freesurfer@8.2.0 --file license.txt

The file goes under licences/<app>/, readable by the engine’s account alone, and reaches its pipeline read-only with the variable the pack names (FS_LICENSE). Once the terms are accepted, --file alone places a new file and records no new acceptance. nils software remove <app>@<version> takes away what the engine installed; nils software forget <app>@<version> takes a registration back (the engine’s manifest, wrappers and module go, and the registered path is never touched). The engine never pushes an image anywhere. In the desk the same is Settings > Software.

Site participation

Since 1.0.0-beta.5 an install can share counts about itself with a receiver, and nothing else: an opt-in channel, closed by default, that a person turns on, reads before anything leaves, and turns off. Tier 1 is the counts: the archive by modality, vendor, scanner model, year and body part, the answers per axis, the review’s corrections, the releases and the audit, every cell under 5 held back. Tier 3 is a sealed read: the audit export of one draw with its composition and protocol. Every document is signed with the install’s own key; none carries a subject code, a path, header text, a stack id, a person’s name or a key.

nils participate enable --tier 1 --site NAME --receiver URL --key-file PATH
nils participate preview --tier 1 --out counts.json
nils participate send --tier 1
nils participate status
nils participate disable

preview writes the file as it would leave and records that a person saw it; send refuses a document that was never previewed or that changed since. The counts may go by themselves once previewed (--auto on enable, at most once a day); a sealed read is always sent by a person. In the desk the same is Settings > Participation, since desk 1.0.0-beta.5 with engine 1.0.0-beta.6.

Packs, families and workflows

Since 1.0.0-beta.2 a pipeline is a pair: its descriptor, nils.job.yml, and its pack, nils-pack.yaml beside it, which holds what NILS adds. The needs a session must meet (a hard need skips a unit in the pack’s words, a soft need travels as a caveat), what each knob does and whether it breaks comparability, the ordered rules that choose knob values per session from the registry’s facts and the person’s goal, the checks, the licence, the resources and the comparability key’s members. Every shipped pipeline carries one. Check a folder offline, then add the pair; the same pair again is the version it is:

nils pipelines validate pipelines/samseg-lesions
nils pipeline add pipelines/samseg-lesions

The check prints the loader’s words for what is wrong (an unknown fact, a wrong type, a word outside a fact’s vocabulary, a knob the descriptor has not, a rule that breaks a constraint of the descriptor) and the descriptor’s digest the pack must pin. It opens no registry. pipelines is an alias of pipeline.

A family is one catalog row with several member pipelines behind it, and the family document’s rules choose the member per unit. Registration is the first, with three members. Adding a family folder adds every member and then the family, and nils pipeline list and show say which rows belong to it:

nils pipelines validate pipelines/registration
nils pipeline add pipelines/registration
nils run registration --select main@dataset:NAME --switch task=within_session --preflight

A workflow is a document, nils.workflow.yml: steps, each a pipeline or a family at a version, with the goal, the switches fixed for the step and the knobs a person may set, and links, an output of one step wired to an input of a later one. Two ship with the starters, flair-lesions and cortical. Check, add, plan and run one:

nils workflow validate workflows/my-chain
nils workflow add workflows/my-chain
nils workflow list
nils workflow plan flair-lesions --select main@dataset:NAME
nils workflow run flair-lesions --select main@dataset:NAME --goal standard
nils workflow runs

The plan runs nothing: it gives each link a verdict in words (satisfied, missing, redundant, refused, fed) and each step its pre-flight. A workflow with a refused step or link does not run. Before a pack change ships, nils pipeline replay <folder> counts over the registry, read-only, what the new pack would change: how many sessions move from run to skipped and why, where units are routed, which knob values change, and which kept results it would make stale.

Provenance is read by subject code, by session or by stack:

nils provenance subject <code>
nils provenance session <code>@<label>
nils provenance stack <id>

It answers which steps ran, with which keys and results, and each result’s curation state: the rules version that classified its inputs, the label set, System 1’s answers with the model’s version, and the axes a person overrode. A change of the rules version on an input marks the result stale. A session’s label is taken with or without ses-, and its day however it is written. The Pipelines page shows the same in the desk.

Keeping it current

nils update             # the newest release, verified, in place
nils update --check     # what it would do

The engine, the desk, the assistant and Kvasir each release on their own, under version numbers of their own, so the engine’s number says nothing about the desk’s. nils update --check lists every part beside its own newest release, and nils update --part <part> updates one part alone (engine, desk, assistant or kvasir); see keeping it current.

An engine update brings the packs of its release as well, into the directory the engine reads them from, and keeps the packs it replaces in <dir>.previous. Only packs that differ from the release’s move. A site’s own packs are never touched, and a first-party pack changed on the machine is kept and said. nils update --check shows each pack’s version beside the release’s. A new pack version applies to what is classified after it, so reclassify to bring older stacks under it.

Since 1.0.0-alpha.66 the engine reads what an enhanced MR object says of how it was acquired (its MR Pulse Sequence module) and which kind of object each file is. After updating to it, in this order:

nils fingerprint                               # every stack again: the SOP class and the phase contrast fill at once
nils digest <root> --reread <manufacturer>     # per root and manufacturer that writes enhanced objects: the module's fields
nils fingerprint                               # the stacks of the series read again
nils classify --pack mri --name <label>        # every stack under the new pack

A re-read reads every file of that manufacturer’s MR series under the root again, so it takes as long as digesting them did; --reread-exact Siemens takes Siemens’ XA scanners alone, which spell their make that way. A registry with no enhanced objects needs neither the re-read nor the second fingerprint.

Since 1.0.0-alpha.69 the engine also reads GE’s series plane, which MRI pack 0.21.0 reads to tell a three-plane localizer whatever its slice count, and the ImageType Philips writes per frame of an enhanced MR object, by whose Dixon part (water, fat, in phase, out of phase) such an object’s frames are now stacks of their own. The registry’s schema moves to 78 by itself when the new engine first opens it. After updating to it, in this order:

nils digest <root> --reread "GE MEDICAL SYSTEMS"   # per root with GE MR series: the series plane
nils fingerprint                                   # every stack again, at the fingerprint's new revision
nils classify --pack mri --name <label>            # every stack under MRI pack 0.21.0

Use the manufacturer as your GE studies spell it, once for each spelling. A registry with no GE series needs no re-read. A Philips enhanced object digested before keeps the new field empty until its files are read again.

Since 1.0.0-alpha.70 the MRI pack is 0.22.0, with no change to the engine or the registry. After updating, classify again; no re-read is needed:

nils classify --pack mri --name <label>            # every stack under MRI pack 0.22.0

Since 1.0.0-alpha.71 the MRI pack is 0.23.0, again with no change to the engine or the registry. After updating, classify again; no re-read is needed:

nils classify --pack mri --name <label>            # every stack under MRI pack 0.23.0

Since 1.0.0-alpha.72 the slab door reads a slab’s tiles at once and keeps recent slabs in memory (256 MB), so pictures from pyramids on a network share come in a fraction of the time. Nothing to do after updating; the registry is unchanged.

Since 1.0.0-alpha.73 the MRI pack is 0.24.0, with no change to the registry. After updating, classify again; no re-read is needed. Classify takes about a quarter longer than under 0.23.0:

nils classify --pack mri --name <label>            # every stack under MRI pack 0.24.0

Since 1.0.0-alpha.73 the engine keeps serving when it runs short of open files, and says so on stderr rather than losing its port. It raises its own soft limit on open files to the hard one, and the unit nils setup and nils update write sets LimitNOFILE=65536 and puts the engine under systemd’s watchdog (WatchdogSec=120, NotifyAccess=main): the engine feeds the watchdog only while it takes requests, so one that hangs is restarted. A unit you wrote yourself should say the same. GET /api/health answers with no token: whether the engine is live and ready, and its counts (handlers, open files, tile reads, caches, accept errors, panics), 200 when ready and 503 when not.

Since 1.0.0-alpha.80 the rules ship on their own. A first-party pack is released under a tag of its own (pack-mri-v<version>), and its pack.yml names the engines it works with; an engine outside that range refuses it and the update path never installs it. nils update --check lists each pack beside its newest release, and nils update --part rules takes the rules alone and restarts nothing, since the engine reads a pack again when its files change. The engine’s own release still carries its packs, and stays their floor.

The MRI pack of 1.0.0-alpha.80 is 1.2.0, which needs this engine or later. The registry’s schema moves to 98 by itself when the new engine first opens it. A source place without a whole, current declaration (what its PatientID holds and how its subjects are found) becomes undeclared, and an undeclared place is never read until its folder is explored again with nils place explore; no file is touched. After updating, explore the places and classify again; no re-read and no fingerprint are needed:

nils place explore                                 # every source place's state read again
nils classify --pack mri --name <label>            # every stack under MRI pack 1.2.0

Since 1.0.0-alpha.82 a release builds every model’s image (body part, post-contrast’s cascade and System 1) from its tag, and ships the descriptors that name them by the digests it pushed, beside the binaries. Take one by its name from the release this engine is:

nils pipeline add --release bodypart-infer-fusion
nils pipeline add --release postcontrast-cascade
nils pipeline add --release system1-score

Post-contrast’s fallback image (postcontrast-full) is too large for a hosted build: it is published beforehand to ghcr.io/kineuro/nils-postcontrast-full, and the release ships its descriptor pinned to the digest published there. nils pipeline add --release postcontrast-full takes it the same way. One image runs each model on the CPU and on a card.

Since 1.0.0-beta.3 post-contrast is 0.3.0. A site the model has no calibration pair for gets its stacks scored anyway when a run is given the raw_scores switch: the model’s raw score is written beside the no-calibration reason in the run’s tables and never becomes a label. With a labelled set of its own T1 brain stacks (stack, label as given or not_given, source as header, name or manual; at least 20 of each class, a few hundred is better) the site fits its own pair:

nils-postcontrast calibrate --labels labels.tsv --scores <run folder>... --site "<cohort> <make>" --out pair.json
nils pipeline secret set post_contrast_calibration --file /absolute/path/pair.json

The pair file reports the fit overall and per label source, a fit that did not converge is refused, and the next run takes the pair from the site file without a new model bundle or image. A pair for a site the released model already calibrates is refused: a certified pair is never replaced.

Since 1.0.0-alpha.82 the registry’s schema moves to 102 by itself when the new engine first opens it. It brings the rules engine on Review (proposals with their effect shown before anyone decides), plain admin access, body part and post-contrast as layers of the Main scans map, an ID type’s identifying flag, and one lookup from an ID to its subject code. After updating, take the newest rules and sort again:

nils update --part rules
nils classify --pack mri --name <label>            # every stack under the rules now in place

In the desk the same is Update on the rules row of Settings, Parts, and then Sort again.

The rules ship on their own tag: the MRI pack is released as pack-mri-v<version>, and an install runs the newest release its engine reads. nils update --pin mri@1.0.0 holds an install at one version, and it is for one purpose: reproducing what the paper reports, which was found with rules 1.0.0. A site does not pin otherwise, since a pinned install misses the fixes made since. nils update --unpin mri lifts it. Rules 1.0.0 and 1.0.1 are published as rules releases of their own for this.

The MRI rules 1.3.0 need engine 1.0.0-alpha.87 or later. They state the thresholds at which a dataset’s headers are flagged as damaged, and change no rule, so no scan needs sorting again.

Since 1.0.0-beta.1 the registry’s schema moves to 106 by itself when the new engine first opens it. On a large registry the new index takes a few minutes, once, while the engine starts. A sort no longer makes pictures itself: it ends once its scans are judged, and its pictures and 3D views are jobs of their own, made several scans at a time. Nothing to do after updating.

Since 1.0.0-beta.2 the registry’s schema moves to 111 by itself when the new engine first opens it: the packs beside the pipelines, the software place’s acceptances, the campaigns’ planted values, the audit draws by count and the workflows. While the engine migrates, every door answers 503 with the migration’s progress, and a supervisor’s update waits for it (six hours at most unless set otherwise) instead of rolling back. The shipped pipelines are new versions with their packs, and the two workflows come with the starters: an engine that seeds its starter catalog adds them when it starts, and Seed now on the Pipelines page adds the ones lacking. The converter is installed with nils software install dcm2niix from now on; one in place is left alone. Nothing else to do after updating. A release now builds a model’s image only when its files changed, and its notes say for each image whether it was built or taken from an earlier release, with its digest.

Since 1.0.0-beta.4 the schema moves to 114 the same way. On its first start the engine gives the seven starter pipelines their packs and adds the registration family to the catalog, once; a family or starter a site added by hand is left as it is. The MRI rules 1.4.0 ship in the tree. Nothing to do after updating.

Since 1.0.0-beta.5 a dataset’s summary answers at once from its kept counts and counts again in the background when something it counts moved; the Data page of a large dataset on a network share no longer waits on every visit. LST-AI and recon-all-clinical are now starters too: a catalog already in place gets the two where their names are absent. The schema is unchanged. Nothing to do after updating.

Since 1.0.0-beta.6 the registry’s schema moves to 115 by itself when the new engine first opens it: how the install takes part and what it sent (site participation). Nothing to do after updating.

Since 1.0.0-beta.7 a dataset’s summary counts its pictures and 3D views by listing the folders they lie in, not by looking at two files a scan, and the counts are kept in the registry under the stamp they were read under, so a start of the engine, which every update is, answers them at once and counts again only where the data or the runs moved. The first count of a large dataset on a network share after a start took over half an hour and answers in seconds now. Since 1.0.0-beta.8 the 3D views are counted on a few threads, and a scan the rules never judge (a CT scan under the MRI pack) is counted outside the rules rather than as not sorted, so a dataset’s sorted step is done once every scan the rules judge is judged. The schema is unchanged. Nothing to do after updating.

Since 1.0.0-beta.9 committing a staged decision sorts the scans it reaches again at once, as answering a question at the desk does, so every page reads the value in force; until then a committed decision was in force in the registry while the stack and session pages kept the sort’s old value until the next sort. A pipeline may declare the memory a unit takes for each core it is given, beside its base, and the engine sizes a unit to the cores it takes, so one descriptor fits a laptop and a large server; the body-part pass now declares 4 GB and half a GB a worker instead of 16 GB, after a run was killed at a 16 GB cap. The schema is unchanged. Take the new descriptor by its name from this release:

nils pipeline add --release bodypart-infer-fusion

Since 1.0.0-beta.10 an engine release publishes contracts.json beside its binaries, named in its sums, so an install knows the contracts of an engine it is offered before it takes it; a release without one is measured once installed, as before. nils update --all, --part and --check print the order the parts are taken in and why: the engine first, then the desk, the assistant, Kvasir, the engine’s packs and the rules, with the newer releases left out and why, and an engine that cannot be taken stops the update before any part after it moves. Post-contrast is 0.3.1 and both its pipelines pin its new images: the full stage’s image now says how far it is as each stack’s features finish, instead of nothing until its end; its answers are unchanged. Closing a campaign into decisions sorts the scans it decided again at once, as committing does, and a run’s failures retire once a later run of the same pipeline does those units. The schema is unchanged. Take the new descriptors by name:

Since 1.0.0-beta.13 the registry’s schema moves to 117 by itself when the new engine first opens it: the names a release gave its subjects. The same first open blanks, once, every kept identifier value shaped like a valid personnummer or coordination number, whatever its type (a personnummer is never kept). A dataset that holds identified files and has no identity rule is refused pseudonymising and bring-in until the rule is given.

nils pipeline add --release postcontrast-cascade
nils pipeline add --release postcontrast-full

Next: make the registry.

Updated 28 October 2026