diff --git a/include/itkWasmTransformIO.h b/include/itkWasmTransformIO.h index e27f0dbe8..ad616f673 100644 --- a/include/itkWasmTransformIO.h +++ b/include/itkWasmTransformIO.h @@ -73,7 +73,7 @@ class ITK_TEMPLATE_EXPORT WasmTransformIOTemplate : public TransformIOBaseTempla /** Set the JSON representation of the image information. */ void - SetJSON(const TransformListJSON & json); + SetJSON(const TransformListJSON & json, bool inMemory=false); /*-------- This part of the interfaces deals with writing data ----- */ diff --git a/packages/core/typescript/itk-wasm/src/cli/default-image-tag.js b/packages/core/typescript/itk-wasm/src/cli/default-image-tag.js index d376e9847..55b30742f 100644 --- a/packages/core/typescript/itk-wasm/src/cli/default-image-tag.js +++ b/packages/core/typescript/itk-wasm/src/cli/default-image-tag.js @@ -1,2 +1,2 @@ -const defaultImageTag = '20241107-53b18ede' +const defaultImageTag = '20241111-d4fcf16c' export default defaultImageTag diff --git a/packages/mesh-io/typescript/src/mesh-io-index-node.ts b/packages/mesh-io/typescript/src/mesh-io-index-node.ts index 33206c1f4..42525fed1 100644 --- a/packages/mesh-io/typescript/src/mesh-io-index-node.ts +++ b/packages/mesh-io/typescript/src/mesh-io-index-node.ts @@ -1,35 +1,41 @@ -import vtkPolyDataReadMeshNode from './vtk-poly-data-read-mesh-node.js' -import vtkPolyDataWriteMeshNode from './vtk-poly-data-write-mesh-node.js' -import objReadMeshNode from './obj-read-mesh-node.js' -import objWriteMeshNode from './obj-write-mesh-node.js' -import stlReadMeshNode from './stl-read-mesh-node.js' -import stlWriteMeshNode from './stl-write-mesh-node.js' -import offReadMeshNode from './off-read-mesh-node.js' -import offWriteMeshNode from './off-write-mesh-node.js' -import wasmReadMeshNode from './wasm-read-mesh-node.js' -import wasmWriteMeshNode from './wasm-write-mesh-node.js' -import wasmZstdReadMeshNode from './wasm-zstd-read-mesh-node.js' -import wasmZstdWriteMeshNode from './wasm-zstd-write-mesh-node.js' -import swcReadMeshNode from './swc-read-mesh-node.js' -import swcWriteMeshNode from './swc-write-mesh-node.js' -import byuReadMeshNode from './byu-read-mesh-node.js' -import byuWriteMeshNode from './byu-write-mesh-node.js' -import freeSurferAsciiReadMeshNode from './free-surfer-ascii-read-mesh-node.js' -import freeSurferAsciiWriteMeshNode from './free-surfer-ascii-write-mesh-node.js' -import freeSurferBinaryReadMeshNode from './free-surfer-binary-read-mesh-node.js' -import freeSurferBinaryWriteMeshNode from './free-surfer-binary-write-mesh-node.js' +import vtkPolyDataReadMeshNode from "./vtk-poly-data-read-mesh-node.js"; +import vtkPolyDataWriteMeshNode from "./vtk-poly-data-write-mesh-node.js"; +import objReadMeshNode from "./obj-read-mesh-node.js"; +import objWriteMeshNode from "./obj-write-mesh-node.js"; +import stlReadMeshNode from "./stl-read-mesh-node.js"; +import stlWriteMeshNode from "./stl-write-mesh-node.js"; +import offReadMeshNode from "./off-read-mesh-node.js"; +import offWriteMeshNode from "./off-write-mesh-node.js"; +import wasmReadMeshNode from "./wasm-read-mesh-node.js"; +import wasmWriteMeshNode from "./wasm-write-mesh-node.js"; +import wasmZstdReadMeshNode from "./wasm-zstd-read-mesh-node.js"; +import wasmZstdWriteMeshNode from "./wasm-zstd-write-mesh-node.js"; +import swcReadMeshNode from "./swc-read-mesh-node.js"; +import swcWriteMeshNode from "./swc-write-mesh-node.js"; +import byuReadMeshNode from "./byu-read-mesh-node.js"; +import byuWriteMeshNode from "./byu-write-mesh-node.js"; +import freeSurferAsciiReadMeshNode from "./free-surfer-ascii-read-mesh-node.js"; +import freeSurferAsciiWriteMeshNode from "./free-surfer-ascii-write-mesh-node.js"; +import freeSurferBinaryReadMeshNode from "./free-surfer-binary-read-mesh-node.js"; +import freeSurferBinaryWriteMeshNode from "./free-surfer-binary-write-mesh-node.js"; const meshIoIndexNode = new Map([ - ['vtk', [vtkPolyDataReadMeshNode, vtkPolyDataWriteMeshNode]], - ['obj', [objReadMeshNode, objWriteMeshNode]], - ['stl', [stlReadMeshNode, stlWriteMeshNode]], - ['off', [offReadMeshNode, offWriteMeshNode]], - ['wasm', [wasmReadMeshNode, wasmWriteMeshNode]], - ['wasm-zst', [wasmZstdReadMeshNode, wasmZstdWriteMeshNode]], - ['swc', [swcReadMeshNode, swcWriteMeshNode]], - ['byu', [byuReadMeshNode, byuWriteMeshNode]], - ['free-surfer-ascii', [freeSurferAsciiReadMeshNode, freeSurferAsciiWriteMeshNode]], - ['free-surfer-binary', [freeSurferBinaryReadMeshNode, freeSurferBinaryWriteMeshNode]], -]) + ["vtk", [vtkPolyDataReadMeshNode, vtkPolyDataWriteMeshNode]], + ["obj", [objReadMeshNode, objWriteMeshNode]], + ["stl", [stlReadMeshNode, stlWriteMeshNode]], + ["off", [offReadMeshNode, offWriteMeshNode]], + ["wasm", [wasmReadMeshNode, wasmWriteMeshNode]], + ["wasmZstd", [wasmZstdReadMeshNode, wasmZstdWriteMeshNode]], + ["swc", [swcReadMeshNode, swcWriteMeshNode]], + ["byu", [byuReadMeshNode, byuWriteMeshNode]], + [ + "freeSurferAscii", + [freeSurferAsciiReadMeshNode, freeSurferAsciiWriteMeshNode], + ], + [ + "freeSurferBinary", + [freeSurferBinaryReadMeshNode, freeSurferBinaryWriteMeshNode], + ], +]); -export default meshIoIndexNode +export default meshIoIndexNode; diff --git a/packages/mesh-io/typescript/src/mesh-io-index.ts b/packages/mesh-io/typescript/src/mesh-io-index.ts index b12d8c577..3f908c681 100644 --- a/packages/mesh-io/typescript/src/mesh-io-index.ts +++ b/packages/mesh-io/typescript/src/mesh-io-index.ts @@ -1,35 +1,35 @@ -import vtkPolyDataReadMesh from './vtk-poly-data-read-mesh.js' -import vtkPolyDataWriteMesh from './vtk-poly-data-write-mesh.js' -import objReadMesh from './obj-read-mesh.js' -import objWriteMesh from './obj-write-mesh.js' -import stlReadMesh from './stl-read-mesh.js' -import stlWriteMesh from './stl-write-mesh.js' -import offReadMesh from './off-read-mesh.js' -import offWriteMesh from './off-write-mesh.js' -import wasmReadMesh from './wasm-read-mesh.js' -import wasmWriteMesh from './wasm-write-mesh.js' -import wasmZstdReadMesh from './wasm-zstd-read-mesh.js' -import wasmZstdWriteMesh from './wasm-zstd-write-mesh.js' -import swcReadMesh from './swc-read-mesh.js' -import swcWriteMesh from './swc-write-mesh.js' -import byuReadMesh from './byu-read-mesh.js' -import byuWriteMesh from './byu-write-mesh.js' -import freeSurferAsciiReadMesh from './free-surfer-ascii-read-mesh.js' -import freeSurferAsciiWriteMesh from './free-surfer-ascii-write-mesh.js' -import freeSurferBinaryReadMesh from './free-surfer-binary-read-mesh.js' -import freeSurferBinaryWriteMesh from './free-surfer-binary-write-mesh.js' +import vtkPolyDataReadMesh from "./vtk-poly-data-read-mesh.js"; +import vtkPolyDataWriteMesh from "./vtk-poly-data-write-mesh.js"; +import objReadMesh from "./obj-read-mesh.js"; +import objWriteMesh from "./obj-write-mesh.js"; +import stlReadMesh from "./stl-read-mesh.js"; +import stlWriteMesh from "./stl-write-mesh.js"; +import offReadMesh from "./off-read-mesh.js"; +import offWriteMesh from "./off-write-mesh.js"; +import wasmReadMesh from "./wasm-read-mesh.js"; +import wasmWriteMesh from "./wasm-write-mesh.js"; +import wasmZstdReadMesh from "./wasm-zstd-read-mesh.js"; +import wasmZstdWriteMesh from "./wasm-zstd-write-mesh.js"; +import swcReadMesh from "./swc-read-mesh.js"; +import swcWriteMesh from "./swc-write-mesh.js"; +import byuReadMesh from "./byu-read-mesh.js"; +import byuWriteMesh from "./byu-write-mesh.js"; +import freeSurferAsciiReadMesh from "./free-surfer-ascii-read-mesh.js"; +import freeSurferAsciiWriteMesh from "./free-surfer-ascii-write-mesh.js"; +import freeSurferBinaryReadMesh from "./free-surfer-binary-read-mesh.js"; +import freeSurferBinaryWriteMesh from "./free-surfer-binary-write-mesh.js"; const meshIoIndex = new Map([ - ['vtk', [vtkPolyDataReadMesh, vtkPolyDataWriteMesh]], - ['obj', [objReadMesh, objWriteMesh]], - ['stl', [stlReadMesh, stlWriteMesh]], - ['off', [offReadMesh, offWriteMesh]], - ['wasm', [wasmReadMesh, wasmWriteMesh]], - ['wasm-zst', [wasmZstdReadMesh, wasmZstdWriteMesh]], - ['swc', [swcReadMesh, swcWriteMesh]], - ['byu', [byuReadMesh, byuWriteMesh]], - ['free-surfer-ascii', [freeSurferAsciiReadMesh, freeSurferAsciiWriteMesh]], - ['free-surfer-binary', [freeSurferBinaryReadMesh, freeSurferBinaryWriteMesh]], -]) + ["vtk", [vtkPolyDataReadMesh, vtkPolyDataWriteMesh]], + ["obj", [objReadMesh, objWriteMesh]], + ["stl", [stlReadMesh, stlWriteMesh]], + ["off", [offReadMesh, offWriteMesh]], + ["wasm", [wasmReadMesh, wasmWriteMesh]], + ["wasmZstd", [wasmZstdReadMesh, wasmZstdWriteMesh]], + ["swc", [swcReadMesh, swcWriteMesh]], + ["byu", [byuReadMesh, byuWriteMesh]], + ["freeSurferAscii", [freeSurferAsciiReadMesh, freeSurferAsciiWriteMesh]], + ["freeSurferBinary", [freeSurferBinaryReadMesh, freeSurferBinaryWriteMesh]], +]); -export default meshIoIndex \ No newline at end of file +export default meshIoIndex; diff --git a/packages/mesh-io/typescript/src/write-mesh-node.ts b/packages/mesh-io/typescript/src/write-mesh-node.ts index 53ca4d4aa..27b3a6755 100644 --- a/packages/mesh-io/typescript/src/write-mesh-node.ts +++ b/packages/mesh-io/typescript/src/write-mesh-node.ts @@ -1,25 +1,25 @@ -import path from 'path' +import path from "path"; -import { - Mesh, - getFileExtension, -} from 'itk-wasm' +import { Mesh, getFileExtension } from "itk-wasm"; -import mimeToMeshIo from './mime-to-mesh-io.js' -import extensionToMeshIo from './extension-to-mesh-io.js' -import meshIoIndexNode from './mesh-io-index-node.js' +import mimeToMeshIo from "./mime-to-mesh-io.js"; +import extensionToMeshIo from "./extension-to-mesh-io.js"; +import meshIoIndexNode from "./mesh-io-index-node.js"; -import WriteMeshOptions from './write-mesh-options.js' +import WriteMeshOptions from "./write-mesh-options.js"; interface WriterOptions { - useCompression?: boolean - binaryFileType?: boolean + useCompression?: boolean; + binaryFileType?: boolean; } interface WriterResult { - couldWrite: boolean + couldWrite: boolean; } -type Writer = (mesh: Mesh, serializedImage: string, options: WriterOptions) => Promise - +type Writer = ( + mesh: Mesh, + serializedMesh: string, + options: WriterOptions +) => Promise; /** * Write a mesh to a serialized file format and from an the itk-wasm Mesh @@ -34,38 +34,47 @@ async function writeMeshNode( mesh: Mesh, serializedMesh: string, options: WriteMeshOptions = {} -) : Promise { - const absoluteFilePath = path.resolve(serializedMesh) - const mimeType = options.mimeType - const extension = getFileExtension(absoluteFilePath) +): Promise { + const absoluteFilePath = path.resolve(serializedMesh); + const mimeType = options.mimeType; + const extension = getFileExtension(absoluteFilePath); - let inputMesh = mesh + let inputMesh = mesh; - let io = null - if (typeof mimeType !== 'undefined' && mimeToMeshIo.has(mimeType)) { - io = mimeToMeshIo.get(mimeType) + let io = null; + if (typeof mimeType !== "undefined" && mimeToMeshIo.has(mimeType)) { + io = mimeToMeshIo.get(mimeType); } else if (extensionToMeshIo.has(extension)) { - io = extensionToMeshIo.get(extension) + io = extensionToMeshIo.get(extension); } else { for (const readerWriter of meshIoIndexNode.values()) { if (readerWriter[1] !== null) { - let { couldWrite } = await (readerWriter[1] as Writer)(inputMesh, absoluteFilePath, { useCompression: options.useCompression, binaryFileType: options.binaryFileType }) + let { couldWrite } = await (readerWriter[1] as Writer)( + inputMesh, + absoluteFilePath, + { + useCompression: options.useCompression, + binaryFileType: options.binaryFileType, + } + ); if (couldWrite) { - return + return; } } } } - if (io === null ) { - throw Error('Could not find IO for: ' + absoluteFilePath) + if (io === null) { + throw Error("Could not find IO for: " + absoluteFilePath); } - const readerWriter = meshIoIndexNode.get(io as string) + const readerWriter = meshIoIndexNode.get(io as string); - const writer = (readerWriter as Array)[1] - let { couldWrite } = await writer(inputMesh, absoluteFilePath, { useCompression: options.useCompression }) + const writer = (readerWriter as Array)[1]; + let { couldWrite } = await writer(inputMesh, absoluteFilePath, { + useCompression: options.useCompression, + }); if (!couldWrite) { - throw Error('Could not write: ' + absoluteFilePath) + throw Error("Could not write: " + absoluteFilePath); } } -export default writeMeshNode +export default writeMeshNode; diff --git a/packages/transform-io/itkInputTransformIO.h b/packages/transform-io/itkInputTransformIO.h index 0f39da89e..f14c7e57c 100644 --- a/packages/transform-io/itkInputTransformIO.h +++ b/packages/transform-io/itkInputTransformIO.h @@ -96,11 +96,11 @@ bool lexical_cast(const std::string &input, InputTransformIOSetJSON(transformListJSON); + constexpr bool inMemory = true; + wasmTransformIO->SetJSON(transformListJSON, inMemory); auto wasmTransformIOBase = WasmTransformIOBaseType::New(); - wasmTransformIOBase->SetTransformIO(wasmTransformIO, false); - wasmTransformIOBase->SetJSON(json); + wasmTransformIOBase->SetTransformIO(wasmTransformIO, inMemory); inputTransformIO.Set(wasmTransformIOBase); #else diff --git a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/hdf5-write-transform.wasi.wasm b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/hdf5-write-transform.wasi.wasm index bac9664f2..df36f9ae5 100755 Binary files a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/hdf5-write-transform.wasi.wasm and b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/hdf5-write-transform.wasi.wasm differ diff --git a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mat-write-transform.wasi.wasm b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mat-write-transform.wasi.wasm index ea2672380..c327d6e57 100755 Binary files a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mat-write-transform.wasi.wasm and b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mat-write-transform.wasi.wasm differ diff --git a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mnc-write-transform.wasi.wasm b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mnc-write-transform.wasi.wasm index a75ce40d6..d62926f30 100755 Binary files a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mnc-write-transform.wasi.wasm and b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/mnc-write-transform.wasi.wasm differ diff --git a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/txt-write-transform.wasi.wasm b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/txt-write-transform.wasi.wasm index 5fcdf710f..0afc279ff 100755 Binary files a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/txt-write-transform.wasi.wasm and b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/txt-write-transform.wasi.wasm differ diff --git a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-write-transform.wasi.wasm b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-write-transform.wasi.wasm index 795eca383..7efa35736 100755 Binary files a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-write-transform.wasi.wasm and b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-write-transform.wasi.wasm differ diff --git a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-zstd-write-transform.wasi.wasm b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-zstd-write-transform.wasi.wasm index 93de0918a..5e4ac505b 100755 Binary files a/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-zstd-write-transform.wasi.wasm and b/packages/transform-io/python/itkwasm-transform-io-wasi/itkwasm_transform_io_wasi/wasm_modules/wasm-zstd-write-transform.wasi.wasm differ diff --git a/packages/transform-io/typescript/package.json b/packages/transform-io/typescript/package.json index d9ac5e32e..a12f5ad0d 100644 --- a/packages/transform-io/typescript/package.json +++ b/packages/transform-io/typescript/package.json @@ -34,12 +34,14 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "itk-wasm": "workspace:^" + "itk-wasm": "workspace:^", + "mime-types": "^2.1.35" }, "devDependencies": { "@itk-wasm/demo-app": "workspace:*", "@itk-wasm/transform-io-build": "workspace:*", "@types/node": "^20.2.5", + "@types/mime-types": "^2.1.4", "ava": "^6.1.3", "esbuild": "^0.19.8", "shx": "^0.3.4", diff --git a/packages/transform-io/typescript/src/extension-to-transform-io.ts b/packages/transform-io/typescript/src/extension-to-transform-io.ts new file mode 100644 index 000000000..f8482a64f --- /dev/null +++ b/packages/transform-io/typescript/src/extension-to-transform-io.ts @@ -0,0 +1,12 @@ +const extensionToTransformIo = new Map([ + ["h5", "hdf5"], + ["hdf5", "hdf5"], + ["txt", "txt"], + ["mat", "mat"], + ["xfm", "mnc"], + ["iwt", "wasm"], + ["iwt.cbor", "wasm"], + ["iwt.cbor.zst", "wasm-zstd"], +]); + +export default extensionToTransformIo; diff --git a/packages/transform-io/typescript/src/index-node-only.ts b/packages/transform-io/typescript/src/index-node-only.ts index 09c564e94..987e7973b 100644 --- a/packages/transform-io/typescript/src/index-node-only.ts +++ b/packages/transform-io/typescript/src/index-node-only.ts @@ -1,122 +1,119 @@ -// Generated file. To retain edits, remove this comment. +import ReadTransformOptions from "./read-transform-options.js"; +export type { ReadTransformOptions }; +import readTransformNode from "./read-transform-node.js"; +export { readTransformNode }; +import WriteTransformOptions from "./write-transform-options.js"; +export type { WriteTransformOptions }; -import Hdf5ReadTransformNodeResult from './hdf5-read-transform-node-result.js' -export type { Hdf5ReadTransformNodeResult } +import writeTransformNode from "./write-transform-node.js"; +export { writeTransformNode }; -import Hdf5ReadTransformNodeOptions from './hdf5-read-transform-node-options.js' -export type { Hdf5ReadTransformNodeOptions } +import Hdf5ReadTransformNodeResult from "./hdf5-read-transform-node-result.js"; +export type { Hdf5ReadTransformNodeResult }; -import hdf5ReadTransformNode from './hdf5-read-transform-node.js' -export { hdf5ReadTransformNode } +import Hdf5ReadTransformNodeOptions from "./hdf5-read-transform-node-options.js"; +export type { Hdf5ReadTransformNodeOptions }; +import hdf5ReadTransformNode from "./hdf5-read-transform-node.js"; +export { hdf5ReadTransformNode }; -import Hdf5WriteTransformNodeResult from './hdf5-write-transform-node-result.js' -export type { Hdf5WriteTransformNodeResult } +import Hdf5WriteTransformNodeResult from "./hdf5-write-transform-node-result.js"; +export type { Hdf5WriteTransformNodeResult }; -import Hdf5WriteTransformNodeOptions from './hdf5-write-transform-node-options.js' -export type { Hdf5WriteTransformNodeOptions } +import Hdf5WriteTransformNodeOptions from "./hdf5-write-transform-node-options.js"; +export type { Hdf5WriteTransformNodeOptions }; -import hdf5WriteTransformNode from './hdf5-write-transform-node.js' -export { hdf5WriteTransformNode } +import hdf5WriteTransformNode from "./hdf5-write-transform-node.js"; +export { hdf5WriteTransformNode }; +import MatReadTransformNodeResult from "./mat-read-transform-node-result.js"; +export type { MatReadTransformNodeResult }; -import MatReadTransformNodeResult from './mat-read-transform-node-result.js' -export type { MatReadTransformNodeResult } +import MatReadTransformNodeOptions from "./mat-read-transform-node-options.js"; +export type { MatReadTransformNodeOptions }; -import MatReadTransformNodeOptions from './mat-read-transform-node-options.js' -export type { MatReadTransformNodeOptions } +import matReadTransformNode from "./mat-read-transform-node.js"; +export { matReadTransformNode }; -import matReadTransformNode from './mat-read-transform-node.js' -export { matReadTransformNode } +import MatWriteTransformNodeResult from "./mat-write-transform-node-result.js"; +export type { MatWriteTransformNodeResult }; +import MatWriteTransformNodeOptions from "./mat-write-transform-node-options.js"; +export type { MatWriteTransformNodeOptions }; -import MatWriteTransformNodeResult from './mat-write-transform-node-result.js' -export type { MatWriteTransformNodeResult } +import matWriteTransformNode from "./mat-write-transform-node.js"; +export { matWriteTransformNode }; -import MatWriteTransformNodeOptions from './mat-write-transform-node-options.js' -export type { MatWriteTransformNodeOptions } +import MncReadTransformNodeResult from "./mnc-read-transform-node-result.js"; +export type { MncReadTransformNodeResult }; -import matWriteTransformNode from './mat-write-transform-node.js' -export { matWriteTransformNode } +import MncReadTransformNodeOptions from "./mnc-read-transform-node-options.js"; +export type { MncReadTransformNodeOptions }; +import mncReadTransformNode from "./mnc-read-transform-node.js"; +export { mncReadTransformNode }; -import MncReadTransformNodeResult from './mnc-read-transform-node-result.js' -export type { MncReadTransformNodeResult } +import MncWriteTransformNodeResult from "./mnc-write-transform-node-result.js"; +export type { MncWriteTransformNodeResult }; -import MncReadTransformNodeOptions from './mnc-read-transform-node-options.js' -export type { MncReadTransformNodeOptions } +import MncWriteTransformNodeOptions from "./mnc-write-transform-node-options.js"; +export type { MncWriteTransformNodeOptions }; -import mncReadTransformNode from './mnc-read-transform-node.js' -export { mncReadTransformNode } +import mncWriteTransformNode from "./mnc-write-transform-node.js"; +export { mncWriteTransformNode }; +import TxtReadTransformNodeResult from "./txt-read-transform-node-result.js"; +export type { TxtReadTransformNodeResult }; -import MncWriteTransformNodeResult from './mnc-write-transform-node-result.js' -export type { MncWriteTransformNodeResult } +import TxtReadTransformNodeOptions from "./txt-read-transform-node-options.js"; +export type { TxtReadTransformNodeOptions }; -import MncWriteTransformNodeOptions from './mnc-write-transform-node-options.js' -export type { MncWriteTransformNodeOptions } +import txtReadTransformNode from "./txt-read-transform-node.js"; +export { txtReadTransformNode }; -import mncWriteTransformNode from './mnc-write-transform-node.js' -export { mncWriteTransformNode } +import TxtWriteTransformNodeResult from "./txt-write-transform-node-result.js"; +export type { TxtWriteTransformNodeResult }; +import TxtWriteTransformNodeOptions from "./txt-write-transform-node-options.js"; +export type { TxtWriteTransformNodeOptions }; -import TxtReadTransformNodeResult from './txt-read-transform-node-result.js' -export type { TxtReadTransformNodeResult } +import txtWriteTransformNode from "./txt-write-transform-node.js"; +export { txtWriteTransformNode }; -import TxtReadTransformNodeOptions from './txt-read-transform-node-options.js' -export type { TxtReadTransformNodeOptions } +import WasmReadTransformNodeResult from "./wasm-read-transform-node-result.js"; +export type { WasmReadTransformNodeResult }; -import txtReadTransformNode from './txt-read-transform-node.js' -export { txtReadTransformNode } +import WasmReadTransformNodeOptions from "./wasm-read-transform-node-options.js"; +export type { WasmReadTransformNodeOptions }; +import wasmReadTransformNode from "./wasm-read-transform-node.js"; +export { wasmReadTransformNode }; -import TxtWriteTransformNodeResult from './txt-write-transform-node-result.js' -export type { TxtWriteTransformNodeResult } +import WasmWriteTransformNodeResult from "./wasm-write-transform-node-result.js"; +export type { WasmWriteTransformNodeResult }; -import TxtWriteTransformNodeOptions from './txt-write-transform-node-options.js' -export type { TxtWriteTransformNodeOptions } +import WasmWriteTransformNodeOptions from "./wasm-write-transform-node-options.js"; +export type { WasmWriteTransformNodeOptions }; -import txtWriteTransformNode from './txt-write-transform-node.js' -export { txtWriteTransformNode } +import wasmWriteTransformNode from "./wasm-write-transform-node.js"; +export { wasmWriteTransformNode }; +import WasmZstdReadTransformNodeResult from "./wasm-zstd-read-transform-node-result.js"; +export type { WasmZstdReadTransformNodeResult }; -import WasmReadTransformNodeResult from './wasm-read-transform-node-result.js' -export type { WasmReadTransformNodeResult } +import WasmZstdReadTransformNodeOptions from "./wasm-zstd-read-transform-node-options.js"; +export type { WasmZstdReadTransformNodeOptions }; -import WasmReadTransformNodeOptions from './wasm-read-transform-node-options.js' -export type { WasmReadTransformNodeOptions } +import wasmZstdReadTransformNode from "./wasm-zstd-read-transform-node.js"; +export { wasmZstdReadTransformNode }; -import wasmReadTransformNode from './wasm-read-transform-node.js' -export { wasmReadTransformNode } +import WasmZstdWriteTransformNodeResult from "./wasm-zstd-write-transform-node-result.js"; +export type { WasmZstdWriteTransformNodeResult }; +import WasmZstdWriteTransformNodeOptions from "./wasm-zstd-write-transform-node-options.js"; +export type { WasmZstdWriteTransformNodeOptions }; -import WasmWriteTransformNodeResult from './wasm-write-transform-node-result.js' -export type { WasmWriteTransformNodeResult } - -import WasmWriteTransformNodeOptions from './wasm-write-transform-node-options.js' -export type { WasmWriteTransformNodeOptions } - -import wasmWriteTransformNode from './wasm-write-transform-node.js' -export { wasmWriteTransformNode } - - -import WasmZstdReadTransformNodeResult from './wasm-zstd-read-transform-node-result.js' -export type { WasmZstdReadTransformNodeResult } - -import WasmZstdReadTransformNodeOptions from './wasm-zstd-read-transform-node-options.js' -export type { WasmZstdReadTransformNodeOptions } - -import wasmZstdReadTransformNode from './wasm-zstd-read-transform-node.js' -export { wasmZstdReadTransformNode } - - -import WasmZstdWriteTransformNodeResult from './wasm-zstd-write-transform-node-result.js' -export type { WasmZstdWriteTransformNodeResult } - -import WasmZstdWriteTransformNodeOptions from './wasm-zstd-write-transform-node-options.js' -export type { WasmZstdWriteTransformNodeOptions } - -import wasmZstdWriteTransformNode from './wasm-zstd-write-transform-node.js' -export { wasmZstdWriteTransformNode } +import wasmZstdWriteTransformNode from "./wasm-zstd-write-transform-node.js"; +export { wasmZstdWriteTransformNode }; diff --git a/packages/transform-io/typescript/src/mime-to-transform-io.ts b/packages/transform-io/typescript/src/mime-to-transform-io.ts new file mode 100644 index 000000000..4941417ef --- /dev/null +++ b/packages/transform-io/typescript/src/mime-to-transform-io.ts @@ -0,0 +1,3 @@ +const mimeToTransformIo = new Map([]); + +export default mimeToTransformIo; diff --git a/packages/transform-io/typescript/src/read-transform-node.ts b/packages/transform-io/typescript/src/read-transform-node.ts new file mode 100644 index 000000000..33b80e677 --- /dev/null +++ b/packages/transform-io/typescript/src/read-transform-node.ts @@ -0,0 +1,75 @@ +import path from "path"; +import mime from "mime-types"; + +import { TransformList, getFileExtension } from "itk-wasm"; + +import mimeToTransformIo from "./mime-to-transform-io.js"; +import extensionToTransformIo from "./extension-to-transform-io.js"; +import transformIoIndexNode from "./transform-io-index-node.js"; + +import ReadTransformOptions from "./read-transform-options.js"; + +interface ReaderResult { + couldRead: boolean; + transform: TransformList; +} +interface ReaderOptions { + /** Use float for the parameters value type. The default is double. */ + floatParameters?: boolean; +} +type Reader = ( + serializedTransform: string, + options: ReaderOptions +) => Promise; + +/** + * Read a transform file format and convert it to the ITK-Wasm file format + * + * @param {string} serializedTransform - Path to input transform serialized in the file format + * @param {ReadTransformOptions} options - options to set the transform parameters type + * + * @returns {Promise} - TransformList result + */ +async function readTransformNode( + serializedTransform: string, + options: ReadTransformOptions = {} +): Promise { + const absoluteFilePath = path.resolve(serializedTransform); + const mimeType = mime.lookup(absoluteFilePath); + const extension = getFileExtension(absoluteFilePath); + + let io = null; + if (mimeType && mimeToTransformIo.has(mimeType)) { + io = mimeToTransformIo.get(mimeType); + } else if (extensionToTransformIo.has(extension)) { + io = extensionToTransformIo.get(extension); + } else { + for (const readerWriter of transformIoIndexNode.values()) { + if (readerWriter[0] !== null) { + let { couldRead, transform } = await (readerWriter[0] as Reader)( + absoluteFilePath, + { floatParameters: options.floatParameters } + ); + if (couldRead) { + return transform; + } + } + } + } + if (io === null) { + throw Error("Could not find IO for: " + absoluteFilePath); + } + const readerWriter = transformIoIndexNode.get(io as string); + + const reader = (readerWriter as Array)[0]; + let { couldRead, transform } = await reader(absoluteFilePath, { + floatParameters: options.floatParameters, + }); + if (!couldRead) { + throw Error("Could not read: " + absoluteFilePath); + } + + return transform; +} + +export default readTransformNode; diff --git a/packages/transform-io/typescript/src/read-transform-options.ts b/packages/transform-io/typescript/src/read-transform-options.ts new file mode 100644 index 000000000..735998df4 --- /dev/null +++ b/packages/transform-io/typescript/src/read-transform-options.ts @@ -0,0 +1,8 @@ +import { WorkerPoolFunctionOption } from "itk-wasm"; + +interface ReadTransformOptions extends WorkerPoolFunctionOption { + /** Use float for the parameters value type. The default is double. */ + floatParameters?: boolean; +} + +export default ReadTransformOptions; diff --git a/packages/transform-io/typescript/src/transform-io-index-node.ts b/packages/transform-io/typescript/src/transform-io-index-node.ts new file mode 100644 index 000000000..fe7ab9b96 --- /dev/null +++ b/packages/transform-io/typescript/src/transform-io-index-node.ts @@ -0,0 +1,23 @@ +import hdf5ReadTransformNode from "./hdf5-read-transform-node.js"; +import hdf5WriteTransformNode from "./hdf5-write-transform-node.js"; +import matReadTransformNode from "./mat-read-transform-node.js"; +import matWriteTransformNode from "./mat-write-transform-node.js"; +import mncReadTransformNode from "./mnc-read-transform-node.js"; +import mncWriteTransformNode from "./mnc-write-transform-node.js"; +import txtReadTransformNode from "./txt-read-transform-node.js"; +import txtWriteTransformNode from "./txt-write-transform-node.js"; +import wasmReadTransformNode from "./wasm-read-transform-node.js"; +import wasmWriteTransformNode from "./wasm-write-transform-node.js"; +import wasmZstdReadTransformNode from "./wasm-zstd-read-transform-node.js"; +import wasmZstdWriteTransformNode from "./wasm-zstd-write-transform-node.js"; + +const meshIoIndexNode = new Map([ + ["hdf5", [hdf5ReadTransformNode, hdf5WriteTransformNode]], + ["mat", [matReadTransformNode, matWriteTransformNode]], + ["mnc", [mncReadTransformNode, mncWriteTransformNode]], + ["txt", [txtReadTransformNode, txtWriteTransformNode]], + ["wasm", [wasmReadTransformNode, wasmWriteTransformNode]], + ["wasmZstd", [wasmZstdReadTransformNode, wasmZstdWriteTransformNode]], +]); + +export default meshIoIndexNode; diff --git a/packages/transform-io/typescript/src/write-transform-node.ts b/packages/transform-io/typescript/src/write-transform-node.ts new file mode 100644 index 000000000..84b7c2509 --- /dev/null +++ b/packages/transform-io/typescript/src/write-transform-node.ts @@ -0,0 +1,82 @@ +import path from "path"; + +import { TransformList, getFileExtension } from "itk-wasm"; + +import mimeToTransformIo from "./mime-to-transform-io.js"; +import extensionToTransformIo from "./extension-to-transform-io.js"; +import transformIoIndexNode from "./transform-io-index-node.js"; + +import WriteTransformOptions from "./write-transform-options.js"; + +interface WriterOptions { + useCompression?: boolean; + floatParameters?: boolean; +} +interface WriterResult { + couldWrite: boolean; +} +type Writer = ( + transform: TransformList, + serializedTransform: string, + options: WriterOptions +) => Promise; + +/** + * Write a transform to a serialized file format and from an the itk-wasm Transform + * + * @param {Transform} transform - Input transform + * @param {string} serializedTransform - Output transform serialized in the file format. + * @param {WriteTransformOptions} options - options object + * + * @returns {void} - result object + */ +async function writeTransformNode( + transform: TransformList, + serializedTransform: string, + options: WriteTransformOptions = {} +): Promise { + const absoluteFilePath = path.resolve(serializedTransform); + const mimeType = options.mimeType; + const extension = getFileExtension(absoluteFilePath); + + let inputTransform = transform; + + let io = null; + if (typeof mimeType !== "undefined" && mimeToTransformIo.has(mimeType)) { + io = mimeToTransformIo.get(mimeType); + } else if (extensionToTransformIo.has(extension)) { + io = extensionToTransformIo.get(extension); + } else { + for (const readerWriter of transformIoIndexNode.values()) { + if (readerWriter[1] !== null) { + let { couldWrite } = await (readerWriter[1] as Writer)( + inputTransform, + absoluteFilePath, + { + useCompression: options.useCompression, + floatParameters: options.floatParameters, + } + ); + if (couldWrite) { + return; + } + } + } + } + if (io === null) { + throw Error("Could not find IO for: " + absoluteFilePath); + } + const readerWriter = transformIoIndexNode.get(io as string); + + const writer = (readerWriter as Array)[1]; + console.log("writer", writer); + console.log("inputTransform", inputTransform); + let { couldWrite } = await writer(inputTransform, absoluteFilePath, { + useCompression: options.useCompression, + }); + if (!couldWrite) { + throw Error("Could not write: " + absoluteFilePath); + } +} + +export default writeTransformNode; diff --git a/packages/transform-io/typescript/src/write-transform-options.ts b/packages/transform-io/typescript/src/write-transform-options.ts new file mode 100644 index 000000000..4d975c08f --- /dev/null +++ b/packages/transform-io/typescript/src/write-transform-options.ts @@ -0,0 +1,14 @@ +import { WorkerPoolFunctionOption } from "itk-wasm"; + +interface WriteTransformOptions extends WorkerPoolFunctionOption { + /** Use compression when writing the mesh if the IO formt supports it. */ + useCompression?: boolean; + + /** Use float for the parameter value type. The default is double. */ + floatParameters?: boolean; + + /** Mime type of the output mesh file. */ + mimeType?: string; +} + +export default WriteTransformOptions; diff --git a/packages/transform-io/typescript/test/node/hdf5-test.js b/packages/transform-io/typescript/test/node/hdf5-test.js index d4945d180..559a77494 100644 --- a/packages/transform-io/typescript/test/node/hdf5-test.js +++ b/packages/transform-io/typescript/test/node/hdf5-test.js @@ -1,11 +1,22 @@ import test from "ava"; import path from "path"; -import { hdf5ReadTransformNode } from "../../dist/index-node.js"; +import { + hdf5ReadTransformNode, + hdf5WriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.h5"); +const testOutputFilePath = path.join( + testOutputPath, + "hdf5-test-write-LinearTransform.h5" +); test("Test reading a HDF5 file", async (t) => { const { couldRead, transform } = await hdf5ReadTransformNode( @@ -14,3 +25,21 @@ test("Test reading a HDF5 file", async (t) => { t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing a HDF5 transform file", async (t) => { + const { couldRead, transform } = await hdf5ReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await hdf5WriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await hdf5ReadTransformNode(testOutputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +}); diff --git a/packages/transform-io/typescript/test/node/iwt-test.js b/packages/transform-io/typescript/test/node/iwt-test.js index 43575c466..4c4a288ee 100644 --- a/packages/transform-io/typescript/test/node/iwt-test.js +++ b/packages/transform-io/typescript/test/node/iwt-test.js @@ -1,11 +1,22 @@ import test from "ava"; import path from "path"; -import { wasmReadTransformNode } from "../../dist/index-node.js"; +import { + wasmReadTransformNode, + wasmWriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.iwt.cbor"); +const testOutputFilePath = path.join( + testOutputPath, + "wasm-test-write-LinearTransform.iwt.cbor" +); test("Test reading a .iwt.cbor file", async (t) => { const { couldRead, transform } = await wasmReadTransformNode( @@ -14,3 +25,21 @@ test("Test reading a .iwt.cbor file", async (t) => { t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing .iwt.cbor transform file", async (t) => { + const { couldRead, transform } = await wasmReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await wasmWriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await wasmReadTransformNode(testOutputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +}); diff --git a/packages/transform-io/typescript/test/node/mat-test.js b/packages/transform-io/typescript/test/node/mat-test.js index 105f4082d..9219d13f6 100644 --- a/packages/transform-io/typescript/test/node/mat-test.js +++ b/packages/transform-io/typescript/test/node/mat-test.js @@ -1,11 +1,22 @@ import test from "ava"; import path from "path"; -import { matReadTransformNode } from "../../dist/index-node.js"; +import { + matReadTransformNode, + matWriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.mat"); +const testOutputFilePath = path.join( + testOutputPath, + "mat-test-write-LinearTransform.mat" +); test("Test reading a .mat file", async (t) => { const { couldRead, transform } = await matReadTransformNode( @@ -14,3 +25,21 @@ test("Test reading a .mat file", async (t) => { t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing .mat transform file", async (t) => { + const { couldRead, transform } = await matReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await matWriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await matReadTransformNode(testOutputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +}); diff --git a/packages/transform-io/typescript/test/node/read-transform-node-test.js b/packages/transform-io/typescript/test/node/read-transform-node-test.js new file mode 100644 index 000000000..d5bdc5920 --- /dev/null +++ b/packages/transform-io/typescript/test/node/read-transform-node-test.js @@ -0,0 +1,12 @@ +import test from "ava"; +import path from "path"; + +import { readTransformNode } from "../../dist/index-node.js"; +import { testInputPath, verifyTestLinearTransform } from "./common.js"; + +const testInputFilePath = path.join(testInputPath, "LinearTransform.mat"); + +test("readTransformNode reads a file path given on the local filesystem", async (t) => { + const transform = await readTransformNode(testInputFilePath); + verifyTestLinearTransform(t, transform); +}); diff --git a/packages/transform-io/typescript/test/node/txt-test.js b/packages/transform-io/typescript/test/node/txt-test.js index 7f2eab445..2c3b0755a 100644 --- a/packages/transform-io/typescript/test/node/txt-test.js +++ b/packages/transform-io/typescript/test/node/txt-test.js @@ -1,16 +1,45 @@ import test from "ava"; import path from "path"; -import { txtReadTransformNode } from "../../dist/index-node.js"; +import { + txtReadTransformNode, + txtWriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.txt"); +const testOutputFilePath = path.join( + testOutputPath, + "txt-test-write-LinearTransform.txt" +); -test("Test reading a Insight Legacy TXT transform file", async (t) => { +test("Test reading an Insight Legacy TXT transform file", async (t) => { const { couldRead, transform } = await txtReadTransformNode( testInputFilePath ); t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing an Insight Legacy TXT transform file", async (t) => { + const { couldRead, transform } = await txtReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await txtWriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await txtReadTransformNode(testOutputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 30dca980a..7d35c7ec9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -768,6 +768,9 @@ importers: itk-wasm: specifier: workspace:^ version: link:../../core/typescript/itk-wasm + mime-types: + specifier: ^2.1.35 + version: 2.1.35 devDependencies: '@itk-wasm/demo-app': specifier: workspace:* @@ -775,6 +778,9 @@ importers: '@itk-wasm/transform-io-build': specifier: workspace:* version: link:.. + '@types/mime-types': + specifier: ^2.1.4 + version: 2.1.4 '@types/node': specifier: ^20.2.5 version: 20.12.10 @@ -2580,6 +2586,7 @@ packages: acorn-import-assertions@1.9.0: resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==} + deprecated: package has been renamed to acorn-import-attributes peerDependencies: acorn: ^8 diff --git a/src/itkWasmTransformIO.cxx b/src/itkWasmTransformIO.cxx index 02493968b..e244d5ea2 100644 --- a/src/itkWasmTransformIO.cxx +++ b/src/itkWasmTransformIO.cxx @@ -28,6 +28,7 @@ #include "itkWasmIOCommon.h" #include "itktransformParameterizationString.h" #include "itkMetaDataDictionaryJSON.h" +#include "itkTransformFactoryBase.h" #include "itkMetaDataObject.h" #include "itkIOCommon.h" @@ -460,7 +461,7 @@ WasmTransformIOTemplate::GetJSON(bool inMemory) -> Transfo template void -WasmTransformIOTemplate::SetJSON(const TransformListJSON & json) +WasmTransformIOTemplate::SetJSON(const TransformListJSON & json, bool inMemory) { // iterate over the JSON and set the transform list TransformListType transformList; @@ -496,13 +497,31 @@ WasmTransformIOTemplate::SetJSON(const TransformListJSON & TransformPointer transform; this->CreateTransform(transform, transformType); transform->SetObjectName(transformJSON.name); + // todo: ITK 5.4.1 + // transform->SetInputSpaceName(transformJSON.inputSpaceName); + // transform->SetOutputSpaceName(transformJSON.outputSpaceName); auto dictionary = transform->GetMetaDataDictionary(); jsonToMetaDataDictionary(transformJSON.metadata, dictionary); - // todo: ITK 5.4.1 - // transform->SetInputSpaceName(transformJSON.inputSpaceName); - // transform->SetOutputSpaceName(transformJSON.outputSpaceName); + if (inMemory) + { + if (transformJSON.transformType.transformParameterization == JSONTransformParameterizationEnum::Composite) + { + continue; + } + + using ParametersValueType = TParametersValueType; + + FixedParametersValueType * fixedPtr = reinterpret_cast< FixedParametersValueType * >( std::strtoull(transformJSON.fixedParameters.substr(35).c_str(), nullptr, 10) ); + transform->CopyInFixedParameters(fixedPtr, fixedPtr + transformJSON.numberOfFixedParameters); + ParametersValueType * paramsPtr = reinterpret_cast< ParametersValueType * >( std::strtoull(transformJSON.parameters.substr(35).c_str(), nullptr, 10) ); + transform->CopyInParameters(paramsPtr, paramsPtr + transformJSON.numberOfParameters); + + auto dictionary = transform->GetMetaDataDictionary(); + jsonToMetaDataDictionary(transformJSON.metadata, dictionary); + } + this->GetReadTransformList().push_back(transform); } }