// Generated file. To retain edits, remove this comment.
import { InterfaceTypes, runPipelineNode } from 'itk-wasm';
import path from 'path';
import { fileURLToPath } from 'url';
/**
 * Read a DICOM image series and return the associated image volume
 *
 * @param {ReadImageDicomFileSeriesNodeOptions} options - options object
 *
 * @returns {Promise<ReadImageDicomFileSeriesNodeResult>} - result object
 */
async function readImageDicomFileSeriesNode(options = { inputImages: [], }) {
    const mountDirs = new Set();
    const desiredOutputs = [
        { type: InterfaceTypes.Image },
        { type: InterfaceTypes.JsonCompatible },
    ];
    const inputs = [];
    const args = [];
    // Inputs
    // Outputs
    const outputImageName = '0';
    args.push(outputImageName);
    const sortedFilenamesName = '1';
    args.push(sortedFilenamesName);
    // Options
    args.push('--memory-io');
    if (options.inputImages) {
        if (options.inputImages.length < 1) {
            throw new Error('"input-images" option must have a length > 1');
        }
        args.push('--input-images');
        options.inputImages.forEach((value) => {
            mountDirs.add(path.dirname(value));
            args.push(value);
        });
    }
    if (options.singleSortedSeries) {
        options.singleSortedSeries && args.push('--single-sorted-series');
    }
    const pipelinePath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'pipelines', 'read-image-dicom-file-series');
    const { returnValue, stderr, outputs } = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs, mountDirs);
    if (returnValue !== 0 && stderr !== "") {
        throw new Error(stderr);
    }
    const result = {
        outputImage: outputs[0]?.data,
        sortedFilenames: outputs[1]?.data,
    };
    return result;
}
export default readImageDicomFileSeriesNode;
//# sourceMappingURL=read-image-dicom-file-series-node.js.map