Skip to content

Commit

Permalink
feat(structured-report-to-text): Initial pipeline addition
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Sep 1, 2022
1 parent 206802d commit b961063
Show file tree
Hide file tree
Showing 17 changed files with 585 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ src/build-emscripten.js
src/build-wasi.js
dist/image-io/
dist/mesh-io/
dist/dicom/
dist/pipelines
dist/wasi-image-io/
dist/wasi-mesh-io/
dist/wasi-dicom/
examples/
doc/
46 changes: 46 additions & 0 deletions dist/dicom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "itk-vite-example",
"version": "1.0.2",
"description": "This example demonstrates how to use itk-wasm in a Rollup project that targets the browser.",
"main": "index.js",
"scripts": {
"start": "vite --port 8080",
"build": "vite build",
"start:production": "vite preview --port 8080",
"cypress:open": "npx cypress open",
"cypress:run": "npx cypress run",
"cypress:runChrome": "npx cypress run --browser chrome",
"cypress:runFirefox": "npx cypress run --browser firefox",
"test:debug": "start-server-and-test start http-get://localhost:8080 cypress:open",
"test": "start-server-and-test start:production http-get://localhost:8080 cypress:run",
"test:chrome": "start-server-and-test start:production http-get://localhost:8080 cypress:runChrome",
"test:firefox": "start-server-and-test start:production http-get://localhost:8080 cypress:runFirefox"
},
"repository": {
"type": "git",
"url": "git+https://github.com/InsightSoftwareConsortium/itk-wasm.git"
},
"keywords": [
"itk",
"rollup",
"vite"
],
"author": "Matt McCormick <[email protected]>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/InsightSoftwareConsortium/itk-wasm/issues"
},
"homepage": "https://github.com/InsightSoftwareConsortium/itk-wasm#readme",
"dependencies": {
"curry": "^1.2.0",
"itk-image-io": "^1.0.0-b.18",
"itk-mesh-io": "^1.0.0-b.18",
"itk-wasm": "^1.0.0-b.18"
},
"devDependencies": {
"cypress": "^10.3.0",
"rollup-plugin-copy": "^3.4.0",
"start-server-and-test": "^1.14.0",
"vite": "^3.0.9"
}
}
2 changes: 1 addition & 1 deletion karma.conf.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = function init (config) {
{ pattern: './dist/image-io/**', watched: true, served: true, included: false },
{ pattern: './dist/mesh-io/**', watched: true, served: true, included: false },
{ pattern: './dist/web-workers/**', watched: true, served: true, included: false },
{ pattern: './dist/pipeline/**', watched: true, served: true, included: false },
{ pattern: './dist/pipelines/**', watched: true, served: true, included: false },
{ pattern: './build-emscripten/ExternalData/test/**', watched: true, served: true, included: false },
{ pattern: `${output.path}/**/*`, watched: false, included: false, },
].concat(testFiles),
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ add_subdirectory(io/internal/pipelines/image/convert-image)
add_subdirectory(io/internal/pipelines/image/read-dicom)
add_subdirectory(io/internal/pipelines/mesh/convert-mesh)
add_subdirectory(io/internal/pipelines/mesh/mesh-to-polydata)
add_subdirectory(io/internal/pipelines/dicom)

endif() # BUILD_ITK_WASM_IO_MODULES
24 changes: 22 additions & 2 deletions src/build-emscripten.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ if (options.copyBuildArtifacts) {
} catch (err) {
if (err.code !== 'EEXIST') throw err
}
try {
fs.mkdirSync(path.join('dist', 'dicom', 'pipelines'), { recursive: true })
} catch (err) {
if (err.code !== 'EEXIST') throw err
}
try {
fs.mkdirSync(path.join('dist', 'web-workers'))
} catch (err) {
Expand Down Expand Up @@ -161,10 +166,25 @@ if (options.copyBuildArtifacts) {
const result = asyncMod.map(meshIOFiles, copyMeshIOModules)
callback(null, result)
}
let dicomFiles = glob.sync(path.join(buildDir, 'dicom', '*.js'))
dicomFiles = dicomFiles.concat(glob.sync(path.join(buildDir, 'dicom', '*.wasm')))
dicomFiles = dicomFiles.filter((fn) => !fn.endsWith('.umd.wasm'))
const copyDICOMModules = function (dicomFile, callback) {
const io = path.basename(dicomFile)
const output = path.join('dist', 'dicom', 'pipelines', io)
fs.copySync(dicomFile, output)
callback(null, io)
}
const buildDICOMParallel = function (callback) {
console.log('Copying dicom modules...')
const result = asyncMod.map(dicomFiles, copyDICOMModules)
callback(null, result)
}

asyncMod.parallel([
buildImageIOsParallel,
buildMeshIOsParallel,
buildDICOMParallel,
])
} // options.copySources

