WCHN / CTseg

Brain CT image segmentation, normalisation, skull-stripping and total brain/intracranial volume computation.
GNU General Public License v3.0
62 stars 16 forks source link

Error reading header file #21

Closed marin-combeau closed 1 year ago

marin-combeau commented 1 year ago

Hello, I was trying to test on docker with: docker run --rm -it -v dir_host:/scanner ubuntu:ctseg function spm_CTseg '/scanner/patient_001_S1.nii' but I have the following error: Error using read_hdr (line 39) Error reading header file "/scanner/patient_001_S1.nii". Error in read_hdr (line 39) Error in nifti (line 26) Error in spm_CTseg (line 138) Error in spm_standalone (line 132) but I have no idea what is wrong with the header the original file was in DICOM, and I converted it in nifti using MRIcroGL (https://www.nitrc.org/projects/mricrogl) Thanks in advance

JohnAshburner commented 1 year ago

For some reason, it was unable to read the header. Make sure the file isn't empty (which might happen if the disk is full) and that you have read permission for it. If you are working on Windows, there can sometimes be problems if some other program has a file open.

gllmflndn commented 1 year ago

In the command line you use, have you replaced dir_host with the path from your computer that contains the file patient_001_S1.nii (that's how bind mounts work)?

marin-combeau commented 1 year ago

For some reason, it was unable to read the header. Make sure the file isn't empty (which might happen if the disk is full) and that you have read permission for it. If you are working on Windows, there can sometimes be problems if some other program has a file open.

Thanks for your answer Yes I made sure it wasn't empty, I opened it on 3DSlicer (https://www.slicer.org/) and everything works normally. For the permission I think I have it, wouldn't it say something about it if it was the problem? (I'm new to this so I'm just asking) and finally, I'm on Linux (Ubuntu 20.04.5).

marin-combeau commented 1 year ago

In the command line you use, have you replaced dir_host with the path from your computer that contains the file patient_001_S1.nii (that's how bind mounts work)?

yes I did :)

gllmflndn commented 1 year ago

In the command line you use, have you replaced dir_host with the path from your computer that contains the file patient_001_S1.nii (that's how bind mounts work)?

yes I did :)

Then let's check what the container sees in /scanner and what the file permissions are:

docker run ...... ubuntu:ctseg eval "ls -l /scanner"
gllmflndn commented 1 year ago

At this stage it might be worth mentioning that, in the absence of MATLAB, it is not necessary to use Docker and you could instead just use the MATLAB Runtime and Standalone SPM directly on your machine by downloading and installing these two pieces of software separately:

https://github.com/WCHN/CTseg/blob/master/Dockerfile#L17 https://github.com/WCHN/CTseg/blob/master/Dockerfile#L30

marin-combeau commented 1 year ago

Then let's check what the container sees in /scanner and what the file permissions are:

docker run ...... ubuntu:ctseg eval "ls -l /scanner"

It says "total 0"

gllmflndn commented 1 year ago

Then let's check what the container sees in /scanner and what the file permissions are:

docker run ...... ubuntu:ctseg eval "ls -l /scanner"

It says "total 0"

So this would indicate that <dir_host>/patient_001_S1.nii is not present on your computer. Could you double-check that you specified dir_host correctly on the Docker command line and that patient_001_S1.nii is indeed there?

marin-combeau commented 1 year ago

yes I just re checked and the path seems to be fine, as well as the file is there, then I re wrote the command docker run --rm -it -v /home/labeyrie/documents/marin/essai_ctseg:/scanner ubuntu:ctseg eval "ls -l /scanner", but now the output is total 4 drwxr-xr-x 2 root root 4096 Mar 3 12:39 scanner

gllmflndn commented 1 year ago

Thanks. /home/labeyrie/documents/marin/essai_ctseg should contain patient_001_S1.nii. Could it be that in your case it contains a directory scanner that then contains patient_001_S1.nii?

marin-combeau commented 1 year ago

yes, patient_001_S1.nii is in the directory scanner

gllmflndn commented 1 year ago

So I think you should but patient_001_S1.nii directly in /home/labeyrie/documents/marin/essai_ctseg and not have any scanner directory. I.e.:

/home/labeyrie/documents/marin/essai_ctseg/patient_001_S1.nii
marin-combeau commented 1 year ago

Hello, sorry for the delay I was out of office for the beginning of the week, I tried to do as you told me and I still have the same error message, and I also tried to move the scanner to the same repository as the code is, and tried the following line: sudo docker run --rm -it -v "/labeyrie/Téléchargements/CTseg":/data ubuntu:ctseg function spm_CTseg '/patient_001_S1.nii' and I still have the same error: Error using read_hdr (line 39) Error reading header file "/patient_001_S1.nii". Error in read_hdr (line 39) Error in nifti (line 26) Error in spm_CTseg (line 138) Error in spm_standalone (line 132) is it a problem with the redaction of the line of code?

brudfors commented 1 year ago

Hi @marin-combeau, Try the command:

sudo docker run --rm -it -v "/labeyrie/Téléchargements/CTseg":/data ubuntu:ctseg function spm_CTseg '/data/patient_001_S1.nii'

This assumes that the file patient_001_S1.nii is available in /labeyrie/Téléchargements/CTseg.

marin-combeau commented 1 year ago

Hi, I just tried it and sadly I still have the same error: Error using read_hdr (line 39) Error reading header file "/data/patient_001_S1.nii". Error in read_hdr (line 39) Error in nifti (line 26) Error in spm_CTseg (line 138) Error in spm_standalone (line 132)

brudfors commented 1 year ago

How about if you access a shell in the container:

sudo docker run --rm -it -v "/labeyrie/Téléchargements/CTseg":/data ubuntu:ctseg bash

and then do a:

ls

Do you see your image?

marin-combeau commented 1 year ago

Typing the line

sudo docker run --rm -it -v "/labeyrie/Téléchargements/CTseg":/data ubuntu:ctseg bash

gets me this error:

Error using spm_cli (line 56)
Cannot find module bash.

Error in spm_cli (line 56)
Error in spm_standalone (line 157)

and I can't manage to understand how to solve it

marin-combeau commented 1 year ago

Hello, so I had a meeting with @gllmflndn, and I am sorry the solution was really easy, I was just forgetting a "/home" at the beginning of the path ... thank you for your time, and I can close the issue now, sorry again for bothering you with a simple problem.