フォルダ内の特定のファイルを別ファイルに移動したいです。
5 views (last 30 days)
Show older comments
フォルダ内に入れている大量のdicomファイルを読み込んでいたのですが、特定の複数のdicomファイルのみ
警告: 問題のありそうな断片的なファイルです。DICOM ではない可能性があります。
などのエラーが出てきてしまいます。
そこで、警告が出てきてしまうファイルのみ別フォルダに移動させたいのですが、どのようなスクリプトを書けばよいのでしょうか。
0 Comments
Accepted Answer
Atsushi Ueno
on 11 Dec 2022
Edited: Atsushi Ueno
on 11 Dec 2022
cur = pwd;
copyfile('/MATLAB/toolbox/matlab/imagesci/peppers.png',cur);
copyfile('/MATLAB/toolbox/images/imdata/CT-MONO2-16-ankle.dcm',cur);
copyfile('/MATLAB/toolbox/images/imdata/US-PAL-8-10x-echo.dcm',cur);
movefile peppers.png peppers.dcm % peppers.pngを偽のdcmファイルにしておく
mkdir temp % 空のtempフォルダを作成
ls -la % ここまでサンプルデータの作成です
list_dicom = dir([pwd,filesep,'*.dcm']);
for j = 1:size(list_dicom,1)
warning('') % 最後のワーニングメッセージを削除
data{j} = dicomread([list_dicom(j).folder,filesep,list_dicom(j).name]);
[warnMsg, warnId] = lastwarn;
if ~isempty(warnMsg)
movefile([list_dicom(j).folder,filesep,list_dicom(j).name] ...
,[cur,filesep,'temp',filesep,list_dicom(j).name])
end
end
ls -la
ls temp -la
偽のpeppers.dcmファイルがtempフォルダに移動された事を確認しました。
More Answers (0)
See Also
Categories
Find more on DICOM Format in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!