MATLAB: Do I receive a “Cannot compress using transfer syntax” error when writing a file using the DICOMWRITE function in MATLAB 7.0 (R14)

compresscompressiondicomwriteImage Processing Toolboxsyntaxtransfer

When I write to a file using the DICOMWRITE function, using:
info = dicominfo('test1.dcm');
dicomwrite(int16(rand(512, 512)), 'test2.dcm', info);
I receive an error similar to the following:
??? Error using ==> images\private\dicom_compress_pixel_cells>compress_cells
Cannot compress using transfer syntax "1.2.840.10008.1.2.4.57".

Best Answer

The error occurs because the particular compression method that is being specified by the metadata information "info" is not supported. While the DICOMWRITE function supports many different compression methods, it does not support all of them.
To workaround this issue, specify another compression method in the Transfer Syntax. For example, to set the Transfer Syntax to lossless JPEG endcoding, use the following code:
info.TransferSyntaxUID = '1.2.840.10008.1.2.4.70'