@abasb75/dicom-parser 0.0.6-test → 0.0.21

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,72 +1,57 @@
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:
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.
15
5
 
16
- ```javascript
17
- import { loadAndParseFromUrl } from "@abasb75/dicom-parser";
6
+ ---
18
7
 
19
- ...
20
- const url = "....dcm";
21
- loadAndParseFromUrl(url)
22
- .then(dataset=>{
23
- console.log(dataset);
24
- })
25
- .catch(err=>{
26
- console.log(error);
27
- })
8
+ ## 📦 Installation
28
9
 
10
+ ```bash
11
+ npm install @abasb75/dicom-parser
29
12
  ```
30
13
 
14
+ ## Demo
31
15
 
32
- 2. For parse dataset from local files:
16
+ https://abasb75.github.io/dicom-parser/
33
17
 
34
- ```javascript
35
- import { loadAndParseFromFiles } from "@abasb75/dicom-parser";
18
+ ## 🚀 Usage
36
19
 
37
- ...
20
+ To use this library, you must provide the ArrayBuffer of a DICOM file.
38
21
 
39
- loadAndParseFromFiles(file)
40
- .then(dataset=>{
41
- console.log(dataset);
42
- })
43
- .catch(err=>{
44
- console.log(error);
45
- });
22
+ ```js
23
+ import { parse } from '@abasb75/dicom-parser';
46
24
 
47
- ```
25
+ const dataset = parse(dicomBuffer as ArrayBuffer);
48
26
 
49
- 3. For parsing arrayBuffer:
27
+ console.log({ dataset });
28
+ ```
50
29
 
51
- ```javascript
52
- import { parse } from "@abasb75/dicom-parser";
30
+ ## Get Value
53
31
 
54
- ...
32
+ ```js
55
33
 
56
- const dataset = parse(arrayBuffer);
34
+ const metadata = dataset.metadata;
35
+ const someTag = dataset.get(0xXXXX,0xXXXX);
57
36
 
58
37
  ```
59
38
 
39
+ ## Pixel Data
60
40
 
61
- 4. Getting value for dicom tag
41
+ ```js
42
+ const pixelData = dataset.getPixelData(frameIndex=0);
43
+ ```
62
44
 
63
- ```javascript
45
+ ## Pallete Color Data
64
46
 
65
- ...
47
+ ```js
48
+ const paletteDataMap = dataset.getPaletteColorData();
66
49
 
67
- const transferSyntaxUID = dataset.get(0x0002,0x0010);
68
- const transferSyntaxUID = dataset.string(0x0002,0x0010);
50
+ if(paletteDataMap){
51
+ // apply palette color to pixels
52
+ ...
53
+ }
54
+
55
+ ````
69
56
 
70
- ...
71
57
 
72
- ```
@@ -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";
117
+ hasPixelData(): boolean;
118
+ getPixelData(frameIndex?: number): DataView;
119
+ getPaletteColorData(): PaletteColorData;
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 { Dataset, _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";
117
+ hasPixelData(): boolean;
118
+ getPixelData(frameIndex?: number): DataView;
119
+ getPaletteColorData(): PaletteColorData;
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 { Dataset, _default as default, loadAndParseFromFiles, loadAndParseFromUrl, parse };