-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinbreastBuilder.m
82 lines (70 loc) · 2.37 KB
/
inbreastBuilder.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
% INbreast Release 1.0
%Breast Research Group, INESC Porto, Portugal
%http://medicalresearch.inescporto.pt/breastresearch/
xlsdata= read_mixed_csv('../INBreast.csv',';');
biradsclass = xlsdata(2:end,8);
biradsclassFilename=xlsdata(2:end,6);
date=xlsdata(2:end,5);
[sortedFilenames,idx]=sort(biradsclassFilename);
biradsclass=biradsclass(idx);
date=date(idx);
DIR = dir('.\*.dcm');
nn=numel(DIR);
INbreast=cell(nn,8);
for k=1:nn
disp(num2str(k))
info=dicominfo(DIR(k).name);
INbreast{k,1}=k;
lineData = textscan(DIR(k).name, '%s', 'Delimiter','_');
lineData = lineData{1};
%INbreast{k,2} is empty - name
INbreast{k,3}=lineData{2};%patient ID
INbreast{k,4}=lineData{3}; %Modality - MG
INbreast{k,5}=lineData{5}; %ViewPosition CC or ML(O)
%INbreast{k,6} is empty - date
INbreast{k,7}=DIR(k).name;
%INbreast{k,8} is empty - birads
end
dicomFilename=INbreast(:,7);
[sortedFilenames,idx]=sort(dicomFilename);
INbreast=INbreast(idx,:);
INbreast(:,8)=biradsclass;
INbreast(:,6)=date;
%organize by cases: a case is the set of all views for a single patient for
%a single day. We have 117 cases.
%IMPORTANT NOTE: in the Academic Radiology publication the number is wrongly presented as 115.
PatientInfo=strcat(INbreast(:,3),INbreast(:,6));
uniquePatientInfo=unique(PatientInfo);
for n=1:length(uniquePatientInfo)
idx = find(ismember(PatientInfo, uniquePatientInfo(n))==1);
INbreastCase{n}=idx;
end
%just usage example
caseBirads =-10*ones(length(INbreastCase),1);
caseLen = zeros(length(INbreastCase),1);
for n=1:length(INbreastCase)
% disp(['case ', num2str(n)]);
curr_case = INbreastCase{n};
curr_biradsSet=[];
caseLen(n)=length(curr_case);
for i=1:length(curr_case)
filename = INbreast{curr_case(i),7};
birads= INbreast{curr_case(i),8};
negFolder = 'neg';
posFolder = 'pos';
if contains(birads, "1") || contains(birads, "2")
copyfile([filename],[negFolder]);
end
if contains(birads, "4") || contains(birads, "5") || contains(birads, "6")
copyfile([filename],[posFolder]);
end
curr_biradsSet=[curr_biradsSet,sscanf(birads, '%g')];
%img=dicomread(filename);
%imshow(img,[]);
end
caseBirads(n)=max(curr_biradsSet);
end
%[caseLen caseBirads]
% figure, hist(caseLen, 1:8)
% figure, hist(caseBirads, 0:6)