dbdicom.Series.coords#

Series.coords(dims=('InstanceNumber',), mesh=False, slice={}, coords={}, exclude=False, **filters) dict[source]#

return a dictionary of coordinates.

Parameters:

dims (tuple, optional) – Dimensions along which the shape is to be determined. If dims is not provided, they default to InstanceNumber.

Raises:

ValueError – If the dimensions do not produce suitable coordinates.

Returns:

dictionary of coordinates, one entry for each dimension. The values for each coordinate are returned as an darray with one dimension.

Return type:

dict

See also

set_coords

Example

Create an empty series with 3 slice dimensions:

>>> coords = {
...     'SliceLocation': np.array([0,1,2,0,1,2]),
...     'FlipAngle': np.array([2,2,2,10,10,10]),
...     'RepetitionTime': np.array([1,5,15,1,5,15]),
... }
>>> series = db.empty_series(coords)

Retrieve the coordinates:

>>> coords = series.coords(tuple(coords))
>>> coords['FlipAngle']
[2,10,2,10,2,10]
>>> coords['RepetitionTime']
[1,1,5,5,15,15]

Check the result in default dimensions:

>>> coords = series.coords()
>>> coords['InstanceNumber']
[1,2,3,4,5,6]

In this case the slice location and flip angle along are sufficient to identify the frames, so these are valid coordinates:

>>> coords = series.coords(('SliceLocation', 'FlipAngle'))
>>> coords['SliceLocation']
[0,0,1,1,2,2]

# However slice location and acquisition time are not sufficient as coordinates because each combination appears twice. So this throws an error:

>>> series.coords(('SliceLocation','RepetitionTime'))
ValueError: These are not proper coordinates. Coordinate values must be unique.