router.get(‘/studies/:studiesId/series/:seriesID/instances/:instancesID/frames/:frames’, (req, res) => {
var studiesId = req.params.studiesId
var seriesID = req.params.seriesID
var instancesID = req.params.instancesID
var frames = req.params.frames
var fs = require(‘fs’)
var dicomParser = require(‘dicom-parser’);
var fs = require(‘fs’)
var data = fs.readFileSync(“E:\bangladesh\Mams\MAMS_India_Today_Image\Dicom_files\11883014\DICOM\PN0\STUDY1\SERIES1\IMAGE1”)
try
{
// Allow raw files
const options = { TransferSyntaxUID: '1.2.840.10008.1.2' };
// Parse the byte array to get a DataSet object that has the parsed contents
var dataSet = dicomParser.parseDicom(data, options);
// access a string element
var studyInstanceUid = dataSet.string('x0020000d');
console.log("studyInstanceUid",studyInstanceUid);
// get the pixel data element (contains the offset and length of the data)
var pixelDataElement = dataSet.elements.x7fe00010 || dataSet.elements.x7fe00008 || dataSet.elements.x7fe00009;
var pixelData = new Uint8Array(dataSet.byteArray.buffer, pixelDataElement.dataOffset, pixelDataElement.length / 2);
// var pixelData = new Uint8Array(dataSet.byteArray.buffer, pixelDataElement.dataOffset, pixelDataElement.length / 2);
// var pixelData = new Uint16Array(dataSet.byteArray.buffer, pixelDataElement.dataOffset, pixelDataElement.length / 2);
pixelData = `
${’ --6b4d1648-ee27-472d-9951-4192b5abff74’}
${‘Content-Location: E:\bangladesh\Mams\MAMS_India_Today_Image\Dicom_files\11883014\DICOM\PN0\STUDY1\SERIES1\IMAGE1’}
${‘Content-ID: d615df89-a84b-4569-96fd-b582fd026ca8@resteasy-multipart’}
${‘Content-Type: application/octet-stream’}
${pixelData}
${’ --6b4d1648-ee27-472d-9951-4192b5abff74–'}`
res.send(pixelData)
}
catch(ex)
{
console.log(‘Error parsing byte stream’, ex);
}