XMLImagedatareader speed up VTI file loading

when I use the XMLImagedatareader to load my vti file that I converted, it wastes one minute. But when I load the VTI file downloaded from the vtkjs official website, like head-binary-zlib.vti ,it just need 5s.
How to preprocess VTI files to speed up reading speed?
Is there a way to speed up the read conversion VTI?
Looking forward to your reply.

How large is your VTI file? What is the dimensions of your dataset? If you data is quite large, you can consider downsampling as one possible approach.

Also, are you timing your download speed plus running the reader, or are you just timing the reader? head-binary-zlib.vti has never taken 5 seconds to read, but it may take 5 seconds to download depending on your network speed.

We downloaded the VTI file to local, and read it as shown in the picture.
But it took me a long time to load the page completely.
The spine.vti file just 900KB. And head-binary-zlib.vti 8.7MB.
Why is the spine.vti file loading more slowly?

const reader = vtkXMLImageDataReader.newInstance({ fetchGzip: true });

const writer = vtkXMLImageDataWriter.newInstance();

const writerReader = vtkXMLImageDataReader.newInstance();

.setUrl(spine.vti, { loadData: true })
.then(() => {
const fileContents = writer.write(reader.getOutputData());

    // Try to read it back.
    const textEncoder = new TextEncoder();

If it’s your dataset that’s causing issues, it would be helpful if you upload your dataset for me to look at, if you are allowed to. If not, I would recommend you go to the VolumeViewer, open chrome devtools and run the performance profiler, load your dataset, then stop the profiler and save and upload the performance trace here.

spine.vti (931.0 KB)

this is my spine.vti

when I use VoluneViewer ,it just takes 5 seconds.
But when turn to XMLImagedatareader, it’s too slow.
I have already upload my dataset for you.
Thank you !

Ah, so it appears that your dataset, when uncompressed, has roughly 270 million points, hence the slower parsing. As for why you’re seeing really slow performance, is it because you’re timing the XMLImageDataWriter → XMLImageDataReader pipeline? You shouldn’t need to have a writer. VolumeViewer just uses XMLImageDataReader underneath. I would recommend checking out the source code for VolumeViewer and using that to inform the flow of your code.