Skip to content

Commit

Permalink
WIP: before rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jadh4v committed Jul 18, 2024
1 parent a40def8 commit 626cfcd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
1 change: 1 addition & 0 deletions packages/dicom/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"itk-wasm": "workspace:^"
},
"devDependencies": {
"@itk-wasm/compare-images": "workspace:*",
"@itk-wasm/dicom-build": "workspace:*",
"@itk-wasm/image-io": "workspace:*",
"@itk-wasm/demo-app": "workspace:*",
Expand Down
46 changes: 21 additions & 25 deletions packages/dicom/typescript/test/node/dcmtk.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
writeSegmentationNode,
} from '../../dist/index-node.js'
import { readImageNode, writeImageNode } from '@itk-wasm/image-io'
// import { compareImageToBaseline } from 'cypress/support/compareImageToBaseline.js'
// /home/jadhav/code/itk-wasm/packages/dicom/typescript/cypress/support/compareImageToBaseline.ts
import { compareImagesNode, vectorMagnitudeNode, toScalarDouble } from '@itk-wasm/compare-images'
//import toScalarDouble from '@itk-wasm/compare-images/toScalarDouble';

function arrayEquals(a, b) {
return (a.length === b.length && a.every((val, idx) => val === b[idx]))
Expand Down Expand Up @@ -335,17 +335,23 @@ test('DCMQI write DICOM segmentation object: overlapping labels', async t => {
})
*/

/*
async function writeDoubleImage(image, filepath) {
const testImageDouble = await toScalarDouble(vectorMagnitudeNode, image);
await writeImageNode(testImageDouble, filepath);
}
await writeDoubleImage(output.segImage, outputPathPrefix + '/output_makeSeg_double.nrrd');
*/
// dcmqi native tests migrated to TypeScript:
// Path to test data from dcmqi is in its source dir
const dcmqi_lib_SOURCE_DIR = '../emscripten-build/_deps/dcmqi_lib-src'
const BASELINE = path.join(dcmqi_lib_SOURCE_DIR, '/data/segmentations')
const JSON_DIR = path.join(dcmqi_lib_SOURCE_DIR, '/doc/examples')

test('write-segmentation_makeSEG', async t => {
const inputSegImageFile = path.join(BASELINE,'/liver_seg.nrrd')
const inputSegImageFile = path.join(dcmqi_lib_SOURCE_DIR, 'data/segmentations/liver_seg.nrrd')
const inputSegImage = await readImageNode(inputSegImageFile)
t.assert(inputSegImage)

const metaInfoFile = path.join(JSON_DIR, '/seg-example.json')
const metaInfoFile = path.join(dcmqi_lib_SOURCE_DIR, 'doc/examples/seg-example.json')
const jsonFileBuffer = fs.readFileSync(metaInfoFile)
const jsonObject = JSON.parse(jsonFileBuffer)
const outputDicomFile = path.join(outputPathPrefix,'liver-seg.dcm')
Expand All @@ -366,23 +372,13 @@ test('write-segmentation_makeSEG', async t => {
const output = await readSegmentationNode(outputDicomFile)
t.assert(output.segImage)
t.assert(output.metaInfo)
compareImageToBaseline(t, output.segImage, inputSegImage)

/*
dcmqi_add_test(
NAME ${dcm2itk}_makeNRRD
MODULE_NAME ${MODULE_NAME}
COMMAND $<TARGET_FILE:${dcm2itk}Test>
--compare ${BASELINE}/liver_seg.nrrd
${MODULE_TEMP_DIR}/makeNRRD-1.nrrd
${dcm2itk}Test
--inputDICOM ${MODULE_TEMP_DIR}/liver.dcm
--outputDirectory ${MODULE_TEMP_DIR}
--outputType nrrd
--prefix makeNRRD
TEST_DEPENDS
${itk2dcm}_makeSEG
)
*/

const r1 = await compareImagesNode(
test1, {
baselineImages: [output.segImage],
spatialTolerance: 0.00001,
})
t.assert(r1)
t.assert(r1 && r1.metrics)
t.assert(r1.metrics.almostEqual)
t.assert(r1.metrics.maximumDifference < 0.01)
})

0 comments on commit 626cfcd

Please sign in to comment.