dbdicom.Series.slice_groups#

Series.slice_groups(dims=('InstanceNumber',)) list[source]#

Return a list of slice groups in the series.

In dbdicom, a slice group is defined as a series of slices that have the same orientation. It is common for a single series to have images with multiple orientations, such as in localizer series in MRI. For such a series, returning all data in a single array may not be meaningful.

Formally, a slice group is a dictionary with two entries: ‘ndarray’ is the numpy.ndarray with the data along the dimensions provided by the dims argument, and ‘affine’ is the 4x4 affine matrix of the slice group. The function returns a list of such dictionaries, one for each slice group in the series.

Parameters:

dims (tuple, optional) – Dimensions for the returned arrays. Defaults to (‘InstanceNumber’,).

Returns:

A list of slice groups (dictionaries), one for each slice group in the series.

Return type:

list

Examples

>>> series = db.ones((128,128,5,10))
>>> sgroups = series.slice_groups(dims=('SliceLocation', 'AcquisitionTime'))

Since there is only one slice group in the series, sgroups is a list with one element:

>>> print(len(sgroups))
1

The array of the slice group is the entire volume of the series:

>>> print(sgroups[0]['ndarray'].shape)
(128, 128, 5, 10)

And the affine of the series has not changed from the default (identity):

>>> print(sgroups[0]['affine'])
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]