niftiwrite is 'slow'

조회 수: 3 (최근 30일)
Matt K.
Matt K. 2024년 4월 15일
답변: Rupesh 2024년 4월 30일
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
Matt K.
Matt K. 2024년 4월 15일
After checking with colleagues...I think it's specific to my PC and not niftiwrite
Cris LaPierre
Cris LaPierre 2024년 4월 15일
Thank you. They may still follow up for more details.

댓글을 달려면 로그인하십시오.

답변 (1개)

Rupesh
Rupesh 2024년 4월 30일
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

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by