moloney / dcmstack

DICOM to Nifti conversion with meta data preservation
Other
72 stars 51 forks source link

Slice thickness calculation? #29

Closed TheChymera closed 9 years ago

TheChymera commented 9 years ago

Hi, I presently trying to stack a number of DICOM files to a NifTi with the help of dcmstack.

In the NifTi header I get the following section (as read with AFNI's 3dinfo):

R-to-L extent:    -8.815 [R] -to-     9.121 [L] -step-     0.304 mm [ 60 voxels]
A-to-P extent:    -6.375 [A] -to-     2.325 [P] -step-     0.300 mm [ 30 voxels]
I-to-S extent:    -4.639 [I] -to-     4.861 [S] -step-     0.500 mm [ 20 voxels]

Or, in plain text:

pixdim          : [ -1.00000000e+00   3.03997457e-01   3.00000012e-01   5.00000000e-01
   1.50000000e+03   1.00000000e+00   1.00000000e+00   1.00000000e+00]

This is what I see in the headers of the DICOM files from which I perform the conversion:

(0018, 0050) Slice Thickness                     DS: '0.35'
(0028, 0030) Pixel Spacing                       DS: ['0.3', '0.3039974672']

Any ideas why dcmstack reads the x and y resolutions correctly, but not the z? Does it try to compute it maybe from something else?

TheChymera commented 9 years ago

Also, I checked and none of the constituent DICOM files have any other Slice Thickness in their header except 0.35.

moloney commented 9 years ago

This is the correct behavior. The DICOM field tells you the width of the slab being excited, the Nifti header tells you the spacing between adjacent slices (calculated from ImagePositionPatient).

TheChymera commented 9 years ago

Many thanks for clarifying this!

So is the spacing in the NifTi header the distance from voxel midpoint to voxel midpoint, or from voxel edge to voxel edge?

Also, any idea what the other numbers are in ImagePositionPatient?

('ImagePositionPatient', [9.13285125, -6.084546948, 0.3556192147])
moloney commented 9 years ago

You might want to take a look at this: http://nipy.org/nibabel/dicom/dicom_orientation.html