Create Dicomdir From Dicom Files

This DICOM to JPG converter can convert DICOM (Digital Imaging and Communications in Medicine) files to JPG (JPEG Image) image.
  • A Dicom Directory cannot have two dicom files with the same SOP Instance UID because the SOP Instance UID should be unique for each file. If you have two different files that have the same SOP Intstance UID then one of them needs to have that value changed.
  • Adding structured report to DICOMDIR file gets added as an image means the DirectoryRecordType becomes IMAGE instead of REPORT for that file. Hence, I went for manual creation of DICOMDIR structure but could not add Tags information to RootDirectoryRecord itself. So, if there is any way to add report using AddFile API, it will save my efforts.
  • Download dicomdir viewer for free. Photo & Graphics tools downloads - Sante DICOMDIR Viewer by Santesoft and many more programs are available for instant and free download.
  • This example shows how to create an image datastore from a collection of DICOM files containing 2-D images. Specify the location of a directory containing 2-D DICOM image files. DicomDir = fullfile (matlabroot, 'toolbox/images/imdata/dog'); Create an imageDatastore, specifying the read function as a handle to the dicomread function.
  • The dcmmkdir utility creates a DICOMDIR file from the specified referenced DICOM files according to the DICOM Part 11 Media Storage Application Profiles. Currently the following profiles are supported (others might be added later): General Purpose CD-R Interchange (STD-GEN-CD) General Purpose Interchange on DVD-RAM Media (STD-GEN-DVD-RAM).
Files
  1. Select a DICOM file (such as *.dcm, *.dcm30, *.dicom).
  2. Click button 'Convert' to start upload your file.
  3. Once upload completed, converter will redirect a web page to show the conversion result.

Create and burn DICOM CD/DVD disks from a DICOMDIR file Select the menu command 'CD/DVD BurningCreate DICOM CD/DVD From DICOMDIR'. A dialog box appears and it allows you to select the desired DICOMDIR file. A second dialog box allows you to select the desired series from the contents of the DICOMDIR file.

Remark:
  • If file upload process takes a very long time or no response or very slow, please try to cancel then submit again.
  • This converter cannot support encrypted or protected image files.
  • If you selected options, be sure to enter valid values.
  • If file source is a URL, be sure to enter a complete and valid URL to your file.
  • DICOM (Digital Imaging and Communications in Medicine) is an image format for storing medical data, such as CT and MRI scan data, it also contains a lot of useful medical information, such as patient tag, study tag, series tag and image tag. The file extensions can be .dcm, .dcm30, .dicom.
  • JPG (JPEG Image) is a lossy image compression format, compression method is usually lossy, based on the discrete cosine transform (DCT), encodings include: Sequential Encoding, Progressive Encoding, Lossless Encoding and Hierarchical Encoding. The file extensions can be .jpg, .jpeg, .jp2.
Related Image Converter:
  • DICOM to PDF
    PDF (Portable Document Format)
  • DICOM to GIF
    GIF (Graphics Interchange Format)
Convert Other File To JPG Converter:
  • PDF to JPG
    PDF (Portable Document Format)
  • BMP to JPG
    BMP (Bitmap)
  • PNG to JPG
    PNG (Portable Network Graphics)
  • GIF to JPG
    GIF (Graphics Interchange Format)
  • TIFF to JPG
    TIFF (Tagged Image File Format)
  • MP4 to JPG
    MP4 (MPEG-4 Video)
  • CR2 to JPG
    CR2 (Canon RAW Version 2)
  • NEF to JPG
    NEF (Nikon Electronic Format)
  • DNG to JPG
    DNG (Digital Negative)
  • PSD to JPG
    PSD (Photoshop Document)
  • CRW to JPG
    CRW (Canon Raw Format)
  • RAW to JPG
    RAW (RAW Image)
  • Canon Raw to JPG
    Canon Raw (Canon Camera Raw Image)
  • Nikon Raw to JPG
    Nikon Raw (Nikon Camera Raw Image)
  • Sony Raw to JPG
    Sony Raw (Sony Camera Raw Image)
  • Pentax Raw to JPG
    Pentax Raw (Pentax Camera Raw Image)
  • Fuji Raw to JPG
    Fuji Raw (Fuji Camera Raw Image)
  • Kodak Raw to JPG
    Kodak Raw (Kodak Camera Raw Image)
  • Panasonic Raw to JPG
    Panasonic Raw (Panasonic Camera Raw Image)
  • Leica Raw to JPG
    Leica Raw (Leica Camera Raw Image)
  • Samsung Raw to JPG
    Samsung Raw (Samsung Camera Raw Image)
  • Sigma Raw to JPG
    Sigma Raw (Sigma Camera Raw Image)
  • Olympus Raw to JPG
    Olympus Raw (Olympus Camera Raw Image)
  • WMF to JPG
    WMF (Windows Metafile)
  • PCX to JPG
    PCX (PiCture eXchange)
  • DJVU to JPG
    DjVu (DjVu Image)
  • EPS to JPG
    EPS (Encapsulated PostScript)
  • DPX to JPG
    DPX (Digital Picture Exchange)
  • CBR to JPG
    CBR (Comic Book RAR)
  • CBZ to JPG
    CBZ (Comic Book ZIP)
  • WEBP to JPG
    WEBP (Web Picture)
  • HEIC to JPG
    HEIC (High Efficiency Image Container)
  • DOCX to JPG
    DOCX (Office Open XML Document)
  • CR3 to JPG
    CR3 (Canon RAW Version 3)
  • ARW to JPG
    ARW (Sony Alpha Digital Image)
  • JFIF to JPG
    JFIF (JPEG File Interchange Format)
  • TGA to JPG
    TGA (Truevision Graphics Adapter)

