フォルダ内の特定のファイルを別ファイルに移動したいです。
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
フォルダ内に入れている大量のdicomファイルを読み込んでいたのですが、特定の複数のdicomファイルのみ
警告: 問題のありそうな断片的なファイルです。DICOM ではない可能性があります。
などのエラーが出てきてしまいます。
そこで、警告が出てきてしまうファイルのみ別フォルダに移動させたいのですが、どのようなスクリプトを書けばよいのでしょうか。
0 commentaires
Réponse acceptée
Atsushi Ueno
le 11 Déc 2022
Modifié(e) : Atsushi Ueno
le 11 Déc 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フォルダに移動された事を確認しました。
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur DICOM Format dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!