|
5 | 5 |
|
6 | 6 | arguments
|
7 | 7 | srcFolder (1,:) char % source folder location of 3D brain volumes, organized by participant
|
8 |
| - dstFolder (1,:) char = '' % destination folder for 2D horizontal midslice images, organized by age class |
| 8 | + dstFolder (1,:) char = '' % destination folder for 2D axial midslice images, organized by age class |
9 | 9 | augmentDataset (1,1) logical = false % specify whether to apply offline data augmentation (a copy of image flipped 180 degrees).
|
10 | 10 | applySkullStripping (1,1) logical = false % specify whether to apply skull-stripping
|
11 | 11 | end
|
|
59 | 59 | end
|
60 | 60 |
|
61 | 61 |
|
62 |
| -% prepare2DImageDataset is a function that takes in the MRI image volume data for each label. It extracts the horizontal midslice of each MRI scan volume, applies normalization and other optional processing (skull stripping, augmentation), and saves the reduced 2D image dataset to a specified folder tree organized by label for downstream training, validation, and testing. |
| 62 | +% prepare2DImageDataset is a function that takes in the MRI image volume data for each label. It extracts the axial midslice of each MRI scan volume, applies normalization and other optional processing (skull stripping, augmentation), and saves the reduced 2D image dataset to a specified folder tree organized by label for downstream training, validation, and testing. |
63 | 63 | % The function's processing options can be used to:
|
64 | 64 | % strip the skull from the 2D images (imType set to 'strip')
|
65 | 65 | % augment the dataset by saving added copies of each 2D image flipped by 180 degrees (imModify set to true)
|
|
72 | 72 |
|
73 | 73 | [~, ~, k, ~] = size(srcData{1});
|
74 | 74 |
|
75 |
| -% Extract horizontal mid-slice from each image volume |
| 75 | +% Extract axial mid-slice from each image volume |
76 | 76 | mid_slices = cellfun(@squeeze,cellfun(@double,cellfun(@(x)x(:,:,round(k/2),1),srcData,'un',0),'UniformOutput',false),'UniformOutput',false);
|
77 | 77 |
|
78 | 78 | % Include data from the preprocessed image that does not include the skull
|
|
97 | 97 |
|
98 | 98 | avg_intensity = mean(cell2mat(cellfun(@imhist,convert2img,'UniformOutput',false)),2);
|
99 | 99 |
|
100 |
| -% Create a copy if the image and rorate the image by 180 degrees |
| 100 | +% Create a copy of the image and rotate it by 180 degrees |
101 | 101 | if applyAugmentation
|
102 | 102 | convert2img_2 = cellfun(@ind2rgb, cellfun(@(x)rot90(x,2),mid_slices,'UniformOutput',false),map,'UniformOutput',false);
|
103 | 103 | avg_intensity_2 = mean(cell2mat(cellfun(@imhist,convert2img_2,'UniformOutput',false)),2);
|
|
0 commit comments