Common pydicom functions called by user code

File Reading/Parsing¶

The main function to read and parse DICOM files using pydicom is dcmread. It is coded in the moduledicom.filereader, but is also imported when the pydicom package is imported:

If you need fine control over the reading, you can either call read_partial or use open_dicom.All are documented below:

pydicom.filereader.dcmread(fp, defer_size=None, stop_before_pixels=False, force=False, specific_tags=None)[source][source]

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

Read a DICOM dataset stored in accordance with the DICOM File Format(DICOM Standard Part 10 Section 7). If the dataset is not stored inaccordance with the File Format (i.e. the preamble and prefix are missing,there are missing required Type 1 File Meta Information Group elementsor the entire File Meta Information is missing) then you will have toset force to True.

Parameters:
fp:str or file-like

Either a file-like object, or a string containing the file name. If afile-like object, the caller is responsible for closing it.

defer_size:int or str or None

If None (default), all elements read into memory. If specified, then ifa data element’s stored value is larger than defer_size, the value isnot 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

If False (default), the full file will be read and parsed. Set True tostop before reading (7FE0,0010) ‘Pixel Data’ (and all subsequentelements).

force:bool

If False (default), raises an InvalidDicomError if the file is missingthe File Meta Information header. Set to True to force reading even ifno File Meta Information header is found.

specific_tags:list or None

If not None, only the tags in the list are returned. The listelements can be tags or tag names.

Returns:
FileDataset

An instance of FileDataset that represents a parsed DICOM file.

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:

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

Use within a context manager:

pydicom.filereader.read_partial(fileobj, stop_when=None, defer_size=None, force=False, specific_tags=None)[source][source]

Parse a DICOM file until a condition is met.

Parameters:
fileobj:a file-like object

Note that the file will not close when the function returns.

stop_when :

Stop condition. See read_dataset for more info.

defer_size:int, str, None, optional

See dcmread for parameter info.

force:boolean

See dcmread for parameter info.

specific_tags:list or None

See dcmread for parameter info.

Returns:
FileDataset instance or DicomDir instance.
Create Dicomdir From Dicom Files

See also

dcmread
More generic file reading function.

Notes

Use dcmread unless you need to stop on some condition other thanreaching pixel data.

Files

File Writing¶

DICOM files can also be written using pydicom. There are two ways to do this.The first is to use write_file with a prexisting FileDataset (derived from Dataset) instance.The second is to use the save_as method on an Dataset instance.

pydicom.filewriter.write_file(filename, dataset, write_like_original=True)[source]

Write dataset to the filename specified.

If write_like_original is True then dataset will be written as is(after minimal validation checking) and may or may not contain all or partsof the File Meta Information (and hence may or may not be conformant withthe DICOM File Format).If write_like_original is False, dataset will be stored in the DICOMFile Format in accordance with DICOM Standard Part 10 Section 7. The bytestream of the dataset will be placed into the file after the DICOM FileMeta Information.

Parameters:
filename:str or file-like

Name of file or the file-like to write the new DICOM file to.

dataset:pydicom.dataset.FileDataset

Dataset holding the DICOM information; e.g. an object read withpydicom.dcmread().

write_like_original:bool

If True (default), preserves the following information fromthe Dataset (and may result in a non-conformant file):- preamble – if the original file has no preamble then none will be

  • file_meta – if the original file was missing any required File Meta
    Information Group elements then they will not be added or written.If (0002,0000) ‘File Meta Information Group Length’ is present thenit may have its value updated.
  • seq.is_undefined_length – if original had delimiters, write them now
    too, instead of the more sensible length characters
  • is_undefined_length_sequence_item – for datasets that belong to a
    sequence, write the undefined length delimiters if that iswhat the original had.

If False, produces a file conformant with the DICOM File Format, withexplicit lengths for all elements.

See also

pydicom.dataset.FileDataset
Dataset class with relevant attributes and information.
pydicom.dataset.Dataset.save_as
Write a DICOM file from a dataset that was read in with dcmread(). save_as wraps dcmwrite.
Dataset.save_as(filename, write_like_original=True)[source][source]

Create Dicomdir From Dicom Files Download

Write the Dataset to filename.

Saving a Dataset requires that the Dataset.is_implicit_VR andDataset.is_little_endian attributes exist and are set appropriately. IfDataset.file_meta.TransferSyntaxUID is present then it should be set toa consistent value to ensure conformance.

Parameters:
filename:str or file-like

Name of file or the file-like to write the new DICOM file to.

write_like_original:bool

If True (default), preserves the following information fromthe Dataset (and may result in a non-conformant file):- preamble – if the original file has no preamble then none will

  • file_meta – if the original file was missing any required File
    Meta Information Group elements then they will not be added orwritten.If (0002,0000) ‘File Meta Information Group Length’ is presentthen it may have its value updated.
  • seq.is_undefined_length – if original had delimiters, write them
    now too, instead of the more sensible length characters
  • is_undefined_length_sequence_item – for datasets that belong to
    a sequence, write the undefined length delimiters if that iswhat the original had.

If False, produces a file conformant with the DICOM File Format,with explicit lengths for all elements.

See also

pydicom.filewriter.write_dataset
Write a DICOM Dataset to a file.
pydicom.filewriter.write_file_meta_info
Write the DICOM File Meta Information Group elements to a file.
pydicom.filewriter.dcmwrite
Write a DICOM file from a FileDataset instance.

Create Dicomdir From Dicom Files Converter

You can find the complete API documentation for Dataset and otherclasses in the following section.