# pydicom.filereader.dcmread

`pydicom.filereader.``dcmread`(fp, defer_size=None, stop_before_pixels=False, force=False, specific_tags=None)

  Read and parse a DICOM dataset stored in the DICOM File Format.

  Read a DICOM dataset stored in accordance with the DICOM File Format. If the dataset is not stored in accordance with the File Format (i.e. the preamble and prefix are missing, there are missing required Type 1 File Meta Information Group elements or the entire File Meta Information is missing) then you will have to set force to `True`.

  Parameters:

  - fp (str or file-like) – Either a file-like object, or a string containing the file name. If a file-like object, the caller is responsible for closing it.
  - defer_size (int or str or None, optional) – If `None` (default), all elements are read into memory. If specified, then if a data element’s stored value is larger than defer_size, the value is not read into memory until it is accessed in code. Specify an integer (bytes), or a string value with units, e.g. “512 KB”, “2 MB”.
  - stop_before_pixels (bool, optional) – If `False` (default), the full file will be read and parsed. Set `True` to stop before reading (7FE0,0010) Pixel Data (and all subsequent elements).
  - force (bool, optional) – If `False` (default), raises an `InvalidDicomError` if the file is missing the File Meta Information header. Set to `True` to force reading even if no File Meta Information header is found.
  - specific_tags (list or None, optional) – If not `None`, only the tags in the list are returned. The list elements can be tags or tag names. Note that the element (0008,0005) Specific Character Set is always returned if present - this ensures correct decoding of returned text values.

  Returns: | An instance of `FileDataset` that represents a parsed DICOM file.
  Return type: | FileDataset
  Raises: | `InvalidDicomError` – If force is `True` and the file is not a valid DICOM file.

  See also

  `pydicom.dataset.FileDataset()`
    Data class that is returned.
  `pydicom.filereader.read_partial()`
    Only read part of a DICOM file, stopping on given conditions.

  Examples

  Read and return a dataset stored in accordance with the DICOM File Format:

      >>> ds = pydicom.dcmread("rtplan.dcm")
      >>> ds.PatientName

  Read and return a dataset not in accordance with the DICOM File Format:

      >>> ds = pydicom.dcmread("rtplan.dcm", force=True)
      >>> ds.PatientName

  Use within a context manager:

      >>> with pydicom.dcmread("rtplan.dcm") as ds:
      >>>     ds.PatientName