Expand Down Expand Up @@ -199,13 +219,13 @@ if (options.buildTestPipelines) {
pipelineFiles = pipelineFiles.concat(glob.sync(path.join(pipelinePath, 'web-build', '*.wasm')))
pipelineFiles.forEach((file) => {
const filename = path.basename(file)
const output = path.join('dist', 'pipeline', filename)
const output = path.join('dist', 'pipelines', filename)
fs.copySync(file, output)
})
}

try {
fs.mkdirSync(path.join('dist', 'pipeline'))
fs.mkdirSync(path.join('dist', 'pipelines'))
} catch (err) {
if (err.code !== 'EEXIST') throw err
}
Expand Down
13 changes: 13 additions & 0 deletions src/build-wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,23 @@ if (options.copyBuildArtifacts) {
const result = asyncMod.map(meshIOFiles, copyMeshIOModules)
callback(null, result)
}
let dicomFiles = glob.sync(path.join(buildDir, 'wasi-dicom', '*.wasm'))
const copyDICOMModules = function (dicomFile, callback) {
const io = path.basename(dicomFile)
const output = path.join('dist', 'wasi-dicom', io)
fs.copySync(dicomFile, output)
callback(null, io)
}
const buildDICOMParallel = function (callback) {
console.log('Copying wasi-dicom modules...')
const result = asyncMod.map(dicomFiles, copyDICOMModules)
callback(null, result)
}

asyncMod.parallel([
buildImageIOsParallel,
buildMeshIOsParallel,
buildDICOMParallel,
])
} // options.copySources

Expand Down
52 changes: 52 additions & 0 deletions src/io/internal/pipelines/dicom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.16)
project(itkwasm-dicom)

set(CMAKE_CXX_STANDARD 17)

find_package(ITK REQUIRED
COMPONENTS
ITKDCMTK
WebAssemblyInterface
)
include(${ITK_USE_FILE})

set(wasm_modules )

# diquant.cc required for odd linker error
add_executable(structured-report-to-text structured-report-to-text.cxx diquant.cc)
target_link_libraries(structured-report-to-text PUBLIC ${ITK_LIBRARIES})
list(APPEND wasm_modules "structured-report-to-text")


if (WASI AND DEFINED WebAssemblyInterface_BINARY_DIR)
foreach(target ${wasm_modules})
itk_module_target_label(${target})
itk_module_target_export(${target})
itk_module_target_install(${target})
set_property(TARGET ${target}
PROPERTY RUNTIME_OUTPUT_DIRECTORY
${WebAssemblyInterface_BINARY_DIR}/wasi-dicom
)
endforeach()
return()
endif()

if (EMSCRIPTEN AND DEFINED WebAssemblyInterface_BINARY_DIR)
foreach(target ${wasm_modules})
itk_module_target_label(${target})
itk_module_target_export(${target})
itk_module_target_install(${target})
set_property(TARGET ${target}
PROPERTY RUNTIME_OUTPUT_DIRECTORY
${WebAssemblyInterface_BINARY_DIR}/dicom
)
itk_module_target_label(${target}.umd)
itk_module_target_export(${target}.umd)
itk_module_target_install(${target}.umd)
set_property(TARGET ${target}.umd
PROPERTY RUNTIME_OUTPUT_DIRECTORY
${WebAssemblyInterface_BINARY_DIR}/dicom
)
endforeach()
return()
endif()
Loading

0 comments on commit b961063

Please sign in to comment.