Skip to content

Commit

Permalink
feat: Add OP normalizer (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsimko authored Oct 29, 2024
1 parent e8f375c commit 6840af9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/DicomMetaDictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ DicomMetaDictionary.sopClassNamesByUID = {
"1.2.840.10008.5.1.4.1.1.88.33": "ComprehensiveSR",
"1.2.840.10008.5.1.4.1.1.128": "PETImage",
"1.2.840.10008.5.1.4.1.1.130": "EnhancedPETImage",
"1.2.840.10008.5.1.4.1.1.128.1": "LegacyConvertedEnhancedPETImage"
"1.2.840.10008.5.1.4.1.1.128.1": "LegacyConvertedEnhancedPETImage",
"1.2.840.10008.5.1.4.1.1.77.1.5.1": "OphthalmicPhotography8BitImage"
};

DicomMetaDictionary.dictionary = dictionary;
Expand Down
9 changes: 9 additions & 0 deletions src/normalizers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Normalizer {
PETImageNormalizer;
sopClassUIDMap[toUID.Segmentation] = SEGImageNormalizer;
sopClassUIDMap[toUID.DeformableSpatialRegistration] = DSRNormalizer;
sopClassUIDMap[toUID.OphthalmicPhotography8BitImage] =
OPImageNormalizer;
return sopClassUIDMap[sopClassUID];
}

Expand Down Expand Up @@ -531,6 +533,12 @@ class DSRNormalizer extends Normalizer {
}
}

class OPImageNormalizer extends Normalizer {
normalize() {
this.dataset = this.datasets[0]; // only one dataset per series and for now we assume it is normalized
}
}

export { Normalizer };
export { ImageNormalizer };
export { MRImageNormalizer };
Expand All @@ -543,3 +551,4 @@ export { PETImageNormalizer };
export { SEGImageNormalizer };
export { PMImageNormalizer };
export { DSRNormalizer };
export { OPImageNormalizer };
22 changes: 21 additions & 1 deletion test/normalizers.test.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
it("No tests yet", () => {});
import "regenerator-runtime/runtime.js";

import fs from "fs";
import { jest } from "@jest/globals";
import { DicomMessage } from "../src/DicomMessage";
import { DicomMetaDictionary } from "../src/DicomMetaDictionary";
import dcmjs from "../src";

// The asset downloads in this file might take some time on a slower connection
jest.setTimeout(60000);

it("test_normalizer_op", async () => {
const file = fs.readFileSync('test/sample-op.dcm');
const dicomDict = DicomMessage.readFile(file.buffer);

const dataset = DicomMetaDictionary.naturalizeDataset(dicomDict.dict);
const multiframe = dcmjs.normalizers.Normalizer.normalizeToDataset([dataset]);

expect(dataset.NumberOfFrames).toEqual(1);
expect(multiframe.NumberOfFrames).toEqual(1);
});
Binary file added test/sample-op.dcm
Binary file not shown.

0 comments on commit 6840af9

Please sign in to comment.