dbdicom.extensions.numpy.norm_projection#

dbdicom.extensions.numpy.norm_projection(series: Series, dims=('SliceLocation', 'InstanceNumber'), axis=-1, ord=None) Series[source]#

Projection along a specified dimension using the vector norm.

This functions uses numpy.linalg.norm to calculate the projection, see: https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html

Parameters:
  • series (dbdicom.Series) – Original series.

  • dims (tuple, optional) – Dimensions of the array. Defaults to (‘SliceLocation’,’InstanceNumber’).

  • axis (int, optional) – axis along which the maximum is to be taken. Defaults to -1.

  • ord (int, optional) – order of the norm - see documentation of numpy.linalg.norm for details

Returns:

maximum intensity projection.

Return type:

dbicom.Series

Example

Get the function from the numpy extension to dbdicom:

>>> from db.extensions.numpy import norm_projection

Create a zero-filled array, describing 8 MRI images each measured at 3 flip angles and 2 repetition times:

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

Create a norm projection on the slice locations and check the dimensions:

>>> mip = norm_projection(series)
>>> array = mip.pixel_values(dims=('SliceLocation', 'ImageNumber'))
>>> print(array.shape)
(128, 128, 8, 1)

Create a norm projection along the Slice Location axis:

>>> mip = norm_projection(series, dims=tuple(coords), axis=0)
>>> array = mip.pixel_values(dims=tuple(coords))
>>> print(array.shape)
(128, 128, 1, 3, 2)

Create a norm projection along the Flip Angle axis:

>>> mip = norm_projection(series, dims=tuple(coords), axis=1)
>>> array = mip.pixel_values(dims=tuple(coords))
>>> print(array.shape)
(128, 128, 8, 1, 2)

Create a norm projection along the Repetition Time axis:

>>> mip = norm_projection(series, dims=tuple(coords), axis=2)
>>> array = mip.pixel_values(dims=tuple(coords))
>>> print(array.shape)
(128, 128, 8, 3, 1)