6.0.1 • Published 2 months ago

@itk-wasm/dicom v6.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

@itk-wasm/dicom

npm version

Read files and images related to DICOM file format.

💻 Live API Demo

🕮 Documentation 📚

Installation

npm install @itk-wasm/dicom

Usage

Browser interface

Import:

import {
  applyPresentationStateToImage,
  readDicomEncapsulatedPdf,
  structuredReportToHtml,
  structuredReportToText,
  readDicomTags,
  readImageDicomFileSeries,
  setPipelinesBaseUrl,
  getPipelinesBaseUrl,
} from "@itk-wasm/dicom"

applyPresentationStateToImage

Apply a presentation state to a given DICOM image and render output as bitmap, or dicom file.

async function applyPresentationStateToImage(
  imageIn: File | BinaryFile,
  presentationStateFile: File | BinaryFile,
  options: ApplyPresentationStateToImageOptions = {}
) : Promise<ApplyPresentationStateToImageResult>
ParameterTypeDescription
imageIn*FileBinaryFile*Input DICOM file
presentationStateFile*FileBinaryFile*Process using presentation state file

ApplyPresentationStateToImageOptions interface:

PropertyTypeDescription
colorOutputbooleanoutput image as RGB (default: false)
configFilestringfilename: string. Process using settings from configuration file
framenumberframe: integer. Process using image frame f (default: 1)
noPresentationStateOutputbooleanDo not get presentation state information in text stream.
noBitmapOutputbooleanDo not get resulting image as bitmap output stream.
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

ApplyPresentationStateToImageResult interface:

PropertyTypeDescription
presentationStateOutStreamJsonCompatibleOutput overlay information
outputImageImageOutput image
webWorkerWorkerWebWorker used for computation.

readDicomEncapsulatedPdf

Extract PDF file from DICOM encapsulated PDF.

async function readDicomEncapsulatedPdf(
  dicomFile: File | BinaryFile,
  options: ReadDicomEncapsulatedPdfOptions = {}
) : Promise<ReadDicomEncapsulatedPdfResult>
ParameterTypeDescription
dicomFile*FileBinaryFile*Input DICOM file

ReadDicomEncapsulatedPdfOptions interface:

PropertyTypeDescription
readFileOnlybooleanread file format only
readDatasetbooleanread data set without file meta information
readXferAutobooleanuse TS recognition (default)
readXferDetectbooleanignore TS specified in the file meta header
readXferLittlebooleanread with explicit VR little endian TS
readXferBigbooleanread with explicit VR big endian TS
readXferImplicitbooleanread with implicit VR little endian TS
acceptOddLengthbooleanaccept odd length attributes (default)
assumeEvenLengthbooleanassume real length is one byte larger
enableCp246booleanread undefined len UN as implicit VR (default)
disableCp246booleanread undefined len UN as explicit VR
retainUnbooleanretain elements as UN (default)
convertUnbooleanconvert to real VR if known
enableCorrectionbooleanenable automatic data correction (default)
disableCorrectionbooleandisable automatic data correction
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

ReadDicomEncapsulatedPdfResult interface:

PropertyTypeDescription
pdfBinaryOutputUint8ArrayOutput pdf file
webWorkerWorkerWebWorker used for computation.

structuredReportToHtml

Render DICOM SR file and data set to HTML/XHTML

async function structuredReportToHtml(
  dicomFile: File | BinaryFile,
  options: StructuredReportToHtmlOptions = {}
) : Promise<StructuredReportToHtmlResult>
ParameterTypeDescription
dicomFile*FileBinaryFile*Input DICOM file

StructuredReportToHtmlOptions interface:

