javascriptdicompapaya

How to display a specific dicom image (Papaya)?


I am using the rii-mango/Papaya to display dicom-files. I upload a folder containing 243 dicom files. It always starts in the middle of the files (here image 121) but I want to start with image 243. Is there a function to display a specific image? I tried:

papayaContainers[0].preferences.viewer.currentSlice = 243;

But it does not work (nothing changes).


Solution

  • You can specify a coordinate parameter. The coordinate is in image indices. You'd need to know the image dimensions beforehand though.

    params["coordinate"] = [0, 0, 0];
    

    Another way would be to use the loadingComplete callback:

    params["loadingComplete"] = function() {
        var viewer = papayaContainers[0].viewer;
        var dims = viewer.volume.header.imageDimensions;
    
        // position coordinate centered on last slice (assuming axial slices)
        var coord = new papaya.core.Coordinate(
            Math.floor(dims.xDim / 2), 
            Math.floor(dims.yDim / 2), 
            dims.zDim - 1);
        viewer.gotoCoordinate(coord);
    };