Dicomwrite writes empty file

I have a problem with dicomwrite which does not give any error but just writes an empty file. Even if I run the following code, starting from a legitimate DICOM file:

pkg load dicom
image = dicomread('dicomfile.dcm');
info = dicominfo('dicomfile.dcm');

I don’t get any error message and the file test_dicomwrite.dcm is created but it is empty.

I know that the dicom package relies on the libgdcm library and I’m not 100% sure I have it but I downloaded the Windows version of Octave that comes with the packages pre-installed and, if I search “libgdcm” in the Program Files of Octave I find a number of .dll files that seem to mirror the files in the library.

The info variable is a struct variable as I expect and image is an array of dimensions img_size, img_size, number_of_images. If I run
figure; imshow(image(:,:,1))
I get the figure that I expect so I don’t think the problem is in the variables.

Can anyone help?

My system

  • OS: e.g. Windows 10 Education 21H2
  • Octave version: Version 7.1.0
  • Installation method: Downloaded and installed “octave-7.1.0-w64-installer.exe” from Download

The gdcm library comes with the installer as does the installed dicom package.

From your example, you are loading in a dicomfile “dicomfile.dcm” and writing to a new name. Can you supply the dicom file dicomfile.dcm, or a sample one that shows the same behavior ?