Karolinska Institutet

NILS

Neuroimaging Intelligent
Linked System

Intelligent Classification
Automated Anonymization
BIDS Export

NILS

The Challenge

Raw DICOM Chaos

Inconsistent naming
Vendor variations
No standard structure

Research Ready

BIDS compliant
Consistent classification
Automated pipeline

Why Classification is Hard

DICOM Tags Are Unreliable

SeriesDescription varies by site, operator, and vendor

Vendor-Specific Implementations

Siemens, GE, Philips encode the same sequence differently

Multi-Output Acquisitions

SyMRI produces 20+ outputs from one 5-minute scan

Derived vs Source Ambiguity

ADC maps, synthetic contrasts, and reformats need special handling

Six-Axis Classification

Orthogonal dimensions for complete MRI characterization

The Six Axes

Base

T1w, T2w, DWI, SWI

Technique

TSE, MPRAGE, EPI

Modifier

FLAIR, FatSat, 3D

Construct

ADC, FA, T1map

Provenance

SyMRI, SWI, Raw

Acceleration

GRAPPA, SMS, CS

Classification Output

{
  "base": "T1w",
  "technique": "MPRAGE",
  "modifier_csv": "3D",
  "construct_csv": null,
  "provenance": "RawRecon",
  "acceleration_csv": "GRAPPA",
  "directory_type": "anat"
}

Maps directly to BIDS structure

Detection Infrastructure

Multi-layer vendor-agnostic detection

DICOM Tags
5 Parsers
107 Unified Flags
6 Axis Detectors

DICOM Tag Parsers

Parser DICOM Tag Detects
ImageType (0008,0008) ORIGINAL, DERIVED, ADC, PHASE, SWI...
ScanningSequence (0018,0020) SE, GR, IR, EP physics
SequenceVariant (0018,0021) SK, SP, MP modifiers
ScanOptions (0018,0022) FS, FC, parallel imaging
SequenceName (0018,0024) *tfl3d, *ep_b patterns

107 Unified Flags

Vendor-agnostic boolean detection flags

Physics

has_se has_gre has_epi has_ir

Technique

is_tse is_mprage is_dwi is_bold

Derived

has_adc has_fa is_synthetic is_qmap
Flags aggregate evidence from all parsers using OR logic

Three-Tier Detection

1

Exclusive Flag 95%

Single unified flag definitively identifies the value

2

Alternative Flags / Keywords 75-90%

Any matching condition triggers detection (OR logic)

3

Combination / Fallback 50-75%

Multiple conditions must match (AND logic)

Provenance-First Branching

Route to specialized logic based on data origin

Provenance
SyMRI Branch 17+ types
SWI Branch 6 types
EPIMix Branch 12 types
RawRecon Branch

The Multi-Output Problem

Modern sequences produce multiple series from one acquisition

Technology Time Outputs Challenge
SyMRI/MAGiC ~5 min 1-20+ series Maps vs synthetic contrasts
SWI ~4 min 2-6 series Mag vs phase vs processed
EPIMix ~1 min 5-9 series 6 contrasts, same source
All outputs share the same sequence name — standard detectors fail

SyMRI Branch

Quantitative vs synthetic: a physics distinction

Quantitative Maps

base = NULL (no tissue contrast)

T1map, T2map, PDmap, MyelinMap

Pixel value = measurement in ms or %

Synthetic Weighted

base = T1w/T2w/PDw

SyntheticT1w, SyntheticFLAIR, SyntheticDIR

Simulated contrast-weighted images

Key insight: T1 map pixel "800" means 800 ms — not T1-weighted contrast

SWI Branch

Susceptibility contrast from magnitude + phase

Magnitude
T2* anatomy
Phase
Iron vs calcium
SWI
Mag × Phase4
MinIP
Venogram
QSM
Quantitative (ppm)
All outputs have base=SWI; construct differentiates output type

EPIMix/NeuroMix Branch

Complete brain exam in ~1 minute

EPIMix (55-75s)

T1-FLAIRSE-EPI
T2-FLAIRSE-EPI
T2wb=0 from DWI
isoDWI / ADCSE-EPI
T2*wGRE-EPI

NeuroMix adds

T2-FLAIRSSFSE no distortion
T2wSSFSE
T1w 3D3D-EPI
SWI 3D3D-EPI
Developed at Karolinska Institutet (Skare, Sprenger et al.)

Cohort Pipeline

Four-stage processing workflow


Anonymize

Extract

Sort

BIDS Export

Sorting: 4-Step Process

1. Checkup

Verify cohort scope, validate data integrity, repair dates

2. Stack Fingerprint

Build classification features with Polars (450K stacks in ~60s)

3. Classification

10-stage pipeline with provenance branching

4. Completion

Fill gaps, flag for manual review

10-Stage Classification

0

Exclusion Check

1

Provenance Detection

2

Technique Detection

3

Branch Logic

4

Modifier Detection

5

Acceleration Detection

6

Contrast Agent Detection

7

Body Part Detection

8

Intent Synthesis (BIDS)

9

Review Flag Aggregation

Architecture

Frontend

React + Vite + TypeScript

Backend

Python FastAPI + Polars

Database

PostgreSQL

Deployment

Docker Compose

# Quick Start

git clone https://github.com/\
    NeuroGranberg/NILS.git

cd NILS

docker compose up

Web UI at localhost:5173

YAML-Driven Rules

Extensible without code changes

# technique-detection.yaml

MPRAGE:
  name: "MPRAGE"
  category: "GRE"

  detection:
    exclusive: is_mprage
    keywords:
      - "mprage"
      - "bravo"
      - "ir-spgr"
    combination:
      - has_gre
      - has_ir
      - is_3d

  implied_base: "T1w"

Detection YAML Files

  • base-detection.yaml
  • technique-detection.yaml
  • modifier-detection.yaml
  • construct-detection.yaml
  • provenance-detection.yaml
  • acceleration-detection.yaml

Get Started

Repository

github.com/NeuroGranberg/NILS


Documentation

neurogranberg.github.io/NILS

Quick Start

git clone ...NILS.git
docker compose up