nyukat / breast_cancer_classifier

Deep Neural Networks Improve Radiologists' Performance in Breast Cancer Screening
https://ieeexplore.ieee.org/document/8861376
GNU Affero General Public License v3.0
844 stars 269 forks source link

helper function #41

Closed nightandweather closed 4 years ago

nightandweather commented 4 years ago

thank you for your contributions.

using another dataset to this respository. this code can be useful.

`def divide_list(l, n):

리스트 l의 길이가 n이면 계속 반복

for i in range(0, len(l), n): 
    yield l[i:i + n] 

def make_dict(file_list):

print(file_list)

mkdict = {'horizontal_flip' :"NO",'L-CC' :[file_list[0].split('.')[0]],'L-MLO' : [file_list[1].split('.')[0]],'R-CC':[file_list[2].split('.')[0]],'R-MLO':[file_list[3].split('.')[0]]}
return mkdict

import natsort

sample_file_path = 'your folder path' sample_file_list = natsort.natsorted(os.listdir(sample_file)) n=4 result = list(divide_list(sample_file_list,n))

bin_list = [] for i in result: bin_list.append(make_dict(i)) with open(sample_file+ '/nccpatient.pkl','wb') as f: pickle.dump(bin_list,f) ` this code can make your pkl file.

Anyway, I have a question,

in your resposirtory, image_prediction.csv, left_benign,right_benign,left_malignant,right_malignant 0.0580,0.0754,0.0091,0.0179 0.0646,0.9536,0.0012,0.7258 0.4388,0.3526,0.2325,0.1061 0.3765,0.6483,0.0909,0.2597

Are these results ​​written in the order of patient number in the pklfile?

wooginawunan commented 4 years ago

Thank you for providing this helper! In the sample pickle file, we provide a list of exams and the predictions are in the same order with the order of exams.