Reading files from a CD using HTML5, webkitdirectory takes longer than reading local files

I have a web application that allows a user to upload DICOM and Non-DICOM files to their account. I use JavaScript , HTML5 , Webkitdirectory , Chrome and Datatable to populate the selected files in the user interface. The problem I am facing is

When selecting files from their local machine, the following code works quite quickly, and the selected files are populated directly in the user interface, but when choosing the same number of files from the CD, it takes time to display in the user interface. Here is an example -

For a CD with 20 DICOM + 2 studies without DICOM and about 2241 images, filling out the list for the first time takes 5-6 minutes in the user interface. If I try to select the same folder on the CD, the list will be filled roughly 60 seconds if it was populated once before during the same session.

But if I use the same set of files from the local machine, it takes about 6-7 seconds to fill in the user interface.

Here is my code that runs for each DICOM file -

var fileReader = new FileReader(); fileReader.onload = function(evt){ console.log("Completed Reading"); var arrayBuffer = fileReader.result; var byteArray = new Uint8Array(arrayBuffer); _parseDicom(byteArray); try { if (fileReader.readyState !== 2) { fileReader.abort(); } } catch (err) { console.log('error occured: '+err); } } var blob = f.slice(0, 50000); console.log("Starting to Read"); fileReader.readAsArrayBuffer(blob); 

After analyzing the problem I encountered,

  • The main thing that I think of is that the OS takes time to install a CD into its memory, since it is an external drive. It takes less time if we get a second time because the contents of the CD are already installed.

  • The time between "Starting Reading" and "Completed Reading" is relatively longer when reading files from a CD than on the local machine.

  • I also tried looking for the DICOMDIR file , which is an index of all the training files contained on the disk, and is included for this very reason: to avoid lengthy disk scans. But I did not find any standard or way to parse the DICOMDIR file in JavaScript

Is there a way to reduce the time taken to read files from a CD?

UPDATE -

Now I can get the DICOMDIR file structure in JavaScript using dicomParser - https://github.com/chafey/dicomParser

 var fr = new FileReader(); fr.onload = function(evt){ var byteArray = new Uint8Array(fr.result); try { var dataSet = dicomParser.parseDicom(byteArray); _searchDicom(dataSet, f); } catch (err) { if (typeof err.dataSet != 'undefined') { _searchDicom(err.dataSet, f); } } } var blob = f.slice(0, 1000000); fr.readAsArrayBuffer(blob); function _searchDicom(dataset,f) { var data = dataset.elements.x00041220.items; if(data) { data.forEach(function (e) { if (e.dataSet.string('x00041430') === 'PATIENT') { console.log("Patient Name - "+e.dataSet.string('x00100010')); } else if (e.dataSet.string('x00041430') === 'STUDY') {} else if (e.dataSet.string('x00041430') === 'SERIES') {} else if (e.dataSet.string('x00041430') === 'IMAGE') {} }); } } 

The structure of the object is similar to the structure displayed on - https://rawgit.com/chafey/dicomParser/master/examples/dumpWithDataDictionary/index.html
when we upload any DICOMDIR file.

The problem here is that I cannot collect all patients , studies , series or images at once. The only solution I found was to repeat and check if the object is a patient , study , series or image

Is there any method / standard for a better search?

+5
source share

Source: https://habr.com/ru/post/1271316/


All Articles