How to use the loglevelnext.error function in loglevelnext

To help you get started, we’ve selected a few loglevelnext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dcmjs-org / dcmjs / src / utilities / compression / rleSingleSamplePerPixel.js View on Github external
function decodeFrame(rleEncodedFrame, pixelData) {
    // Check HEADER:
    const header = new Uint32Array(rleEncodedFrame, 0, 16);

    if (header[0] !== 1) {
        log.error(
            `rleSingleSamplePerPixel only supports fragments with single Byte Segments (for rle encoded segmentation data) at the current time. This rleEncodedFrame has ${
                header[0]
            } Byte Segments.`
        );

        return;
    }

    if (header[1] !== 64) {
        log.error(
            "Data offset of Byte Segment 1 should be 64 bytes, this rle fragment is encoded incorrectly."
        );

        return;
    }
github dcmjs-org / dcmjs / src / DicomMetaDictionary.js View on Github external
if (entry) {
                let dataValue = dataset[naturalName];
                if (dataValue === undefined) {
                    // handle the case where it was deleted from the object but is in keys
                    return;
                }
                // process this one entry
                var dataItem = {
                    vr: entry.vr,
                    Value: dataset[naturalName]
                };
                if (entry.vr == "ox") {
                    if (dataset._vrMap && dataset._vrMap[naturalName]) {
                        dataItem.vr = dataset._vrMap[naturalName];
                    } else {
                        log.error(
                            "No value representation given for",
                            naturalName
                        );
                    }
                }

                dataItem.Value = DicomMetaDictionary.denaturalizeValue(
                    dataItem.Value
                );

                if (entry.vr == "SQ") {
                    var unnaturalValues = [];
                    for (
                        let datasetIndex = 0;
                        datasetIndex < dataItem.Value.length;
                        datasetIndex++
github dcmjs-org / dcmjs / src / utilities / compression / rleSingleSamplePerPixel.js View on Github external
function decodeFrame(rleEncodedFrame, pixelData) {
    // Check HEADER:
    const header = new Uint32Array(rleEncodedFrame, 0, 16);

    if (header[0] !== 1) {
        log.error(
            `rleSingleSamplePerPixel only supports fragments with single Byte Segments (for rle encoded segmentation data) at the current time. This rleEncodedFrame has ${
                header[0]
            } Byte Segments.`
        );

        return;
    }

    if (header[1] !== 64) {
        log.error(
            "Data offset of Byte Segment 1 should be 64 bytes, this rle fragment is encoded incorrectly."
        );

        return;
    }

    const uInt8Frame = new Uint8Array(rleEncodedFrame, 64);

    let pixelDataIndex = 0;
    let i = 0;

    while (pixelDataIndex < pixelData.length) {
        const byteValue = uInt8Frame[i];

        if (byteValue === undefined) {
            break;
github dcmjs-org / dcmjs / src / normalizers.js View on Github external
normalizeMultiframe() {
        let ds = this.dataset;
        if (!ds.NumberOfFrames) {
            log.error("Missing number or frames not supported");
            return;
        }
        if (Number(ds.NumberOfFrames) === 1) {
            log.error(
                "Single frame instance of multiframe class not supported"
            );
            return;
        }
        if (!ds.PixelRepresentation) {
            // Required tag: guess signed
            ds.PixelRepresentation = 1;
        }
        if (!ds.StudyID || ds.StudyID === "") {
            // Required tag: fill in if needed
            ds.StudyID = "No Study ID";
        }

        let validLateralities = ["R", "L"];
        if (validLateralities.indexOf(ds.Laterality) === -1) {
            delete ds.Laterality;
github dcmjs-org / dcmjs / src / normalizers.js View on Github external
this.datasets.forEach(function(dataset) {
            let position = dataset.ImagePositionPatient.slice();
            let positionVector = ImageNormalizer.vec3Subtract(
                position,
                referencePosition
            );
            let distance = ImageNormalizer.vec3Dot(positionVector, scanAxis);
            distanceDatasetPairs.push([distance, dataset]);
        });
        distanceDatasetPairs.sort(function(a, b) {
            return b[0] - a[0];
        });

        // assign array buffers
        if (ds.BitsAllocated !== 16) {
            log.error(
                "Only works with 16 bit data, not " +
                    String(this.dataset.BitsAllocated)
            );
        }
        if (referenceDataset._vrMap && !referenceDataset._vrMap.PixelData) {
            log.warn("No vr map given for pixel data, using OW");
            ds._vrMap = { PixelData: "OW" };
        } else {
            ds._vrMap = { PixelData: referenceDataset._vrMap.PixelData };
        }
        let frameSize = referenceDataset.PixelData.byteLength;
        ds.PixelData = new ArrayBuffer(ds.NumberOfFrames * frameSize);
        let frame = 0;
        distanceDatasetPairs.forEach(function(pair) {
            let dataset = pair[1];
            let pixels = new Uint16Array(dataset.PixelData);
github dcmjs-org / dcmjs / src / normalizers.js View on Github external
datasets.forEach(function(dataset) {
            if (!dataset.SOPClassUID) {
                return undefined;
            }
            if (!sopClassUID) {
                sopClassUID = dataset.SOPClassUID;
            }
            if (dataset.SOPClassUID !== sopClassUID) {
                log.error(
                    "inconsistent sopClassUIDs: ",
                    dataset.SOPClassUID,
                    sopClassUID
                );
                return undefined;
            }
        });
        return sopClassUID;
github dcmjs-org / dcmjs / src / normalizers.js View on Github external
distanceDatasetPairs.forEach(function(pair) {
            let dataset = pair[1];
            let pixels = new Uint16Array(dataset.PixelData);
            let frameView = new Uint16Array(
                ds.PixelData,
                frame * frameSize,
                frameSize / 2
            );
            try {
                frameView.set(pixels);
            } catch (e) {
                if (e instanceof RangeError) {
                    log.error("Error inserting pixels in PixelData");
                    log.error("frameSize", frameSize);
                    log.error("NumberOfFrames", ds.NumberOfFrames);
                    log.error("pair", pair);
                    log.error(
                        "dataset PixelData size",
                        dataset.PixelData.length
                    );
                }
            }
            frame++;
        });
github dcmjs-org / dcmjs / src / normalizers.js View on Github external
static normalizeToDataset(datasets) {
        let sopClassUID = Normalizer.consistentSOPClassUIDs(datasets);
        let normalizerClass = Normalizer.normalizerForSOPClassUID(sopClassUID);

        if (!normalizerClass) {
            log.error("no normalizerClass for ", sopClassUID);
            return undefined;
        }
        let normalizer = new normalizerClass(datasets);
        normalizer.normalize();
        return normalizer.dataset;
    }
}
github dcmjs-org / dcmjs / src / ValueRepresentation.js View on Github external
read(stream, length, syntax) {
        if (this.fixed && this.maxLength) {
            if (!length) return this.defaultValue;
            if (this.maxLength != length)
                log.error(
                    "Invalid length for fixed length tag, vr " +
                        this.type +
                        ", length " +
                        this.maxLength +
                        " != " +
                        length
                );
        }
        return this.readBytes(stream, length, syntax);
    }

loglevelnext

A modern logging library for Node.js and modern browsers that provides log level mapping to the console

MPL-2.0
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis