fsl.data.dicom¶
This module provides the DicomImage class, which represents a
volumetric DICOM data series. The DicomImage is simply an `Image
which provides accessors for additional DICOM meta data.
The following other functions are provided in this module, which are thin
wrappers around functionality provided by Chris Rorden’s dcm2niix program:
enabled |
Returns True if dcm2niix is present, and recent enough, False otherwise. |
scanDir |
Uses the dcm2niix -b o option to generate a BIDS sidecar JSON file for each series in the given DICOM directory. |
loadSeries |
Takes a DICOM series meta data dictionary, as returned by scanDir(), and loads the associated data as one or more NIFTI images. |
See: https://github.com/rordenlab/dcm2niix/
Note
These functions will not work if an executable called dcm2niix
cannot be found.
-
fsl.data.dicom.MIN_DCM2NIIX_VERSION= (1, 0, 2017, 12, 15)¶ Minimum version of
dcm2niixthat is required for this module to work.
-
fsl.data.dicom.CRC_DCM2NIIX_VERSION= (1, 0, 2019, 9, 2)¶ For versions of
dcm2niixorf this version or newer, the-nflag, used to convert a single DICOM series, requires that a CRC checksum identifying the series be passed (see theseriesCRC()function). Versions prior to this require the series number to be passed.
-
class
fsl.data.dicom.DicomImage(image, metadata, dicomDir, *args, **kwargs)[source]¶ Bases:
fsl.data.image.ImageThe
DicomImageis a volumetricImagewith some associated DICOM metadata.The
Imageclass is used to manage the data and the voxel-to-world transformation. Additional DICOM metadata may be accessed via theImagemetadata access methods.-
__init__(image, metadata, dicomDir, *args, **kwargs)[source]¶ Create a
DicomImage.Parameters: - image – Passed through to
Image.__init__(). - metadata – Dictionary containing DICOM meta-data.
- dicomDir – Directory that the dicom image was loaded from.
- image – Passed through to
-
dicomDir¶ Returns the directory that the DICOM image data was loaded from.
-
__module__= 'fsl.data.dicom'¶
-
-
fsl.data.dicom.compareVersions(v1, v2)[source]¶ Compares two
dcm2niixversionsv1andv2. The versions are assumed to be in the format returned byinstalledVersion().Returns: - 1 if
v1is newer thanv2 - -1 if
v1is older thanv2 - 0 if
v1the same asv2.
- 1 if
-
fsl.data.dicom.enabled()[source]¶ Returns
Trueifdcm2niixis present, and recent enough,Falseotherwise.
-
fsl.data.dicom.scanDir(dcmdir)[source]¶ Uses the
dcm2niix -b ooption to generate a BIDS sidecar JSON file for each series in the given DICOM directory. Reads them all in, and returns them as a sequence of dicts.- Some additional metadata is added to each dictionary:
DicomDir: The absolute path todcmdir
Parameters: dcmdir – Directory containing DICOM series Returns: A list of dicts, each containing the BIDS sidecar JSON metadata for one DICOM series.
-
fsl.data.dicom.seriesCRC(series)[source]¶ Calculate a checksum string of the given DICOM series.
The returned string is of the form:
SeriesCRC[.echonumber]
Where
SeriesCRCis an unsigned integer which is the CRC32 checksum of theSeriesInstanceUID, andechonumberis theEchoNumberof the series - this is only present for multi-echo data, where the series is from the second or subsequent echos.Parameters: series – Dict containing BIDS metadata about a DICOM series, as returned by scanDir().Returns: String containing a CRC32 checksum for the series.
-
fsl.data.dicom.loadSeries(series)[source]¶ Takes a DICOM series meta data dictionary, as returned by
scanDir(), and loads the associated data as one or more NIFTI images.Parameters: series – Dictionary as returned by scanDir(), containing meta data about one DICOM data series.Returns: List containing one or more DicomImageobjects.