12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- %% Author: Aleks Prša
- % Date: May, 2022
- % alex.prsa@gmail.com
- % =========================================================================
- %{
- % -------------------------------------------------------------------------
- % writeDcm(dataRecon3d,filestring,parameter)
- % -------------------------------------------------------------------------
- % DESCRIPTION:
- % This function write a set of Dicom images with respective headers.
- %
- %
- % INPUT:
- % - dataRecon3d = Reconstructed data
- % - filestring = Path to save
- % - parameter = Parameter of all geometry
- %
- % ---------------------------------------------------------------------
- %}
- % =========================================================================
- %% Write Dicom images
- function writeDcm(dataRecon3d,filestring,parameter)
- if(~exist(filestring))
- mkdir(filestring)
- end
- for k=1:size(dataRecon3d,2)
- dataRecon3d{1,k} = dataRecon3d{1,k} + abs(min(dataRecon3d{1,k}(:)));
- dataRecon3d{1,k} = (2^16-1).*mat2gray(dataRecon3d{1,k});
- dataRecon3d{1,k} = uint16(dataRecon3d{1,k});
- end
- % Write dicom files in respective folder
- fprintf('\nWriting images ')
- fprintf('%3d/%3d', 1, parameter.nz)
- for i=1:size(dataRecon3d{1,k},3)
- fprintf('\b\b\b\b\b\b\b%3d/%3d', i, parameter.nz)
- if(i<10)
- fileimg = [filestring,filesep,'0',num2str(i),'.dcm'];
- else
- fileimg = [filestring,filesep,num2str(i),'.dcm'];
- end
- dicomwrite(dataRecon3d{1,k}(:,:,i), fileimg);
- end
- end
|