dbdicom.Series.subseries#

Series.subseries(**kwargs) Series[source]#

Extract a subseries based on values of header elements.

Parameters:

kwargs – Any number of valid DICOM (tag, value) keyword arguments.

Returns:

a new series as a sibling under the same parent.

Return type:

Series

See also

split_by()

Example

Create a multi-slice series with multiple flip angles and repetition times:

>>> coords = {
...    'SliceLocation': np.arange(16),
...    'FlipAngle': [2, 15, 30],
...    'RepetitionTime': [2.5, 5.0, 7.5],
... }
>>> zeros = db.zeros((128, 128, 16, 3, 2), coords)

Create a new series containing only the data with flip angle 2 and repetition time 7.5:

>>> volume = zeros.subseries(FlipAngle=2.0, RepetitionTime=7.5)

Check that the volume series now has two dimensions of size 1:

>>> array = volume.ndarray(dims=tuple(coords))
>>> print(array.shape)
(128, 128, 16, 1, 1)

and only one flip angle and repetition time:

>>> print(volume.FlipAngle, volume.RepetitionTime)
2.0 7.5

and that the parent study now has two series:

>>> volume.study().print()
---------- STUDY ---------------
Study New Study [None]
Series 001 [New Series]
    Nr of instances: 96
Series 002 [New Series]
    Nr of instances: 16
--------------------------------