フォルダ内の特定のフ​ァイルを別ファイルに​移動したいです。

8 visualizaciones (últimos 30 días)
秋葉
秋葉 el 11 de Dic. de 2022
Comentada: 秋葉 el 19 de Dic. de 2022
フォルダ内に入れている大量のdicomファイルを読み込んでいたのですが、特定の複数のdicomファイルのみ
警告: 問題のありそうな断片的なファイルです。DICOM ではない可能性があります。
などのエラーが出てきてしまいます。
そこで、警告が出てきてしまうファイルのみ別フォルダに移動させたいのですが、どのようなスクリプトを書けばよいのでしょうか。

Respuesta aceptada

Atsushi Ueno
Atsushi Ueno el 11 de Dic. de 2022
Editada: Atsushi Ueno el 11 de Dic. de 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 % ここまでサンプルデータの作成です
total 1288 drwxr-xr-x 3 mluser worker 4096 Dec 11 21:54 . drwx------ 1 mluser worker 4096 Dec 11 21:54 .. -r-xr-xr-x 1 mluser worker 525436 Dec 18 2000 CT-MONO2-16-ankle.dcm -r--r--r-- 1 mluser worker 287677 Dec 16 2002 peppers.dcm drwxr-xr-x 2 mluser worker 4096 Dec 11 21:54 temp -r-xr-xr-x 1 mluser worker 483610 Dec 18 2000 US-PAL-8-10x-echo.dcm
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
Warning: Suspicious fragmentary file, might not be DICOM.
Warning: Not enough data imported. Attempted to read 169478669 bytes at position 8. Only read 287669.
ls -la
total 1004 drwxr-xr-x 3 mluser worker 4096 Dec 11 21:54 . drwx------ 1 mluser worker 4096 Dec 11 21:54 .. -r-xr-xr-x 1 mluser worker 525436 Dec 18 2000 CT-MONO2-16-ankle.dcm drwxr-xr-x 2 mluser worker 4096 Dec 11 21:54 temp -r-xr-xr-x 1 mluser worker 483610 Dec 18 2000 US-PAL-8-10x-echo.dcm
ls temp -la
total 292 drwxr-xr-x 2 mluser worker 4096 Dec 11 21:54 . drwxr-xr-x 3 mluser worker 4096 Dec 11 21:54 .. -r--r--r-- 1 mluser worker 287677 Dec 16 2002 peppers.dcm
偽のpeppers.dcmファイルがtempフォルダに移動された事を確認しました。
  1 comentario
秋葉
秋葉 el 19 de Dic. de 2022
遅くなってしまい申し訳ございません.
ありがとうございました.
助かりました.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre DICOM Format en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!