Skip to content

DOC: Dicom doc. improvement #910

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

Merged
merged 5 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.pydevproject
*.py.orig
.DS_Store
.idea/

# Not sure what the next one is for
*.kpf
Expand Down
12 changes: 8 additions & 4 deletions doc/source/dicom/dicom_orientation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ Where:
For later convenience we also define values useful for 3D volumes:

* $s$ : slice index to the slice plane. The first slice index is zero.
* $\Delta{s}$ - spacing in mm between slices.
* $\Delta{s}$ - Spacing in mm between slices, given by the Spacing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dear - I see now that it is more complicated than I thought when I wrote the original - https://stackoverflow.com/questions/14930222/how-to-calculate-space-between-dicom-slices-for-mpr - what do you think we should do?

Copy link
Contributor Author

@jond01 jond01 May 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the method with Image Position (Patient) is more general, as some dicoms may miss the Spacing Between Slices attribute.
If both attributes appear, then filling the third column in the affine is possible with either:

  1. Image Position (Patient) of multiple sorted slices
  2. Spacing Between Slices + the normal n from Image Orientation (Patient).

And they are equivalent (at least are expected to be).

Method 1 is described thoroughly in the doc:
https://nipy.org/nibabel/dicom/dicom_orientation.html#d-affine-formulae
Method 2 may be helpful in some special case: you have just one slice (N=1) but still want the third column of the 4x4 affine matrix. It can be achieved with:

  • The cross product of Image Orientation (Patient) = n
  • Spacing Between Slices = Δs

In summary, it does not contradict anything but worth mentioning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I think the question is whether to add the explicit mention of the DICOM Spacing Between Slices attribute here - because it looks like it is a pretty unreliable method of getting the thing we want, which is the distance between the center of one slice and the center of the next: https://groups.google.com/forum/#!msg/comp.protocols.dicom/gyvsgAj4y6o/KOjJywTWFlAJ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the bold part here can be moved to some footnote:

  • $\Delta{s}$ - Spacing in mm between slices, given by the Spacing ...

However, from my experience when this tag is there - it is correct, i.e. it agrees with the current method.
David A. Clunie is a reliable source, but it was 20 years ago. I think that today most of the manufacturers comply with the definition in the standard, which is exactly what we want:

Spacing Between Slices | (0018,0088) | 3 | Spacing between adjacent slices, in mm. The spacing is measured from the center-to-center of each slice, and if present shall not be negative.

From:
http://dicom.nema.org/MEDICAL/dicom/2015b/output/chtml/part03/sect_C.7.6.16.2.html#table_C.7.6.16-2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's reasonable - maybe with some discussion like here so people know to be a little careful.

Between Slices (0018,0088) attribute in units of mm (if exists).
Can also be calculated from the Image Orientation (Patient) of
multiple slices together with Image Orientation (Patient), as
explained in :ref:`dicom-affine-defs`.

.. _dicom-3d-affines:

Expand Down Expand Up @@ -307,13 +311,13 @@ first voxel in the last (slice index = $N-1$) slice to mm space. So:

.. math::

\left(\begin{smallmatrix}T^N\\1\end{smallmatrix}\right) = A \left(\begin{smallmatrix}0\\0\\-1 + N\\1\end{smallmatrix}\right)
\left(\begin{smallmatrix}T^N\\1\end{smallmatrix}\right) = A \left(\begin{smallmatrix}0\\0\\N - 1\\1\end{smallmatrix}\right)

From this it follows that:

.. math::

\begin{Bmatrix}k_{{1}} : \frac{T^{1}_{{1}} - T^{N}_{{1}}}{1 - N}, & k_{{2}} : \frac{T^{1}_{{2}} - T^{N}_{{2}}}{1 - N}, & k_{{3}} : \frac{T^{1}_{{3}} - T^{N}_{{3}}}{1 - N}\end{Bmatrix}
\begin{Bmatrix}k_{{1}} : \frac{T^{N}_{{1}} - T^{1}_{{1}}}{N - 1}, & k_{{2}} : \frac{T^{N}_{{2}} - T^{1}_{{2}}}{N - 1}, & k_{{3}} : \frac{T^{N}_{{3}} - T^{1}_{{3}}}{N - 1}\end{Bmatrix}

and therefore:

Expand All @@ -324,7 +328,7 @@ and therefore:

.. math::

A_{multi} = \left(\begin{smallmatrix}F_{{11}} \Delta{r} & F_{{12}} \Delta{c} & \frac{T^{1}_{{1}} - T^{N}_{{1}}}{1 - N} & T^{1}_{{1}}\\F_{{21}} \Delta{r} & F_{{22}} \Delta{c} & \frac{T^{1}_{{2}} - T^{N}_{{2}}}{1 - N} & T^{1}_{{2}}\\F_{{31}} \Delta{r} & F_{{32}} \Delta{c} & \frac{T^{1}_{{3}} - T^{N}_{{3}}}{1 - N} & T^{1}_{{3}}\\0 & 0 & 0 & 1\end{smallmatrix}\right)
A_{multi} = \left(\begin{smallmatrix}F_{{11}} \Delta{r} & F_{{12}} \Delta{c} & \frac{T^{N}_{{1}} - T^{1}_{{1}}}{N - 1} & T^{1}_{{1}}\\F_{{21}} \Delta{r} & F_{{22}} \Delta{c} & \frac{T^{N}_{{2}} - T^{1}_{{2}}}{N - 1} & T^{1}_{{2}}\\F_{{31}} \Delta{r} & F_{{32}} \Delta{c} & \frac{T^{N}_{{3}} - T^{1}_{{3}}}{N - 1} & T^{1}_{{3}}\\0 & 0 & 0 & 1\end{smallmatrix}\right)

A_{single} = \left(\begin{smallmatrix}F_{{11}} \Delta{r} & F_{{12}} \Delta{c} & \Delta{s} n_{{1}} & T^{1}_{{1}}\\F_{{21}} \Delta{r} & F_{{22}} \Delta{c} & \Delta{s} n_{{2}} & T^{1}_{{2}}\\F_{{31}} \Delta{r} & F_{{32}} \Delta{c} & \Delta{s} n_{{3}} & T^{1}_{{3}}\\0 & 0 & 0 & 1\end{smallmatrix}\right)

Expand Down
2 changes: 1 addition & 1 deletion doc/source/dicom/spm_dicom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Then, for each currently identified volume:
#. ImageOrientationPatient (to tolerance of sum squared difference 1e-4)
#. PixelSpacing (to tolerance of sum squared difference 1e-4)
#. ICE dims as defined above
#. ImageType (iff imagetype exists in both)zv
#. ImageType (iff imagetype exists in both)
#. SequenceName (iff sequencename exists in both)
#. SeriesInstanceUID (iff exists in both)
#. EchoNumbers (iff exists in both)
Expand Down