|
| 1 | +% Convert ISBI to Net For LSTM |
| 2 | +sequence_length = 5; |
| 3 | + |
| 4 | +% im_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Training/DIC-C2DH-HeLa/01/t%03d.tif'; |
| 5 | +% test_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Challenge/DIC-C2DH-HeLa/01/t%03d.tif'; |
| 6 | +% seg_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Training/DIC-C2DH-HeLa/01_GT/SEG/man_Seg%03d.tif'; |
| 7 | +% net_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Training/DIC-C2DH-HeLa/01_GT/NET/'; |
| 8 | +% T = [2,5,21,31,33,39,54]; |
| 9 | +% im_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Training/DIC-C2DH-HeLa/02/t%03d.tif'; |
| 10 | +% test_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Challenge/DIC-C2DH-HeLa/02/t%03d.tif'; |
| 11 | +% seg_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Training/DIC-C2DH-HeLa/02_GT/SEG/man_Seg%03d.tif'; |
| 12 | +% net_path_base = '/Users/assafarbelle/Documents/ISBI-Data/Training/DIC-C2DH-HeLa/02_GT/NET/'; |
| 13 | +% T = [6,7,14,27,34,38,42,61,67]; |
| 14 | + |
| 15 | + |
| 16 | +im_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-N2DH-SIM+/01/t%03d.tif'; |
| 17 | +test_path_base = '/home/arbellea/ISBI-Challenge-Data/Challenge/Fluo-N2DH-SIM+/01/t%03d.tif'; |
| 18 | +seg_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-N2DH-SIM+/01_GT/SEG/man_seg%03d.tif'; |
| 19 | +net_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-N2DH-SIM+/01_GT/NET/'; |
| 20 | +T = 0:64; |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +% |
| 25 | +% im_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-N2DH-SIM+/02/t%03d.tif'; |
| 26 | +% test_path_base = '/home/arbellea/ISBI-Challenge-Data/Challenge/Fluo-N2DH-SIM+/02/t%03d.tif'; |
| 27 | +% seg_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-N2DH-SIM+/02_GT/SEG/man_seg%03d.tif'; |
| 28 | +% net_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-N2DH-SIM+/02_GT/NET/'; |
| 29 | +% T = 0:149; |
| 30 | + |
| 31 | +% % |
| 32 | +% im_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-C2DL-MSC/01/t%03d.tif'; |
| 33 | +% test_path_base = '/home/arbellea/ISBI-Challenge-Data/Challenge/Fluo-C2DL-MSC/01/t%03d.tif'; |
| 34 | +% seg_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-C2DL-MSC/01_GT/SEG/man_seg%03d.tif'; |
| 35 | +% net_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-C2DL-MSC/01_GT/NET/'; |
| 36 | +% T = [5,7,11,19,24,25,29,33,34,35,45]; |
| 37 | + |
| 38 | +% im_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-C2DL-MSC/02/t%03d.tif'; |
| 39 | +% test_path_base = '/home/arbellea/ISBI-Challenge-Data/Challenge/Fluo-C2DL-MSC/02/t%03d.tif'; |
| 40 | +% seg_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-C2DL-MSC/02_GT/SEG/man_seg%03d.tif'; |
| 41 | +% net_path_base = '/home/arbellea/ISBI-Challenge-Data/Training/Fluo-C2DL-MSC/02_GT/NET/'; |
| 42 | +% T = [0,3,5,6,7,8,9,10,11,12,]; |
| 43 | + |
| 44 | + |
| 45 | +%% |
| 46 | +mkdir(net_path_base) |
| 47 | +mkdir(fullfile(net_path_base,'Seg')) |
| 48 | +mkdir(fullfile(net_path_base,'Raw')) |
| 49 | +%% |
| 50 | +fidT = fopen(fullfile(net_path_base,'train_lstm.csv'),'w'); |
| 51 | +fidV = fopen(fullfile(net_path_base,'val_lstm.csv'),'w'); |
| 52 | +lenT = floor((numel(T)-sequence_length)/2); |
| 53 | +clear T2 |
| 54 | +for i = 1:lenT |
| 55 | + T2(2*i-1) = T(lenT+(i)); |
| 56 | + T2(2*i) = T(lenT-(i-1)); |
| 57 | + |
| 58 | +end |
| 59 | +if mod(numel(T),2) |
| 60 | + T2(end+1) = T(end); |
| 61 | +end |
| 62 | +for i = 1:numel(T) |
| 63 | + t = T2(i); |
| 64 | + im_path = sprintf(im_path_base,t); |
| 65 | + seg_path = sprintf(seg_path_base,t); |
| 66 | + S = imread(seg_path); |
| 67 | + I = imread(im_path); |
| 68 | + s = size(S); |
| 69 | + RGB = zeros(s(1),s(2),3); |
| 70 | + RGB(:,:,1) = S==0; |
| 71 | + E = zeros(s); |
| 72 | + F = zeros(s); |
| 73 | + for l = unique(S(S>0))' |
| 74 | + BW = imerode(S==l,ones(3)); |
| 75 | + E(S==l&(~BW)) = 1; |
| 76 | + F(BW) = 1; |
| 77 | + end |
| 78 | + RGB(:,:,2) = F; |
| 79 | + RGB(:,:,3) = E; |
| 80 | + L = RGB(:,:,2) + RGB(:,:,3)*2; |
| 81 | + out_row = ''; |
| 82 | + for tt = 0:(sequence_length-1) |
| 83 | + out_row = sprintf('%s./Raw/t%03d.png,./Seg/t%03d.png',out_row,t+tt,t+tt); |
| 84 | + |
| 85 | + if tt<(sequence_length-1) |
| 86 | + out_row = sprintf('%s,',out_row); |
| 87 | + else |
| 88 | + out_row = sprintf('%s\n',out_row); |
| 89 | + end |
| 90 | + end |
| 91 | + if i/numel(T)<0.7 |
| 92 | + fprintf(fidT,out_row); |
| 93 | + else |
| 94 | + |
| 95 | + fprintf(fidV,out_row); |
| 96 | + end |
| 97 | + %I = uint16(I); |
| 98 | + %imwrite(I, fullfile(net_path_base,out_im_path)) |
| 99 | + %imwrite(uint8(L),fullfile(net_path_base,out_seg_path)) |
| 100 | +end |
| 101 | +fclose(fidT); |
| 102 | + |
| 103 | +fclose(fidV); |
| 104 | +%% |
| 105 | +t=0; |
| 106 | +fid = fopen(fullfile(net_path_base,'test_lstm.csv'),'w'); |
| 107 | +mkdir(fullfile(net_path_base,'ALL')) |
| 108 | +while true |
| 109 | + im_path = sprintf(test_path_base,t); |
| 110 | + if ~exist(im_path,'file') |
| 111 | + fprintf('%s Does not exist.\n Done\n', im_path); |
| 112 | + break |
| 113 | + end |
| 114 | + out_im_path = sprintf('./ALL/t%03d.png',t); |
| 115 | + I = uint16(imread(im_path)); |
| 116 | + imwrite(I, fullfile(net_path_base,out_im_path)); |
| 117 | + fprintf(fid,'%s\n', out_im_path); |
| 118 | + t = t+1; |
| 119 | +end |
| 120 | +fclose(fid); |
| 121 | + |
| 122 | +%% |
| 123 | + |
| 124 | +t=0; |
| 125 | +fid = fopen(fullfile(net_path_base,'test_train_lstm.csv'),'w'); |
| 126 | +mkdir(fullfile(net_path_base,'ALL_Train')) |
| 127 | +while true |
| 128 | + im_path = sprintf( im_path_base,t); |
| 129 | + if ~exist(im_path,'file') |
| 130 | + fprintf('%s Does not exist.\n Done\n', im_path); |
| 131 | + break |
| 132 | + end |
| 133 | + out_im_path = sprintf('./ALL_Train/t%03d.png',t); |
| 134 | + I = uint16(imread(im_path)); |
| 135 | + imwrite(I, fullfile(net_path_base,out_im_path)); |
| 136 | + fprintf(fid,'%s\n', out_im_path); |
| 137 | + t = t+1; |
| 138 | +end |
| 139 | +fclose(fid); |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
0 commit comments