@abasb75/dicom-parser 0.0.0-test23 → 0.0.1-a

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 CHANGED
@@ -1,88 +1,24 @@
1
- # @abasb75/dicom-parser
1
+ # DICOM Parser
2
2
 
3
- ```sh
4
- npm i @abasb75/dicom-parser pako --save
5
- npm i @types/pako --save-dev
6
- ```
7
-
8
- # Demo
9
-
10
- <a href="https://abasb75.github.io/dicom-parser/">demo link</a>
11
-
12
- # Usage
13
-
14
- 1. For Download dicom and parse from url:
15
-
16
- ```javascript
17
- import { loadAndParseFromUrl } from "@abasb75/dicom-parser";
18
-
19
- ...
20
- const url = "....dcm";
21
- loadAndParseFromUrl(url)
22
- .then(dataset=>{
23
- console.log(dataset);
24
- })
25
- .catch(err=>{
26
- console.log(error);
27
- })
3
+ A lightweight and simple DICOM parser designed for browser and Node.js environments.
4
+ This library extracts metadata and pixel information from raw DICOM files using a clean and intuitive API.
28
5
 
29
- ```
30
-
31
-
32
- 2. For parse dataset from local files:
33
-
34
- ```javascript
35
- import { loadAndParseFromFiles } from "@abasb75/dicom-parser";
6
+ ---
36
7
 
37
- ...
38
-
39
- loadAndParseFromFiles(file)
40
- .then(dataset=>{
41
- console.log(dataset);
42
- })
43
- .catch(err=>{
44
- console.log(error);
45
- });
8
+ ## 📦 Installation
46
9
 
10
+ ```bash
11
+ npm install @abasb75/dicom-parser
47
12
  ```
48
13
 
49
- 3. For parsing arrayBuffer:
50
-
51
- ```javascript
52
- import { parse } from "@abasb75/dicom-parser";
53
-
54
- ...
55
-
56
- const dataset = parse(arrayBuffer);
57
-
58
- ```
59
-
60
-
61
- 4. Getting value for dicom tag
62
-
63
- ```javascript
64
-
65
- ...
66
-
67
- const transferSyntaxUID = dataset.get(0x0002,0x0010);
68
- const transferSyntaxUID = dataset.string(0x0002,0x0010);
69
-
70
- ...
71
-
72
- const framePixelData = dataset.getPixelData(0); // requested frame number
73
-
74
- ...
75
-
76
- ```
14
+ ## 🚀 Usage
77
15
 
78
- 6. get `palette color` map for `PALETTE COLOR` photometricInterpretation:
16
+ To use this library, you must provide the ArrayBuffer of a DICOM file.
79
17
 
80
18
  ```js
81
- const paletteDataMap = dataset.getPaletteColorData();
19
+ import { parse } from '@abasb75/dicom-parser';
82
20
 
83
- if(paletteDataMap){
84
- // apply palette color to pixels
85
- ...
86
- }
21
+ const dataset = parse(dicomBuffer as ArrayBuffer);
87
22
 