PropertyTypeDescription
readFileOnlybooleanread file format only
readDatasetbooleanread data set without file meta information
readXferAutobooleanuse TS recognition (default)
readXferDetectbooleanignore TS specified in the file meta header
readXferLittlebooleanread with explicit VR little endian TS
readXferBigbooleanread with explicit VR big endian TS
readXferImplicitbooleanread with implicit VR little endian TS
processingDetailsbooleanshow currently processed content item
unknownRelationshipbooleanaccept unknown/missing relationship type
invalidItemValuebooleanaccept invalid content item value
(e.g. violation of VR or VM definition)
ignoreConstraintsbooleanignore relationship content constraints
ignoreItemErrorsbooleando not abort on content item errors, just warn
(e.g. missing value type specific attributes)
skipInvalidItemsbooleanskip invalid content items (incl. sub-tree)
disableVrCheckerbooleandisable check for VR-conformant string values
charsetRequirebooleanrequire declaration of ext. charset (default)
charsetAssumestringcharset: string, assume charset c if no extended charset declared
charsetCheckAllbooleancheck all data elements with string values
(default: only PN, LO, LT, SH, ST, UC and UT)
convertToUtf8booleanconvert all element values that are affected
by Specific Character Set (0008,0005) to UTF-8
urlPrefixstringURL: string. Append specificed URL prefix to hyperlinks of referenced composite objects in the document.
html32booleanuse only HTML version 3.2 compatible features
html40booleanallow all HTML version 4.01 features (default)
xhtml11booleancomply with XHTML version 1.1 specification
addDocumentTypebooleanadd reference to SGML document type definition
cssReferencestringURL: string. Add reference to specified CSS to document
cssFile*stringFileTextFile*filename: string. Embed content of specified CSS into document
expandInlinebooleanexpand short content items inline (default)
neverExpandInlinebooleannever expand content items inline
alwaysExpandInlinebooleanalways expand content items inline
renderFullDatabooleanrender full data of content items
sectionTitleInlinebooleanrender section titles inline, not separately
documentTypeTitlebooleanuse document type as document title (default)
patientInfoTitlebooleanuse patient information as document title
noDocumentHeaderbooleando not render general document information
renderInlineCodesbooleanrender codes in continuous text blocks
conceptNameCodesbooleanrender code of concept names
numericUnitCodesbooleanrender code of numeric measurement units
codeValueUnitbooleanuse code value as measurement unit (default)
codeMeaningUnitbooleanuse code meaning as measurement unit
renderAllCodesbooleanrender all codes (implies +Ci, +Cn and +Cu)
codeDetailsTooltipbooleanrender code details as a tooltip (implies +Cc)
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

StructuredReportToHtmlResult interface:

PropertyTypeDescription
outputTextstringOutput text file
webWorkerWorkerWebWorker used for computation.

structuredReportToText

Read a DICOM structured report file and generate a plain text representation

async function structuredReportToText(
  dicomFile: File | BinaryFile,
  options: StructuredReportToTextOptions = {}
) : Promise<StructuredReportToTextResult>
ParameterTypeDescription
dicomFile*FileBinaryFile*Input DICOM file

StructuredReportToTextOptions interface:

PropertyTypeDescription
unknownRelationshipbooleanAccept unknown relationship type
invalidItemValuebooleanAccept invalid content item value
ignoreConstraintsbooleanIgnore relationship constraints
ignoreItemErrorsbooleanIgnore content item errors
skipInvalidItemsbooleanSkip invalid content items
noDocumentHeaderbooleanPrint no document header
numberNestedItemsbooleanNumber nested items
shortenLongValuesbooleanShorten long item values
printInstanceUidbooleanPrint SOP Instance UID
printSopclassShortbooleanPrint short SOP class name
printSopclassLongbooleanPrint SOP class name
printSopclassUidbooleanPrint long SOP class name
printAllCodesbooleanPrint all codes
printInvalidCodesbooleanPrint invalid codes
printTemplateIdbooleanPrint template identification
indicateEnhancedbooleanIndicate enhanced encoding mode
printColorbooleanUse ANSI escape codes
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

StructuredReportToTextResult interface:

PropertyTypeDescription
outputTextstringOutput text file
webWorkerWorkerWebWorker used for computation.

readDicomTags

Read the tags from a DICOM file

async function readDicomTags(
  dicomFile: File | BinaryFile,
  options: ReadDicomTagsOptions = {}
) : Promise<ReadDicomTagsResult>
ParameterTypeDescription
dicomFile*FileBinaryFile*Input DICOM file.

ReadDicomTagsOptions interface:

PropertyTypeDescription
tagsToReadJsonCompatibleA JSON object with a "tags" array of the tags to read. If not provided, all tags are read. Example tag: "0008103e".
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

ReadDicomTagsResult interface:

PropertyTypeDescription
tagsJsonCompatibleOutput tags in the file. JSON object an array of tag, value arrays. Values are encoded as UTF-8 strings.
webWorkerWorkerWebWorker used for computation.

readImageDicomFileSeries

Read a DICOM image series and return the associated image volume

async function readImageDicomFileSeries(
  options: ReadImageDicomFileSeriesOptions = { inputImages: [] as BinaryFile[] | File[] | string[], }
) : Promise<ReadImageDicomFileSeriesResult>
ParameterTypeDescription

ReadImageDicomFileSeriesOptions interface:

PropertyTypeDescription
inputImages*string[]File[]BinaryFile[]*File names in the series
singleSortedSeriesbooleanThe input files are a single sorted series
webWorkernull or Worker or booleanWebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

ReadImageDicomFileSeriesResult interface:

PropertyTypeDescription
outputImageImageOutput image volume
sortedFilenamesJsonCompatibleOutput sorted filenames
webWorkerWorkerWebWorker used for computation.

