CTseg icon indicating copy to clipboard operation
CTseg copied to clipboard

Segmentation obtained doesn't seem to be right

Open marin-combeau opened this issue 1 year ago • 14 comments

Hello, I applied the algorithm to a CT scan that I have, and the resulting segmentation in itself seems to be good, it looks like a nice brain, but it doesn't seem to fit my the CT scan that was in input. Indeed, first I have to translate the segmentation because it is far away from where the head is on the CT scan, and secondly the shapes and the size don't fit, it seems like it is showing the results from another head. I used the line docker run --rm -it -v "/home/labeyrie/Téléchargements/CTseg":/data ubuntu:ctseg function spm_CTseg '/data/patient_001_S1.nii' and here are the results, displaying the input CT scan: Capture d’écran de 2023-03-27 10-00-09 wc version: Capture d’écran de 2023-03-27 09-58-20 mwc version: Capture d’écran de 2023-03-27 10-27-28 Am I doing something wrong?

marin-combeau avatar Mar 27 '23 08:03 marin-combeau

Hi @marin-combeau, you should use the c* files (the wc* and mwc* files are normalised segmentations). Are they not present in your output directory?

gllmflndn avatar Mar 28 '23 16:03 gllmflndn

Hi, I had tested it and I thought it was worse than the others, but with more observation I realised that it seems to be better, but still too large compared to the scan and not in the right position (I had to do a translation and a rotation), is it a problem in the header information, like voxel dimension or something like that? here are the pictures: Capture d’écran de 2023-03-30 12-00-41 Capture d’écran de 2023-03-30 12-02-40 I also notice that the skin segmentation is taking some of the background in addition to the actual skin: Capture d’écran de 2023-03-30 12-06-17 Capture d’écran de 2023-03-30 12-07-48

marin-combeau avatar Mar 30 '23 10:03 marin-combeau

It might create other problems but could you try again with correct_header set to false:

docker run --rm -it -v "/home/labeyrie/Téléchargements/CTseg":/data ubuntu:ctseg eval "spm_CTseg('/data/patient_001_S1.nii','',true,true,false)"

gllmflndn avatar Apr 03 '23 10:04 gllmflndn

Now the segmentations 1, 2 and 3 are empty, and the 4, 5 and 6 give this: Capture d’écran de 2023-04-04 10-30-55

marin-combeau avatar Apr 04 '23 08:04 marin-combeau

So it did indeed create other problems :frowning_face: At this stage, it's best waiting for @brudfors's comment as I don't know what the issues with CT headers are and I might be looking in the wrong direction anyway.

gllmflndn avatar Apr 04 '23 09:04 gllmflndn

Okay, thanks

marin-combeau avatar Apr 04 '23 09:04 marin-combeau

It looks to me like the registration part of the algorithm is struggling to register the adult head tissue priors to the CT of a baby's head. Unfortunately, I don't have a good fix for this - other than for someone to generate a set of baby tissue priors.

JohnAshburner avatar Apr 06 '23 09:04 JohnAshburner

Thanks for your answer, but the scan I am feeding the algorithm with is the one of an adult, but indeed the segmentation obtained seems like the one of a baby, I guess because of the differences in the dimensions. I am also checking the nifti header of the CT scan to search for problem that could explain this, I have this result (it could be different from the ones used for the training of the algorithm, which could cause problems I guess):

<class 'nibabel.nifti1.Nifti1Header'> object, endian='<'
sizeof_hdr      : 348
data_type       : b''
db_name         : b''
extents         : 0
session_error   : 0
regular         : b'r'
dim_info        : 0
dim             : [  3 320 320 160   1   1   1   1]
intent_p1       : 0.0
intent_p2       : 0.0
intent_p3       : 0.0
intent_code     : none
datatype        : int16
bitpix          : 16
slice_start     : 0
pixdim          : [-1.    0.76  0.76  0.99  1.    1.    1.    1.  ]
vox_offset      : 0.0
scl_slope       : nan
scl_inter       : nan
slice_end       : 0
slice_code      : unknown
xyzt_units      : 10
cal_max         : 0.0
cal_min         : 0.0
slice_duration  : 0.0
toffset         : 0.0
glmax           : 0
glmin           : 0
descrip         : b'Time=200837.748;mb=159'
aux_file        : b''
qform_code      : scanner
sform_code      : scanner
quatern_b       : 0.0
quatern_c       : 1.0
quatern_d       : 0.0
qoffset_x       : 204.47557
qoffset_y       : -32.717865
qoffset_z       : 199.90698
srow_x          : [ -0.76  -0.     0.   204.48]
srow_y          : [  0.     0.76   0.   -32.72]
srow_z          : [  0.     0.     0.99 199.91]
intent_name     : b''
magic           : b'n+1'

