NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.nicom.dicomwrappers.Wrapper

Next topic

nibabel.nicom.dicomwrappers.SiemensWrapper

Reggie -- the one

nibabel.nicom.dicomwrappers.MosaicWrapper

digraph inheritancee19e6c2a35 { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "SiemensWrapper" [shape=ellipse,URL="nibabel.nicom.dicomwrappers.SiemensWrapper.html#nibabel.nicom.dicomwrappers.SiemensWrapper",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "Wrapper" -> "SiemensWrapper" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Wrapper" [shape=ellipse,URL="nibabel.nicom.dicomwrappers.Wrapper.html#nibabel.nicom.dicomwrappers.Wrapper",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "MosaicWrapper" [shape=ellipse,URL="#nibabel.nicom.dicomwrappers.MosaicWrapper",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "SiemensWrapper" -> "MosaicWrapper" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

class nibabel.nicom.dicomwrappers.MosaicWrapper(dcm_data=None, csa_header=None, n_mosaic=None)

Class for Siemens mosaic format data

Mosaic format is a way of storing a 3D image in a 2D slice - and it’s as simple as you’d imagine it would be - just storing the slices in a mosaic similar to a light-box print.

We need to allow for this when getting the data and (because of an idiosyncrasy in the way Siemens stores the images) calculating the position of the first voxel.

Adds attributes:

  • n_mosaic : int
  • mosaic_size : float

Initialize Siemens Mosaic wrapper

The Siemens-specific information is in the csa_header, either passed in here, or read from the input dcm_data.

Parameters :

dcm_data : None or object, optional

object should allow attribute access. If csa_header is None, it should also be possible for to extract a CSA header from dcm_data. Usually this will be a dicom.dataset.Dataset object resulting from reading a DICOM file. If None, just make an empty dict.

csa_header : None or mapping, optional

mapping giving values for Siemens CSA image sub-header.

n_mosaic : None or int, optional

number of images in mosaic. If None, try to get this number from csa_header. If this fails, raise an error

get_data()

Get scaled image data from DICOMs

Resorts data block from mosaic to 3D

Returns :

data : array

array with data as scaled from any scaling in the DICOM fields.

Notes

The apparent image in the DICOM file is a 2D array that consists of blocks, that are the output 2D slices. Let’s call the original array the slab, and the contained slices slices. The slices are of pixel dimension n_slice_rows x n_slice_cols. The slab is of pixel dimension n_slab_rows x n_slab_cols. Because the arrangement of blocks in the slab is defined as being square, the number of blocks per slab row and slab column is the same. Let n_blocks be the number of blocks contained in the slab. There is also n_slices - the number of slices actually collected, some number <= n_blocks. We have the value n_slices from the ‘NumberOfImagesInMosaic’ field of the Siemens private (CSA) header. n_row_blocks and n_col_blocks are therefore given by ceil(sqrt(n_slices)), and n_blocks is n_row_blocks ** 2. Also n_slice_rows == n_slab_rows / n_row_blocks, etc. Using these numbers we can therefore reconstruct the slices from the 2D DICOM pixel array.

static image_position()

Return position of first voxel in data block

Adjusts Siemens mosaic position vector for bug in mosaic format position. See dicom_mosaic in doc/theory for details.

Parameters :

None :

Returns :

img_pos : (3,) array

position in mm of voxel (0,0,0) in Mosaic array

static image_shape()

Return image shape as returned by get_data()

is_mosaic = True