setPipelinesBaseUrl

Set base URL for WebAssembly assets when vendored.

function setPipelinesBaseUrl(
  baseUrl: string | URL
) : void

getPipelinesBaseUrl

Get base URL for WebAssembly assets when vendored.

function getPipelinesBaseUrl() : string | URL

Node interface

Import:

import {
  applyPresentationStateToImageNode,
  readDicomEncapsulatedPdfNode,
  structuredReportToHtmlNode,
  structuredReportToTextNode,
  readDicomTagsNode,
  readImageDicomFileSeriesNode,
} from "@itk-wasm/dicom"

applyPresentationStateToImageNode

Apply a presentation state to a given DICOM image and render output as bitmap, or dicom file.

async function applyPresentationStateToImageNode(
  imageIn: string,
  presentationStateFile: string,
  options: ApplyPresentationStateToImageNodeOptions = {}
) : Promise<ApplyPresentationStateToImageNodeResult>
ParameterTypeDescription
imageInstringInput DICOM file
presentationStateFilestringProcess using presentation state file

ApplyPresentationStateToImageNodeOptions interface:

PropertyTypeDescription
colorOutputbooleanoutput image as RGB (default: false)
configFilestringfilename: string. Process using settings from configuration file
framenumberframe: integer. Process using image frame f (default: 1)
noPresentationStateOutputbooleanDo not get presentation state information in text stream.
noBitmapOutputbooleanDo not get resulting image as bitmap output stream.

ApplyPresentationStateToImageNodeResult interface:

PropertyTypeDescription
presentationStateOutStreamJsonCompatibleOutput overlay information
outputImageImageOutput image

readDicomEncapsulatedPdfNode

Extract PDF file from DICOM encapsulated PDF.

async function readDicomEncapsulatedPdfNode(
  dicomFile: string,
  options: ReadDicomEncapsulatedPdfNodeOptions = {}
) : Promise<ReadDicomEncapsulatedPdfNodeResult>
ParameterTypeDescription
dicomFilestringInput DICOM file

ReadDicomEncapsulatedPdfNodeOptions interface:

PropertyTypeDescription
readFileOnlybooleanread file format only
readDatasetbooleanread data set without file meta information
readXferAutobooleanuse TS recognition (default)
readXferDetectbooleanignore TS specified in the file meta header
readXferLittlebooleanread with explicit VR little endian TS
readXferBigbooleanread with explicit VR big endian TS
readXferImplicitbooleanread with implicit VR little endian TS
acceptOddLengthbooleanaccept odd length attributes (default)
assumeEvenLengthbooleanassume real length is one byte larger
enableCp246booleanread undefined len UN as implicit VR (default)
disableCp246booleanread undefined len UN as explicit VR
retainUnbooleanretain elements as UN (default)
convertUnbooleanconvert to real VR if known
enableCorrectionbooleanenable automatic data correction (default)
disableCorrectionbooleandisable automatic data correction

ReadDicomEncapsulatedPdfNodeResult interface:

PropertyTypeDescription
pdfBinaryOutputUint8ArrayOutput pdf file

structuredReportToHtmlNode

Render DICOM SR file and data set to HTML/XHTML

async function structuredReportToHtmlNode(
  dicomFile: string,
  options: StructuredReportToHtmlNodeOptions = {}
) : Promise<StructuredReportToHtmlNodeResult>
ParameterTypeDescription
dicomFilestringInput DICOM file

StructuredReportToHtmlNodeOptions interface:

