필터 지우기
필터 지우기

Issue with writing DICOM images to a folder ('Could not open folder for writing' error)

조회 수: 8 (최근 30일)
I have a script to apply a manual segmentation to a set of DICOM images in a for loop. I want to write the segmentation for each image to a specific (initially empty) folder.
baseFileName = sprintf('%s_%d.dcm', cnt);
fullFileName = fullfile(pwd, 'Project_Segmentations', baseFileName);
dicomwrite(segmentation, fullFileName);
The error message I'm getting is:
Error using dicom_open_msg (line 31)
Could not open "Project\DICOMs_Project\_" for writing
Error in dicomwrite>write_stream (line 660)
file = dicom_open_msg(file, 'w');
Error in dicomwrite>encodeAndWriteAttrs (line 325)
msg = write_stream(destination, data_stream);
Error in dicomwrite>write_message (line 282)
encodeAndWriteAttrs(attrs, options, filename, specificCharacterSet);
Error in dicomwrite (line 208)
[status, options] = write_message(X, filename, map, metadata, options);
Error in ManualSegmentationFull (line 80)
dicomwrite(segmentation, fullFileName);
Thanks in advance for any advice you may have!

채택된 답변

Cameron Harris
Cameron Harris 2018년 2월 20일
The problem seemed to be down to trying to use, I think it must have been creating an invalid file name:
'%s_%d.dcm'
This code actually works fine, writing to the correct folder, when I simply use:
baseFileName = sprintf('Segmentation_%d.dcm', cnt);
fullFileName = fullfile(pwd, 'Project_Segmentations',baseFileName);
% Write the DICOM segmentation to the folder.
dicomwrite(segmentation, fullFileName);
What I actually want is for the DICOMs to be written with the file name format of 'OrginalFileName_Segmentation.dcm'. If anyone can advise me on this it'd be really helpful, but for now the file name format I'm using is acceptable for my application.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by