Why does a specific nifti image cannot be unzipped when using niftiread? Tmpdir needs write permission and sufficient free space.

19 visualizzazioni (ultimi 30 giorni)
Hi,
I was using niftiread to load a .nii.gz file. It worked fine perfectly fine for other files except this one. It showed error message
"Error using images.internal.nifti.niftiFile/getUncompressedFileName (line 136)
Cannot unzip file. tempdir needs write permissions and sufficient free space.
Error in images.internal.nifti.niftiFile (line 45)
[filename, self.TempfileCleaners, ~] = self.getUncompressedFileName(firstFile);
Error in niftiread (line 66)
NF = images.internal.nifti.niftiFile(varargin{:});"
I used MATLAB2021b.
I had a few attempts:
1. Double checked the path and the file name. They are correct.
2. Use setenv() to change tempdir to my home directory, which I am sure I have the write permission and enough space. But it did not solve this problem.
3. I am able to open this image using image viewing tool (MRIcron, etc). But I cannot unzip it manually using 7zip.
This issue happened before, and I cannot figure it out all the times. If anyone can help me with it, I would highly appreciate it!

Risposta accettata

Neha
Neha il 14 Nov 2023
Hi Tongyao,
I understand that you are facing an error while using the "niftiread" function while loading a .nii.gz file. Since you have already confirmed that the file name and path are correct and that there are no permission or space related issues, you can try implementing the solution explained in the comments for this MATLAB Answer:
Hope this helps!

Più risposte (1)

Ricardo Alonso
Ricardo Alonso il 6 Apr 2024
Hello. This just happened to me.
In my case it was because the file wasn't really a compressed one, but uncompressed (.nii) that I copied with the wrong extension (.nii.gz).
Change its extension to .nii and try again.
I suspect this is your case because of your 3d point.

Community Treasure Hunt

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

Start Hunting!

Translated by