Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in saving output when is .nii.gz #1532

Closed
pietroastolfi opened this Issue Jan 11, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@pietroastolfi
Copy link

pietroastolfi commented Jan 11, 2019

Hi,

The environment in which I found this bug are:

  • Mac OS X 10.13.6 with mrtrix 3.0_RC2-82-gbb77205e
  • Ubuntu 16.04 LTS with mrtrix 3.0_RC3-96-g2c350fa9

I found a problem with some commands (mrresize and mrconvert) when the output specified is .nii.gz format.

To be specific the commands used are:

mrresize -voxel 2.5 input.nii.gz output.nii.gz

mrconvert input.mif output.nii.gz

What happens is that the commands execution proceed without failing (decompression(if needed) - computation - compression), but in the end the saved file is just 8KB whatever is the input size. By checking the file with fslinfo the header is correct. Hence, I guess that the 8KB is just the size of the header.

As additional test I tried to split the execution of the command and the gzip compression. Thus:
mrconvert input.mif output.nii
gzip output.nii
In this case the created output file is correct.

If you need some more information, let me know

@jdtournier

This comment has been minimized.

Copy link
Member

jdtournier commented Jan 11, 2019

Thanks for reporting. Unfortunately I can't reproduce on either of my systems (MSY2 on Windows 10, and Arch Linux), for either of the commits you point to. Also, if there was such a glaring issue in our code, I'd be surprised not to have heard about it before. So I'm tempted to think there's something odd about your system, but the fact that you encounter this issue on two different OS's is troubling.

Can you post the contents of your config on both of the affected systems? Maybe that might shed some light.

Also, does running with -debug reveal anything out of the ordinary? It might be a good idea to post the full output here so we can take a look.

@pietroastolfi

This comment has been minimized.

Copy link
Author

pietroastolfi commented Jan 11, 2019

I was a surprised too about this "glaring" issue. However, the fact I was sure it happened in two different computers convinced me to report it.
Anyway, I'm really sorry, but I just discovered that it didn't happen on the mac os since the shell were I had this problem was connected via ssh to the Ubuntu device. Sorry again

On mac os I've done a trial right now and I haven't encountered any problem.

I don't have the mrtrix config file in any of the systems.

The problem still alive on Ubuntu 16.04 LTS:

mrconvert -debug GM.mif ~/GM.nii.gz

mrconvert: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrconvert: [DEBUG] No config file found at "/home/pietro/.mrtrix.conf"
mrconvert: [INFO] opening image "GM.mif"...
mrconvert: [DEBUG] reading key/value file "GM.mif"...
mrconvert: [DEBUG] sanitising image information...
mrconvert: [INFO] image "GM.mif" opened with dimensions 145x174x145x1, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mrconvert: [DEBUG] memory-mapping file "GM.mif"...
mrconvert: [DEBUG] file "GM.mif" mapped at 0x7f1f1e8a5000, size 14633400 (read-only)
mrconvert: [DEBUG] image "GM.mif" loaded
mrconvert: [DEBUG] image "GM.mif" initialised with strides = [ -1 145 25230 145 ], start = 144, using indirect IO
mrconvert: [INFO] creating image "/home/pietro/GM.nii.gz"...
mrconvert: [DEBUG] sanitising image information...
mrconvert: [DEBUG] creating empty file "/home/pietro/GM.nii.gz"
mrconvert: [DEBUG] sanitising image information...
mrconvert: [INFO] image "/home/pietro/GM.nii.gz" created with dimensions 145x174x145x1, voxel spacing 1.25x1.25x1.25x1, datatype Float32LE
mrconvert: [DEBUG] loading image "/home/pietro/GM.nii.gz"...
mrconvert: [DEBUG] image "/home/pietro/GM.nii.gz" loaded
mrconvert: [DEBUG] image "/home/pietro/GM.nii.gz" initialised with strides = [ -1 145 25230 3658350 ], start = 144, using indirect IO
mrconvert: [DEBUG] initialising threads...
mrconvert: [DEBUG] launching 8 threads "loop threads"...
mrconvert: [ 3%] copying from "GM.mif" to "/home/pietro/GM.nii.gz"...
mrconvert: [DEBUG] waiting for completion of threads "loop threads"...
mrconvert: [100%] copying from "GM.mif" to "/home/pietro/GM.nii.gz"...
mrconvert: [DEBUG] threads "loop threads" completed OK
mrconvert: [100%] copying from "GM.mif" to "/home/pietro/GM.nii.gz"
mrconvert: [100%] compressing image "/home/pietro/GM.nii.gz"
mrconvert: [DEBUG] image "/home/pietro/GM.nii.gz" unloaded
mrconvert: [DEBUG] unmapping file "GM.mif"
mrconvert: [DEBUG] image "GM.mif" unloaded

