赞
踩
最近在使用PANDA的过程中,出现了DWI的dicom文件夹输入存在问题的状况,对照manual中发现是因为医院为我们提供的DWI数据是42或84个(对应于2次扫描或4次扫描,没有进行按扫描次数分类。)这里我写了一个简单的安扫描次数分类的toolkit,可以针对42或84个扫描文件中的DWI进行批量分类处理。经过修改后相信适用于大家,注意操作环境是Linux下的matlab。
% 2016/4/11
% author: Changle Zhang
% funtion:sort DWI files by the scanning time
clc
clear all;
close all;
%load train
%[filename,pathname]=uigetfile({'*.dcm'},'choose any dcm file');
pathname='*'; % input the pathname
cd(pathname);
foldernamecell=dir;
dircells=struct2cell(foldernamecell);
foldernames=dircells(1,:);
folderlength=numel(foldernames);
for i=3:folderlength
folder=char(foldernames(i));
cd (folder);
cd DWI;
dirs=dir;
dircell=struct2cell(dirs)' ;
filenames=dircell(:,1);
length=numel(filenames)-2;
if (length==84)
mkdir('DWI1'); %depends on the number of scanning
mkdir('DWI2');
mkdir('DWI3');
mkdir('DWI4');
for n=3:numel(filenames)-2;
dcminfo=dicominfo(char(filenames(n)));
name1=dcminfo.AcquisitionNumber;
if (name1<=21)
copyfile(char(filenames(n)),'DWI1');
elseif (21<name1)&&(name1<=42)
copyfile(char(filenames(n)),'DWI2');
elseif (42<name1)&&(name1<=63)
copyfile(char(filenames(n)),'DWI3');
else
copyfile(char(filenames(n)),'DWI4');
end
end
elseif (length==42)
mkdir('DWI1'); %depends on the number of scanning
mkdir('DWI2');
for n=3:numel(filenames)-2;
dcminfo=dicominfo(char(filenames(n)));
name1=dcminfo.AcquisitionNumber;
if (name1<=21)
copyfile(char(filenames(n)),'DWI1');
else
copyfile(char(filenames(n)),'DWI2');
end
end
end
cd(pathname)
end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。