Generate image data info. Note that image files with sample code not
tic
dirData = 'C:\image-mRNA-prognostic-model-master\bin.png';
list = dir(dirData);
list = list(3:end);
nList = numel(list);
imageInfo.file = cell(nList, 1);
imageInfo.pid = cell(nList, 1);
tissue = cell(nList, 1);
for i = 1:nList
sublist = dir([dirData, list(i).name, '/*.svs']);
tissue{i} = sublist.name(14:15);
imageInfo.file{i} = [list(i).name, '/', sublist.name];
imageInfo.pid{i} = sublist.name(1:15);
fprintf('%d/%d finished\n', i, nList);
end
indTumor = strcmp(tissue, '01');
imageInfo.file = imageInfo.file(indTumor);
imageInfo.pid = imageInfo.pid(indTumor);
[imageInfo.pid, ind] = sort(imageInfo.pid);
imageInfo.file = imageInfo.file(ind);
openslide_load_library();
nFiles = numel(imageInfo.file);
imageInfo.mppX = zeros(nFiles, 1);
imageInfo.mppY = zeros(nFiles, 1);
imageInfo.width = zeros(nFiles, 1);
imageInfo.height = zeros(nFiles, 1);
imageInfo.mag = zeros(nFiles, 1);
for i = 1:nFiles
slidePtr = openslide_open([dirData, imageInfo.file{i}]);
[imageInfo.mppX(i, 1),...
imageInfo.mppY(i, 1),...
imageInfo.width(i, 1),...
imageInfo.height(i, 1),...
numberOfLevels,...
downsampleFactors,...
imageInfo.mag(i, 1)] = openslide_get_slide_properties(slidePtr);
fprintf('%d/%d finished\n', i, nFiles);
end
toc
openslide_close(slidePtr )
clear slidePtr
openslide_unload_library
imageInfo = struct2table(imageInfo);
indOk = imageInfo.mag ~= 5;
imageInfo = imageInfo(indOk, :);
save imageInfo imageInfo