niftiwrite is 'slow'

3 Ansichten (letzte 30 Tage)
Matt K.
Matt K. am 15 Apr. 2024
Beantwortet: Rupesh am 30 Apr. 2024
Hi,
I am repeatedly writing out a 200 MB image (512x512x375 uint16) using niftiwrite and I find that niftiwrite becomes slower once I get to the ~12th file that's being written.
Writing first 1-11 files take ~0.06 seconds, but the 12th and higher files take ~1.5 to 2.3 seconds. (confirmed via tic/toc)
I checked my win10 taskmanager and there's no noticible change in CPU or RAM, and I also have plenty of space on my HDD.
I thought that simply creating the output file took time, so I made empty files before writing the nifti data, but this had no effect.
Does anyone have any ideas or suggestions?
Thank you,
Matt
  4 Kommentare
Matt K.
Matt K. am 15 Apr. 2024
After checking with colleagues...I think it's specific to my PC and not niftiwrite
Cris LaPierre
Cris LaPierre am 15 Apr. 2024
Thank you. They may still follow up for more details.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rupesh
Rupesh am 30 Apr. 2024
Hi Matt,
I understand that you're facing a significant slowdown when writing large “NIfTI” files after the initial few files even after having no system resource constraints. You can considerer some pinpointed ideas to address the specific aspects of your problem which contributes towards slowdown in file operations.
  • Optimize File I/O Operations: Ensure the target directory for your “NIfTI” files is not on MATLAB's path to prevent MATLAB from unnecessarily indexing these files which can potentially slowing down file writing. You can also use clear “mex” to clear the JIT compilation cache, which could hold onto state that negatively impacts performance during repetitive file writing tasks.
  • Compression Considerations: If you're using niftiwrite with compression enabled, consider disabling it to see if performance improves. Compression can significantly increase CPU load and writing time, especially for large files. If compression is necessary, experiment with different levels of compression to find a balance between file size and writing speed.
  • Disk Defragmentation: For HDD users, regularly defragment your disk to improve read/write efficiency. Use MATLAB's built-in profiler (profile on; and profile viewer) to get more detailed insights into where exactly the slowdown occurs. This might help pinpoint whether the issue is with file I/O, memory management, or something else.
By focusing on the above scenarios, you may be able to solve the slowdown experienced during the writing of large “NIfTI” files and improve the overall efficiency of your file I/O operations in MATLAB. You can also refer to below documents for Optimised IO operations cases mentioned above. https://in.mathworks.com/help/coder/ug/speed-up-mex-generation-by-using-jit-compilation.html

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by