88
- ````
23
+ console.log({ dataset });
24
+ ```
@@ -1,22 +1,3 @@
1
- import Dataset from "./Dataset";
2
- import Tag from "./Tag";
3
- interface Tags {
4
- [key: string]: Tag;
5
- }
6
- interface DicomDate {
7
- year: string | number;
8
- month: string | number;
9
- day: string | number;
10
- }
11
- interface DicomTime {
12
- hour: string | number;
13
- minute: string | number;
14
- second: string | number;
15
- }
16
- interface DicomDateTime extends DicomDate, DicomTime {
17
- }
18
- type DicomDataset = Dataset;
19
- type PixelArray = Int16Array | Uint16Array | Int32Array | Uint32Array | Int8Array | Uint8Array | Float32Array;
20
1
  interface DicomVOILutModule {
21
2
  voiLUTFunction: string;
22
3
  windowWidth: number | undefined;
@@ -69,18 +50,13 @@ interface DicomPixelModule {
69
50
  segmentedBluePaletteColorLookupTableData: any;
70
51
  segmentedAlphaPaletteColorLookupTableData: any;
71
52
  pixelMeasuresSequence: any;
53
+ spacingBetweenSlices: any;
72
54
  }
73
55
  interface DicomScalingModule {
74
56
  rescaleSlope: number | undefined;
75
57
  rescaleIntercept: number | undefined;
76
58
  modality: string;
77
- }
78
- interface PixelDataDecodeOptions {
79
- pixelData: DataView;
80
- bitsAllocated: number;
81
- pixelRepresentation: number;
82
- littleEndian: boolean;
83
- dataset?: Dataset;
59
+ rescaleType: any;
84
60
  }
85
61
  interface PaletteColorDataColor {
86
62
  data: Uint8Array[] | Uint16Array[];
@@ -95,4 +71,67 @@ interface PaletteColorData {
95
71
  blue: PaletteColorDataColor | undefined;
96
72
  alpha: PaletteColorDataColor | undefined;
97
73
  }
98
- export type { Tags, DicomTime, DicomDate, DicomDateTime, DicomDataset, DicomVOILutModule, DicomPatientModule, DicomPixelModule, DicomScalingModule, PixelArray, PixelDataDecodeOptions, PaletteColorData, PaletteColorDataColor, };
74
+
75
+ interface DatasetProperties {
76
+ littleEndian: boolean;
77
+ implicit: boolean;
78
+ elements: {
79
+ [key: string]: any;
80
+ };
81
+ bytes: Uint8Array;
82
+ transferSyntaxUID?: string | undefined | null;
83
+ prefix?: string | undefined | null;
84
+ metadata?: {
85
+ [key: string]: any;
86
+ } | undefined | null;
87
+ deflated?: boolean | undefined | null;
88
+ }
89
+ declare class Dataset {
90
+ static Float: string;
91
+ static Integer: string;
92
+ littleEndian: boolean;
93
+ implicit: boolean;
94
+ elements: {
95
+ [key: string]: any;
96
+ };
97
+ transferSyntaxUID: string | null | undefined;
98
+ prefix?: string | undefined | null;
99
+ metadata?: {
100
+ [key: string]: any;
101
+ } | undefined | null;
102
+ deflated?: boolean | undefined | null;
103
+ bytes: Uint8Array;
104
+ /** modules */
105
+ voiLUTModule: DicomVOILutModule | null;
106
+ patientModule: DicomPatientModule | null;
107
+ pixelModule: DicomPixelModule | null;
108
+ scalingModule: DicomScalingModule | null;
109
+ constructor(properties: DatasetProperties);
110
+ get(group: number | string, element?: number | null | undefined): any;
111
+ date(group: number, element: number): any;
112
+ int(group: number, element: number): number | number[];
113
+ float(group: number, element: number): number | number[];
114
+ time(group: number, element: number): any;
115
+ getGeometricTags(tagName: string, frameIndex?: number): any;
116
+ getPixelTypes(): "Float" | "Integer" | null;
117
+ hasPixelData(): boolean;
118
+ getPixelData(frameIndex?: number): DataView<ArrayBufferLike>;
119
+ getPaletteColorData(): PaletteColorData | undefined;
120
+ /** module geter */
121
+ getPatientModule(): DicomPatientModule;
122
+ getVOILutModule(): DicomVOILutModule;
123
+ getScalingModule(): DicomScalingModule;
124
+ getPixelModule(frameIndex?: number): DicomPixelModule;
125
+ recalculeModules(): void;
126
+ }
127
+
128
+ declare function loadAndParseFromUrl(url: string): Promise<Dataset>;
129
+ declare function loadAndParseFromFiles(file: File): Promise<Dataset>;
130
+ declare function parse(dicomBuffer: ArrayBuffer): Dataset;
131
+ declare const _default: {
132
+ parse: typeof parse;
133
+ loadAndParseFromFiles: typeof loadAndParseFromFiles;
134
+ loadAndParseFromUrl: typeof loadAndParseFromUrl;
135
+ };
136
+
137
+ export { _default as default, loadAndParseFromFiles, loadAndParseFromUrl, parse };
@@ -0,0 +1,137 @@
1
+ interface DicomVOILutModule {
2
+ voiLUTFunction: string;
3
+ windowWidth: number | undefined;
4
+ windowCenter: number | undefined;
5
+ voiLUTSequence: unknown;
6
+ lutDescriptor: any;
7
+ lutExplanation: any;
8
+ lutData: any;
9
+ windowCenterAndWidthExplanation: string;
10
+ }
11
+ interface DicomPatientModule {
12
+ patientName: string;
13
+ patientID: string;
14
+ typeofPatientID: string;
15
+ patientSex: string;
16
+ patientBirthDate: string;
17
+ patientAge: string;
18
+ patientSize: string;
19
+ otherPatientIDs: string;
20
+ otherPatientNames: string;
21
+ patientWeight: string;
22
+ }
23
+ interface DicomPixelModule {
24
+ photometricInterpretation: string;
25
+ numberOfFrames: number | undefined;
26
+ pixelRepresentation: number | undefined;
27
+ pixelSpacing: any | undefined;
28
+ rows: number | number | undefined;
29
+ columns: number | number | undefined;
30
+ bitsAllocated: number | undefined;
31
+ highBit: number | undefined;
32
+ bitsStored: number | undefined;
33
+ samplesPerPixel: number | undefined;
34
+ pixelDataProviderURL: any;
35
+ pixelPaddingRangeLimit: any;
36
+ extendedOffsetTable: any;
37
+ extendedOffsetTableLengths: any;
38
+ pixelAspectRatio: any;
39
+ planarConfiguration: number | undefined;
40
+ redPaletteColorLookupTableDescriptor: unknown;
41
+ greenPaletteColorLookupTableDescriptor: unknown;
42
+ bluePaletteColorLookupTableDescriptor: unknown;
43
+ alphaPaletteColorLookupTableDescriptor: unknown;
44
+ redPaletteColorLookupTableData: any;
45
+ greenPaletteColorLookupTableData: any;
46
+ bluePaletteColorLookupTableData: any;
47
+ alphaPaletteColorLookupTableData: any;
48
+ segmentedRedPaletteColorLookupTableData: any;
49
+ segmentedGreenPaletteColorLookupTableData: any;
50
+ segmentedBluePaletteColorLookupTableData: any;
51
+ segmentedAlphaPaletteColorLookupTableData: any;
52
+ pixelMeasuresSequence: any;
53
+ spacingBetweenSlices: any;
54
+ }
55
+ interface DicomScalingModule {
56
+ rescaleSlope: number | undefined;
57
+ rescaleIntercept: number | undefined;
58
+ modality: string;
59
+ rescaleType: any;
60
+ }
61
+ interface PaletteColorDataColor {
62
+ data: Uint8Array[] | Uint16Array[];
63
+ firstInputValueMapped: number;
64
+ lutEntries: number;
65
+ bitsPerEntry: number;
66
+ littleEndian: boolean;
67
+ }
68
+ interface PaletteColorData {
69
+ red: PaletteColorDataColor | undefined;
70
+ green: PaletteColorDataColor | undefined;
71
+ blue: PaletteColorDataColor | undefined;
72
+ alpha: PaletteColorDataColor | undefined;
73
+ }
74
+
75
+ interface DatasetProperties {
76
+ littleEndian: boolean;
77
+ implicit: boolean;
78
+ elements: {
79
+ [key: string]: any;
80
+ };
81
+ bytes: Uint8Array;
82
+ transferSyntaxUID?: string | undefined | null;
83
+ prefix?: string | undefined | null;
84
+ metadata?: {
85
+ [key: string]: any;
86
+ } | undefined | null;
87
+ deflated?: boolean | undefined | null;
88
+ }
89
+ declare class Dataset {
90
+ static Float: string;
91
+ static Integer: string;
92
+ littleEndian: boolean;
93
+ implicit: boolean;
94
+ elements: {
95
+ [key: string]: any;
96
+ };
97
+ transferSyntaxUID: string | null | undefined;
98
+ prefix?: string | undefined | null;
99
+ metadata?: {
100
+ [key: string]: any;
101
+ } | undefined | null;
102
+ deflated?: boolean | undefined | null;
103
+ bytes: Uint8Array;
104
+ /** modules */
105
+ voiLUTModule: DicomVOILutModule | null;
106
+ patientModule: DicomPatientModule | null;
107
+ pixelModule: DicomPixelModule | null;
108
+ scalingModule: DicomScalingModule | null;
109
+ constructor(properties: DatasetProperties);
110
+ get(group: number | string, element?: number | null | undefined): any;
111
+ date(group: number, element: number): any;
112
+ int(group: number, element: number): number | number[];
113
+ float(group: number, element: number): number | number[];
114
+ time(group: number, element: number): any;
115
+ getGeometricTags(tagName: string, frameIndex?: number): any;
116
+ getPixelTypes(): "Float" | "Integer" | null;
117
+ hasPixelData(): boolean;
118
+ getPixelData(frameIndex?: number): DataView<ArrayBufferLike>;
119
+ getPaletteColorData(): PaletteColorData | undefined;
120
+ /** module geter */
121
+ getPatientModule(): DicomPatientModule;
122
+ getVOILutModule(): DicomVOILutModule;
123
+ getScalingModule(): DicomScalingModule;
124
+ getPixelModule(frameIndex?: number): DicomPixelModule;
125
+ recalculeModules(): void;
126
+ }
127
+
128
+ declare function loadAndParseFromUrl(url: string): Promise<Dataset>;
129
+ declare function loadAndParseFromFiles(file: File): Promise<Dataset>;
130
+ declare function parse(dicomBuffer: ArrayBuffer): Dataset;
131
+ declare const _default: {
132
+ parse: typeof parse;
133
+ loadAndParseFromFiles: typeof loadAndParseFromFiles;
134
+ loadAndParseFromUrl: typeof loadAndParseFromUrl;
135
+ };
136
+
137
+ export { _default as default, loadAndParseFromFiles, loadAndParseFromUrl, parse };