npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dicom-sr-parser

v3.0.0

Published

Extract TEXT from DICOM Structured Reports by Concept Name Code Value

Downloads

359

Readme

dicom-sr-parser

Extract TEXT (0040,A160) from DICOM Structured Reports by Concept Name Code Value (0008,0100) — minimal Node API built on dicom-parser.

npm install dicom-sr-parser

Requires Node.js 18+

Quick start

CLI

npx dicom-sr-parser report.dcm QURE_CODE_12
npx dicom-sr-parser --all --json report.dcm TEST_CODE_01
npx dicom-sr-parser --coding-scheme 99VENDOR report.dcm QURE_CODE_12

| Flag | Description | |------|-------------| | --all | All matches (uses parseAll) | | --json | JSON on stdout | | --coding-scheme <id> | Filter (0008,0102) | | --code-meaning <text> | Filter (0008,0104) | | -h, --help | Usage |

Default codeValue: QURE_CODE_12

Library

const fs = require("fs");
const { parse, parseAll, parseFromFile } = require("dicom-sr-parser");

const buffer = fs.readFileSync("report.dcm");

const { found, text } = parse(buffer, "QURE_CODE_12");
const all = parseAll(buffer, "QURE_CODE_12", {
  codingSchemeDesignator: "99VENDOR",
});
const fromDisk = parseFromFile("report.dcm", "TEST_CODE_01");

Long impressions (TEXT / UT): by default strings up to 1MB are read (maxElementLength; dicom-parser alone truncates at 128).

parse(buffer, "IMPRESSION", { maxElementLength: 2 * 1024 * 1024 });

ESM

import { parse, parseAll } from "dicom-sr-parser";

TypeScript

Types ship with the package (src/index.d.ts). Run npm run test:types.

dcmjs (optional)

npm install dcmjs
const { parseNaturalizedDataset, parseWithDcmjs } = require("dicom-sr-parser/dcmjs");

parseNaturalizedDataset(naturalizedDataset, "126000");
parseWithDcmjs(buffer, "QURE_CODE_12");

Browser

npm run build
import { parse } from "dicom-sr-parser/browser";

See examples/browser-demo.html and docs/guide.md.

Vendor presets

templates/qure.js, templates/rsna.js, templates/tid3110.js

API reference

| Export | Description | |--------|-------------| | parse(buffer, codeValue, options?) | First match → { found, text, codeValue } | | parseAll(buffer, codeValue, options?) | All matches → { found, matches: [{ text, path }], codeValue } | | parseFromFile(path, codeValue, options?) | Same as parse | | findTextByCodeValue(items, codeValue, options?) | Walk pre-parsed Content Sequence | | findAllByCodeValue(items, codeValue, options?) | All matches on pre-parsed tree | | findTextByCodeMeaning(items, codeMeaning, options?) | Match (0008,0104) only | | matchesConceptCode(codeItem, codeValue, options?) | Low-level concept matcher | | extractTextFromContentItem(item) | Read TEXT/UT from one content item | | dataSetToContentTree(dataSet, options?) | explicitDataSetToJS → Content Sequence | | TAG | Hex tag keys used internally | | DEFAULT_MAX_ELEMENT_LENGTH | Default maxElementLength (1MB) |

path in matches uses 1-based ordinals along nested (0040,A730) (DICOM Referenced Content Item Identifier style).

dicom-sr-parser vs dcmjs

| | dicom-sr-parser | dcmjs | |--|----------------------|-----------| | Size / deps | Tiny, dicom-parser only | Large, full DICOM toolkit | | Goal | Get labeled SR text by code | Read/write SR, SEG, TID 1500, OHIF | | API | parse(buffer, "CODE") | Naturalized JSON, derivations | | Best for | ETL, scripts, vendor codes | Web viewers, derived objects |

Use dcmjs when you need standards-first SR creation or OHIF integration. Use dicom-sr-parser when you only need one field from an SR in Node.

Examples

node examples/node-etl.cjs ./dicoms
node examples/import-esm.mjs report.dcm TEST_CODE_01

Development

npm install
npm run build
npm test
npm run test:types

Roadmap

ROADMAP.md

Changelog

CHANGELOG.md

License

MIT