ll -h ~/GM.nii.gz

-rw-rw-r-- 1 pietro pietro 8.0K Jan 11 17:55 /home/pietro/GM.nii.gz

mrresize -debug -voxel 2.5 nodif_brain_mask.nii.gz ~/nodif_brain_mask_2.5mm.nii.gz

mrresize: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrresize: [DEBUG] No config file found at "/home/pietro/.mrtrix.conf"
mrresize: [INFO] opening image "nodif_brain_mask.nii.gz"...
mrresize: [DEBUG] sanitising image information...
mrresize: [DEBUG] searching for suitable phase encoding data...
mrresize: [INFO] image "nodif_brain_mask.nii.gz" opened with dimensions 145x174x145, voxel spacing 1.25x1.25x1.25, datatype Float32LE
mrresize: [DEBUG] loading image "nodif_brain_mask.nii.gz"...
mrresize: [100%] uncompressing image "nodif_brain_mask.nii.gz"
mrresize: [DEBUG] image "nodif_brain_mask.nii.gz" loaded
mrresize: [DEBUG] image "nodif_brain_mask.nii.gz" initialised with strides = [ -1 145 25230 ], start = 144, using direct IO
mrresize: [INFO] creating image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz"...
mrresize: [DEBUG] sanitising image information...
mrresize: [DEBUG] creating empty file "/home/pietro/nodif_brain_mask_2.5mm.nii.gz"
mrresize: [DEBUG] sanitising image information...
mrresize: [INFO] image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz" created with dimensions 72x87x72, voxel spacing 2.5x2.5x2.5, datatype Float32LE
mrresize: [DEBUG] loading image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz"...
mrresize: [DEBUG] image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz" loaded
mrresize: [DEBUG] image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz" initialised with strides = [ -1 72 6264 ], start = 71, using direct IO
mrresize: [INFO] using oversampling factors [ 2 2 2 ]
mrresize: [DEBUG] initialising threads...
mrresize: [DEBUG] launching 8 threads "loop threads"...
mrresize: [ 6%] reslicing "nodif_brain_mask.nii.gz"...
mrresize: [DEBUG] waiting for completion of threads "loop threads"...
mrresize: [100%] reslicing "nodif_brain_mask.nii.gz"...
mrresize: [DEBUG] threads "loop threads" completed OK
mrresize: [100%] reslicing "nodif_brain_mask.nii.gz"
mrresize: [100%] compressing image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz"
mrresize: [DEBUG] image "/home/pietro/nodif_brain_mask_2.5mm.nii.gz" unloaded
mrresize: [DEBUG] image "nodif_brain_mask.nii.gz" unloaded

ll -h ~/nodif_brain_mask_2.5mm.nii.gz

-rw-rw-r-- 1 pietro pietro 8.0K Jan 11 18:33 /home/pietro/nodif_brain_mask_2.5mm.nii.gz

Do you have any ideas on what I should check?

@jdtournier

This comment has been minimized.

Copy link
Member

jdtournier commented Jan 12, 2019

Ok, good to hear, that means the issue is likely down to your libz library, for some reason. Can the post the output of:

ldd $(which mrconvert)

This should report all libraries that mrconvert is using, and their locations. I want to see whether any of them are non-standard in some way...

@pietroastolfi

This comment has been minimized.

Copy link
Author

pietroastolfi commented Jan 15, 2019

this the output of the command:
ldd $(which mrconvert)

linux-vdso.so.1 => (0x00007ffe6a986000)
libmrtrix.so => /home/lorenzo/work/mrtrix3/bin/../lib/libmrtrix.so (0x00007f8f34eef000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8f34b6d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8f34864000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8f3464e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8f34431000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8f34067000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8f35315000)
libz.so.1 => /usr/local/lib/libz.so.1 (0x00007f8f33e4b000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f8f33bd7000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f8f339b5000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f8f337a7000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f8f3354e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8f3334a000)

p.s. I noted that I have a general problem in this system with the creation of gzip archive (for example I'm having problem with FSL first_flirt, which create a .nii.gz file and again it results only the header), maybe there is some corrupted library. If you have hints let me know.

@jdtournier

This comment has been minimized.

Copy link
Member

jdtournier commented Jan 16, 2019

Relevant line is:

libz.so.1 => /usr/local/lib/libz.so.1 (0x00007f8f33e4b000)

This is not the standard version supplied by your distribution. The /usr/local folder is used for custom or manually installed software. I don't know why you'd have this installed, but I suggest you get rid of it, and revert back to your distribution-supplied zlib package...

@pietroastolfi

This comment has been minimized.

Copy link
Author

pietroastolfi commented Jan 16, 2019

Solved! probably I've installed it some times for compatibility reason.

Thanks a lot 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.