marin-combeau avatar Apr 14 '23 07:04 marin-combeau

I think the header looks OK, and setting correct_header=true should take care of any affine matrix related issues regardless.

Are you sure the scan is not of a young child? Your 3D Slicer screenshot above (https://github.com/WCHN/CTseg/issues/23#issuecomment-1490041360) suggests it is; from looking at the 3D rendering and the fact that the head in the scan is small compared to the predicted segmentation.

brudfors avatar Apr 14 '23 09:04 brudfors

Hi, thanks for your answer, yes I am sure that the scan in the screenshot is the one of an adult (24yo), and the 3D rendering is showing the predicted segmentation, which I think gives the impression of a baby/young child skull since the height seems good, but the width and length are higher.

marin-combeau avatar Apr 17 '23 08:04 marin-combeau

The head proportions don't look right for a typical adult. Could the voxel sizes in the headers be wrong?

[image: image.png]

On Mon, 17 Apr 2023 at 09:10, marin-combeau @.***> wrote:

Hi, thanks for your answer, yes I am sure that the scan in the screenshot is the one of an adult (24yo), and the 3D rendering is showing the predicted segmentation, which I think gives the impression of a baby/young child skull since the height seems good, but the width and length are higher.

— Reply to this email directly, view it on GitHub https://github.com/WCHN/CTseg/issues/23#issuecomment-1510896411, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACY3J65QJRJPS7YNQJUJBBLXBT3FRANCNFSM6AAAAAAWI3KJEA . You are receiving this because you commented.Message ID: @.***>

JohnAshburner avatar Apr 17 '23 08:04 JohnAshburner

How did you convert from DICOM to NIfTI? Could the slice thickness have been used for the voxel sizes, rather than the distance between slices? SPM's DICOM conversion (when it works) should put the right voxel sizes in the header. There is often a shear with CT scans, which I've also tried to ensure that it deals with properly (based on a limited number of examples).

On Mon, 17 Apr 2023 at 09:41, John Ashburner @.***> wrote:

The head proportions don't look right for a typical adult. Could the voxel sizes in the headers be wrong?

[image: image.png]

On Mon, 17 Apr 2023 at 09:10, marin-combeau @.***> wrote:

Hi, thanks for your answer, yes I am sure that the scan in the screenshot is the one of an adult (24yo), and the 3D rendering is showing the predicted segmentation, which I think gives the impression of a baby/young child skull since the height seems good, but the width and length are higher.

— Reply to this email directly, view it on GitHub https://github.com/WCHN/CTseg/issues/23#issuecomment-1510896411, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACY3J65QJRJPS7YNQJUJBBLXBT3FRANCNFSM6AAAAAAWI3KJEA . You are receiving this because you commented.Message ID: @.***>

JohnAshburner avatar Apr 17 '23 08:04 JohnAshburner

I used dcm2niix to convert to nifti, through the software MRIcroGL, with the line

/home/labeyrie/Téléchargements/MRIcroGL_linux1804/MRIcroGL/Resources/dcm2niix -f "%f_%p_%t_%s" -p y -z n -o "/home/labeyrie/Documents/Marin/essai dicom to nifti" "/home/path/of/dicom/to/convert"

and I believe Guillaume Flandin told me that the conversion should be okay using this

marin-combeau avatar Apr 17 '23 10:04 marin-combeau

One thing you could do is to display the images within SPM to see if they look the same than within the software you are currently using. To do so, you can use the instructions below to open the SPM interface: https://en.wikibooks.org/wiki/SPM/Docker#SPM_Containers where you replace spmcentral/spm fmri by ubuntu:ctseg. You can then use the Display or CheckReg buttons to display one or several images. You will now also see the DICOM Import button allowing you to do the DICOM to NIfTI conversion with SPM instead of dcm2niix, as discussed above.

gllmflndn avatar Apr 27 '23 14:04 gllmflndn