Showing
3 changed files
with
7 additions
and
102 deletions
1 | inputheader = '..\data\MICCAI_BraTS_2019_Data_Training\HGG_seg_flair\'; | 1 | inputheader = '..\data\MICCAI_BraTS_2019_Data_Training\HGG_seg_flair\'; |
2 | -outfolder = '..\data\MICCAI_BraTS_2019_Data_Training\total_frame\'; | 2 | +outfolder = '..\data\MICCAI_BraTS_2019_Data_Training\total_frame_m255\'; |
3 | 3 | ||
4 | files = dir(inputheader); | 4 | files = dir(inputheader); |
5 | id = {files.name}; | 5 | id = {files.name}; |
... | @@ -8,7 +8,7 @@ flag = ~strcmp(id, '.') & ~strcmp(id, '..'); | ... | @@ -8,7 +8,7 @@ flag = ~strcmp(id, '.') & ~strcmp(id, '..'); |
8 | files = files(flag); | 8 | files = files(flag); |
9 | 9 | ||
10 | 10 | ||
11 | -for i = 1 : length(files) | 11 | +for i = 1 : 1%length(files) |
12 | 12 | ||
13 | id = split(files(i).name, '.nii'); | 13 | id = split(files(i).name, '.nii'); |
14 | id = char(id(1)); | 14 | id = char(id(1)); |
... | @@ -42,7 +42,11 @@ for i = 1 : length(files) | ... | @@ -42,7 +42,11 @@ for i = 1 : length(files) |
42 | filename = strcat(id, '_', int2str(c), type); % BraTS19_2013_2_1_seg_flair_c.png | 42 | filename = strcat(id, '_', int2str(c), type); % BraTS19_2013_2_1_seg_flair_c.png |
43 | outpath = strcat(outfolder, filename); | 43 | outpath = strcat(outfolder, filename); |
44 | % typecase int16 to double, range[0, 1], rotate 90 and filp updown | 44 | % typecase int16 to double, range[0, 1], rotate 90 and filp updown |
45 | - cp_data = flipud(rot90(mat2gray(double(data(:,:,k))))); | 45 | + % range [0, 1] |
46 | + %cp_data = flipud(rot90(mat2gray(double(data(:,:,k))))); | ||
47 | + cp_data = flipud(rot90(mat2gray(double(data(:,:,k))))).*255; | ||
48 | +% M = max(cp_data(:)); | ||
49 | +% disp(M); | ||
46 | imwrite(cp_data, outpath); | 50 | imwrite(cp_data, outpath); |
47 | 51 | ||
48 | c = c+ 1; | 52 | c = c+ 1; | ... | ... |
code/shape_exception_handling.m
deleted
100644 → 0
1 | -data_path = '..\data\MICCAI_BraTS_2019_Data_Training\HGG_seg_flair\BraTS19_CBICA_AVG_1_seg_flair.nii'; | ||
2 | -data = niftiread(data_path); | ||
3 | - | ||
4 | -cp_data = flipud(rot90(mat2gray(double(data(:,:,82))))); | ||
5 | - | ||
6 | -type = '.png'; | ||
7 | -filename = strcat('BraTS19_CBICA_AVG_1_seg_flair_8', type); % BraTS19_2013_2_1_seg_flair_c.png | ||
8 | -outpath = strcat('..\data\MICCAI_BraTS_2019_Data_Training\zero to valid\', filename); | ||
9 | -imwrite(cp_data, outpath); | ||
10 | - | ||
11 | - | ||
12 | -% st, end 10 | ||
13 | - | ||
14 | -%% (circle 0, ellipse 0) | ||
15 | -% BraTS19_CBICA_AOP_1_seg_flair_0 | ||
16 | -% BraTS19_CBICA_ASF_1_seg_flair_9 -> 8 | ||
17 | -% BraTS19_CBICA_ASR_1_seg_flair_8 | ||
18 | -% BraTS19_CBICA_ASR_1_seg_flair_9 | ||
19 | -% BraTS19_CBICA_AVG_1_seg_flair_9 -> 8 | ||
20 | -% | ||
21 | -% | ||
22 | -% | ||
23 | -% | ||
24 | -% | ||
25 | -% | ||
26 | -% | ||
27 | -% | ||
28 | -% | ||
29 | -% | ||
30 | -% | ||
31 | -% | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
code/shape_exception_handling_all.m
deleted
100644 → 0
1 | -getname_path = '..\data\MICCAI_BraTS_2019_Data_Training\zero2\'; | ||
2 | -inputheader = '..\data\MICCAI_BraTS_2019_Data_Training\HGG_seg_flair\'; | ||
3 | -outfolder = '..\data\MICCAI_BraTS_2019_Data_Training\zero to valid2\'; | ||
4 | - | ||
5 | -files = dir(getname_path); | ||
6 | -id = {files.name}; | ||
7 | -% files + dir file | ||
8 | -flag = ~strcmp(id, '.') & ~strcmp(id, '..'); | ||
9 | -files = files(flag); | ||
10 | - | ||
11 | -% get filenames in getname_path folder | ||
12 | -for i = 1 : length(files) | ||
13 | - %id = split(files(i).name, '.nii'); | ||
14 | - fname = files(i).name; | ||
15 | - id = reverse(extractBetween(reverse(fname), 7, strlength(fname))); | ||
16 | - | ||
17 | - data_path = convertCharsToStrings(strcat(inputheader,'\', id, '.nii')); | ||
18 | - data = niftiread(data_path); | ||
19 | - | ||
20 | - fprintf('ID #%d = %s\n', i, data_path); | ||
21 | - | ||
22 | - idx = 1; | ||
23 | - frames = zeros(1,1); | ||
24 | - for j = 1 : z | ||
25 | - n_nonblack = numel(find(data(:,:,j) > 0)); | ||
26 | - if(n_nonblack > 70) | ||
27 | - frames(idx,1) = j; | ||
28 | - idx = idx + 1; | ||
29 | - end | ||
30 | - end | ||
31 | - | ||
32 | -% for j = z : -1 : 1 | ||
33 | -% n_nonblack = numel(find(data(:,:,j) > 0)); | ||
34 | -% if(n_nonblack > 50) | ||
35 | -% fprintf('%s: %d\n ','number: ', n_nonblack); | ||
36 | -% en = j; | ||
37 | -% break; | ||
38 | -% end | ||
39 | -% end | ||
40 | - | ||
41 | - | ||
42 | - c = 0; | ||
43 | - [nrow, ncol] = size(frames); | ||
44 | - step = round(nrow/11); | ||
45 | -% fprintf('%s: %d \n', 'nrow', nrow); | ||
46 | -% fprintf('%s: %d\n ','st: ', frames(1, 1)); | ||
47 | -% fprintf('%s: %d\n ','end: ', frames(nrow, 1)); | ||
48 | - %disp(frames); | ||
49 | - | ||
50 | - for k = 1 : step : step*10 | ||
51 | - %fprintf('%d ', k); | ||
52 | - fprintf('%d ', frames(k, 1)); | ||
53 | - type = '.png'; | ||
54 | - filename = strcat(id, '_', int2str(c), type); % BraTS19_2013_2_1_seg_flair_c.png | ||
55 | - outpath = convertCharsToStrings(strcat(outfolder, filename)); | ||
56 | - % typecase int16 to double, range[0, 1], rotate 90 and filp updown | ||
57 | - % range [0, 1] | ||
58 | - cp_data = flipud(rot90(mat2gray(double(data(:,:,frames(k, 1)))))); | ||
59 | -% M = max(cp_data(:)); | ||
60 | -% disp(M); | ||
61 | - imwrite(cp_data, outpath); | ||
62 | - | ||
63 | - c = c+ 1; | ||
64 | - end | ||
65 | - | ||
66 | - | ||
67 | -end | ||
68 | - |
-
Please register or login to post a comment