dicom-synth 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +348 -55
- package/bin/dicom-synth-generate.mjs +85 -0
- package/dist/esm/collection/writer.js +484 -0
- package/dist/esm/index.js +649 -179
- package/dist/esm/schema/types.js +0 -0
- package/dist/esm/schema/validate.js +191 -0
- package/dist/esm/syntheticFixtures/generator.js +140 -103
- package/dist/esm/syntheticFixtures/uid.js +68 -0
- package/dist/esm/syntheticFixtures/violations.js +115 -0
- package/dist/types/collection/writer.d.ts +22 -0
- package/dist/types/index.d.ts +5 -5
- package/dist/types/schema/types.d.ts +64 -0
- package/dist/types/schema/validate.d.ts +3 -0
- package/dist/types/syntheticFixtures/generator.d.ts +3 -27
- package/dist/types/syntheticFixtures/uid.d.ts +12 -0
- package/dist/types/syntheticFixtures/violations.d.ts +2 -0
- package/package.json +3 -3
- package/bin/dicom-synth-write.mjs +0 -9
- package/dist/esm/negativeCases/index.js +0 -17
- package/dist/types/negativeCases/index.d.ts +0 -11
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { type CollectionManifest, type GeneratedFile, generateCollectionFromSpec, generateFile, writeCollectionFromSpec, } from './collection/writer.js';
|
|
2
|
+
export { defaultPublicCasesPath, loadCaseById, loadCasesFromJson, loadDefaultCases, type PublicCaseRecord, type PublicCaseSource, } from './public-fixtures/catalog.js';
|
|
3
|
+
export { caseCachePath, fetchPublicCaseToCache, verifySha256, } from './public-fixtures/fetch.js';
|
|
4
|
+
export type { DatasetLayout, DatasetSpec, DicomdirSpec, DicomTagOverrides, FakeSignatureSpec, FileSpec, ImageSpec, InvalidUidCtSpec, LargeCtSpec, NonDicomSpec, SeriesEntrySpec, SeriesSpec, StudySpec, TransferSyntax, ValidCtSpec, VendorCtSpec, ViolationClass, } from './schema/types.js';
|
|
5
|
+
export { validateDatasetSpec } from './schema/validate.js';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type TransferSyntax = 'explicit-vr-little-endian' | 'implicit-vr-little-endian';
|
|
2
|
+
export type DicomTagOverrides = {
|
|
3
|
+
PatientID?: string;
|
|
4
|
+
PatientName?: string;
|
|
5
|
+
StudyDescription?: string;
|
|
6
|
+
SeriesDescription?: string;
|
|
7
|
+
[tag: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type ViolationClass = 'uid-too-long' | 'non-conformant-uid' | 'missing-meta-header' | 'malformed-sq-delimiter' | 'vr-max-length-exceeded' | 'missing-type1-tag';
|
|
10
|
+
type BaseCtSpec = {
|
|
11
|
+
tags?: DicomTagOverrides;
|
|
12
|
+
transferSyntax?: TransferSyntax;
|
|
13
|
+
violations?: ViolationClass[];
|
|
14
|
+
};
|
|
15
|
+
export type ValidCtSpec = BaseCtSpec & {
|
|
16
|
+
type: 'valid-ct';
|
|
17
|
+
};
|
|
18
|
+
export type InvalidUidCtSpec = BaseCtSpec & {
|
|
19
|
+
type: 'invalid-uid-ct';
|
|
20
|
+
};
|
|
21
|
+
export type VendorCtSpec = BaseCtSpec & {
|
|
22
|
+
type: 'vendor-warnings-ct';
|
|
23
|
+
};
|
|
24
|
+
export type LargeCtSpec = BaseCtSpec & {
|
|
25
|
+
type: 'large-ct';
|
|
26
|
+
rows: number;
|
|
27
|
+
columns: number;
|
|
28
|
+
frames?: number;
|
|
29
|
+
};
|
|
30
|
+
export type FakeSignatureSpec = {
|
|
31
|
+
type: 'fake-signature';
|
|
32
|
+
};
|
|
33
|
+
export type NonDicomSpec = {
|
|
34
|
+
type: 'non-dicom';
|
|
35
|
+
content?: string;
|
|
36
|
+
};
|
|
37
|
+
export type DicomdirSpec = {
|
|
38
|
+
type: 'dicomdir';
|
|
39
|
+
};
|
|
40
|
+
export type ImageSpec = ValidCtSpec | InvalidUidCtSpec | VendorCtSpec | LargeCtSpec;
|
|
41
|
+
export type FileSpec = ImageSpec | FakeSignatureSpec | NonDicomSpec | DicomdirSpec;
|
|
42
|
+
export type EntrySpec = FileSpec & {
|
|
43
|
+
count?: number;
|
|
44
|
+
};
|
|
45
|
+
export type SeriesEntrySpec = ImageSpec & {
|
|
46
|
+
count?: number;
|
|
47
|
+
};
|
|
48
|
+
export type SeriesSpec = {
|
|
49
|
+
entries: SeriesEntrySpec[];
|
|
50
|
+
tags?: DicomTagOverrides;
|
|
51
|
+
};
|
|
52
|
+
export type StudySpec = {
|
|
53
|
+
series: SeriesSpec[];
|
|
54
|
+
tags?: DicomTagOverrides;
|
|
55
|
+
count?: number;
|
|
56
|
+
};
|
|
57
|
+
export type DatasetLayout = 'flat' | 'hierarchical';
|
|
58
|
+
export type DatasetSpec = {
|
|
59
|
+
entries?: EntrySpec[];
|
|
60
|
+
studies?: StudySpec[];
|
|
61
|
+
seed?: number;
|
|
62
|
+
layout?: DatasetLayout;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function buildSyntheticCtBuffer(variant: SyntheticCtVariant): Buffer;
|
|
5
|
-
export declare const SYNTHETIC_FIXTURES: {
|
|
6
|
-
filename: string;
|
|
7
|
-
variant: SyntheticCtVariant;
|
|
8
|
-
description: string;
|
|
9
|
-
}[];
|
|
10
|
-
export type MinimalDicomTags = {
|
|
11
|
-
patientId?: string;
|
|
12
|
-
patientName?: string;
|
|
13
|
-
sopInstanceUid?: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Write a minimal CT DICOM file to `filePath`.
|
|
17
|
-
*
|
|
18
|
-
* The output is intentionally bare: it contains no Part 10 group-0002
|
|
19
|
-
* file-meta header (no MediaStorageSOPClassUID, TransferSyntaxUID, etc.).
|
|
20
|
-
* Use `buildDicomDict` / `buildSyntheticCtBuffer` when a conformant
|
|
21
|
-
* Part 10 file with a complete meta header is required.
|
|
22
|
-
*
|
|
23
|
-
* The parent directory is created if it does not exist.
|
|
24
|
-
*/
|
|
25
|
-
export declare function writeMinimalDicomFile(filePath: string, tags?: MinimalDicomTags): void;
|
|
26
|
-
/** Write all catalogue fixtures to a directory (created if missing). */
|
|
27
|
-
export declare function writeSyntheticFixturesToDir(outDir: string): string[];
|
|
1
|
+
import type { FileSpec } from '../schema/types.js';
|
|
2
|
+
import type { UidSet } from './uid.js';
|
|
3
|
+
export declare function buildBufferForSpec(spec: FileSpec, uid: UidSet): Buffer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type UidSet = {
|
|
2
|
+
study: string;
|
|
3
|
+
series: string;
|
|
4
|
+
sop: string;
|
|
5
|
+
};
|
|
6
|
+
export type GroupUidGenerator = {
|
|
7
|
+
study: (studyIndex: number) => string;
|
|
8
|
+
series: (studyIndex: number, seriesIndex: number) => string;
|
|
9
|
+
};
|
|
10
|
+
export declare function makeGroupUidGenerator(seed?: number): GroupUidGenerator;
|
|
11
|
+
export type UidGenerator = (fileIndex: number) => UidSet;
|
|
12
|
+
export declare function makeUidGenerator(seed?: number): UidGenerator;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dicom-synth",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Toolkit for synthetic DICOM fixtures and public fixture fetch/cache.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@11.
|
|
7
|
+
"packageManager": "pnpm@11.5.2",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/clintools/dicom-synth.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"module": "dist/esm/index.js",
|
|
23
23
|
"types": "dist/types/index.d.ts",
|
|
24
24
|
"bin": {
|
|
25
|
-
"dicom-synth-
|
|
25
|
+
"dicom-synth-generate": "./bin/dicom-synth-generate.mjs",
|
|
26
26
|
"dicom-synth-fetch": "./bin/dicom-synth-fetch.mjs"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { writeSyntheticFixturesToDir } from '../dist/esm/index.js'
|
|
4
|
-
|
|
5
|
-
const outDir = resolve(process.argv[2] ?? './fixtures/synthetic')
|
|
6
|
-
const paths = writeSyntheticFixturesToDir(outDir)
|
|
7
|
-
for (const p of paths) {
|
|
8
|
-
console.log(`wrote ${p}`)
|
|
9
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/negativeCases/index.ts
|
|
2
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
function writeFakeDicomSignatureFile(filePath) {
|
|
5
|
-
const buf = Buffer.alloc(200, 0);
|
|
6
|
-
buf.write("XXXX", 128, 4, "ascii");
|
|
7
|
-
mkdirSync(resolve(filePath, ".."), { recursive: true });
|
|
8
|
-
writeFileSync(filePath, buf);
|
|
9
|
-
}
|
|
10
|
-
function writeNonDicomFile(filePath, content = "not dicom") {
|
|
11
|
-
mkdirSync(resolve(filePath, ".."), { recursive: true });
|
|
12
|
-
writeFileSync(filePath, content);
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
writeFakeDicomSignatureFile,
|
|
16
|
-
writeNonDicomFile
|
|
17
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Write a file large enough to pass size checks but with `XXXX` at
|
|
3
|
-
* offset 128 instead of the `DICM` magic bytes.
|
|
4
|
-
* The parent directory is created if it does not exist.
|
|
5
|
-
*/
|
|
6
|
-
export declare function writeFakeDicomSignatureFile(filePath: string): void;
|
|
7
|
-
/**
|
|
8
|
-
* Write arbitrary non-DICOM content to `filePath`.
|
|
9
|
-
* The parent directory is created if it does not exist.
|
|
10
|
-
*/
|
|
11
|
-
export declare function writeNonDicomFile(filePath: string, content?: string): void;
|