PropertyTypeDescription
readFileOnlybooleanread file format only
readDatasetbooleanread data set without file meta information
readXferAutobooleanuse TS recognition (default)
readXferDetectbooleanignore TS specified in the file meta header
readXferLittlebooleanread with explicit VR little endian TS
readXferBigbooleanread with explicit VR big endian TS
readXferImplicitbooleanread with implicit VR little endian TS
processingDetailsbooleanshow currently processed content item
unknownRelationshipbooleanaccept unknown/missing relationship type
invalidItemValuebooleanaccept invalid content item value
(e.g. violation of VR or VM definition)
ignoreConstraintsbooleanignore relationship content constraints
ignoreItemErrorsbooleando not abort on content item errors, just warn
(e.g. missing value type specific attributes)
skipInvalidItemsbooleanskip invalid content items (incl. sub-tree)
disableVrCheckerbooleandisable check for VR-conformant string values
charsetRequirebooleanrequire declaration of ext. charset (default)
charsetAssumestringcharset: string, assume charset c if no extended charset declared
charsetCheckAllbooleancheck all data elements with string values
(default: only PN, LO, LT, SH, ST, UC and UT)
convertToUtf8booleanconvert all element values that are affected
by Specific Character Set (0008,0005) to UTF-8
urlPrefixstringURL: string. Append specificed URL prefix to hyperlinks of referenced composite objects in the document.
html32booleanuse only HTML version 3.2 compatible features
html40booleanallow all HTML version 4.01 features (default)
xhtml11booleancomply with XHTML version 1.1 specification
addDocumentTypebooleanadd reference to SGML document type definition
cssReferencestringURL: string. Add reference to specified CSS to document
cssFile*stringFileTextFile*filename: string. Embed content of specified CSS into document
expandInlinebooleanexpand short content items inline (default)
neverExpandInlinebooleannever expand content items inline
alwaysExpandInlinebooleanalways expand content items inline
renderFullDatabooleanrender full data of content items
sectionTitleInlinebooleanrender section titles inline, not separately
documentTypeTitlebooleanuse document type as document title (default)
patientInfoTitlebooleanuse patient information as document title
noDocumentHeaderbooleando not render general document information
renderInlineCodesbooleanrender codes in continuous text blocks
conceptNameCodesbooleanrender code of concept names
numericUnitCodesbooleanrender code of numeric measurement units
codeValueUnitbooleanuse code value as measurement unit (default)
codeMeaningUnitbooleanuse code meaning as measurement unit
renderAllCodesbooleanrender all codes (implies +Ci, +Cn and +Cu)
codeDetailsTooltipbooleanrender code details as a tooltip (implies +Cc)

StructuredReportToHtmlNodeResult interface:

PropertyTypeDescription
outputTextstringOutput text file

structuredReportToTextNode

Read a DICOM structured report file and generate a plain text representation

async function structuredReportToTextNode(
  dicomFile: string,
  options: StructuredReportToTextNodeOptions = {}
) : Promise<StructuredReportToTextNodeResult>
ParameterTypeDescription
dicomFilestringInput DICOM file

StructuredReportToTextNodeOptions interface:

PropertyTypeDescription
unknownRelationshipbooleanAccept unknown relationship type
invalidItemValuebooleanAccept invalid content item value
ignoreConstraintsbooleanIgnore relationship constraints
ignoreItemErrorsbooleanIgnore content item errors
skipInvalidItemsbooleanSkip invalid content items
noDocumentHeaderbooleanPrint no document header
numberNestedItemsbooleanNumber nested items
shortenLongValuesbooleanShorten long item values
printInstanceUidbooleanPrint SOP Instance UID
printSopclassShortbooleanPrint short SOP class name
printSopclassLongbooleanPrint SOP class name
printSopclassUidbooleanPrint long SOP class name
printAllCodesbooleanPrint all codes
printInvalidCodesbooleanPrint invalid codes
printTemplateIdbooleanPrint template identification
indicateEnhancedbooleanIndicate enhanced encoding mode
printColorbooleanUse ANSI escape codes

StructuredReportToTextNodeResult interface:

PropertyTypeDescription
outputTextstringOutput text file

readDicomTagsNode

Read the tags from a DICOM file

async function readDicomTagsNode(
  dicomFile: string,
  options: ReadDicomTagsNodeOptions = {}
) : Promise<ReadDicomTagsNodeResult>
ParameterTypeDescription
dicomFilestringInput DICOM file.

ReadDicomTagsNodeOptions interface:

PropertyTypeDescription
tagsToReadJsonCompatibleA JSON object with a "tags" array of the tags to read. If not provided, all tags are read. Example tag: "0008103e".

ReadDicomTagsNodeResult interface:

PropertyTypeDescription
tagsJsonCompatibleOutput tags in the file. JSON object an array of tag, value arrays. Values are encoded as UTF-8 strings.

readImageDicomFileSeriesNode

Read a DICOM image series and return the associated image volume

async function readImageDicomFileSeriesNode(
  options: ReadImageDicomFileSeriesNodeOptions = { inputImages: [] as string[], }
) : Promise<ReadImageDicomFileSeriesNodeResult>
ParameterTypeDescription

ReadImageDicomFileSeriesNodeOptions interface:

PropertyTypeDescription
inputImages*string[]File[]BinaryFile[]*File names in the series
singleSortedSeriesbooleanThe input files are a single sorted series

ReadImageDicomFileSeriesNodeResult interface:

PropertyTypeDescription
outputImageImageOutput image volume
sortedFilenamesJsonCompatibleOutput sorted filenames
6.0.1

2 months ago

6.0.0

4 months ago

5.0.2

5 months ago

5.0.1

5 months ago

3.3.0

8 months ago

3.2.1

9 months ago

3.2.0

9 months ago

3.1.0

9 months ago

5.0.0

6 months ago

3.0.0

9 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.1.0

12 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago

0.2.0

1 year ago