a b/scripts/cv_analysis/pp.py
1
#==============================================================================#
2
#  Author:       Dominik Müller                                                #
3
#  Copyright:    2020 IT-Infrastructure for Translational Medical Research,    #
4
#                University of Augsburg                                        #
5
#                                                                              #
6
#  This program is free software: you can redistribute it and/or modify        #
7
#  it under the terms of the GNU General Public License as published by        #
8
#  the Free Software Foundation, either version 3 of the License, or           #
9
#  (at your option) any later version.                                         #
10
#                                                                              #
11
#  This program is distributed in the hope that it will be useful,             #
12
#  but WITHOUT ANY WARRANTY; without even the implied warranty of              #
13
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
14
#  GNU General Public License for more details.                                #
15
#                                                                              #
16
#  You should have received a copy of the GNU General Public License           #
17
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
18
#==============================================================================#
19
#-----------------------------------------------------#
20
#                   Library imports                   #
21
#-----------------------------------------------------#
22
import tensorflow as tf
23
from miscnn.data_loading.interfaces import NIFTI_interface
24
from miscnn import Data_IO
25
from miscnn.evaluation.cross_validation import split_folds
26
27
#-----------------------------------------------------#
28
#                Running Preprocessing                #
29
#-----------------------------------------------------#
30
for i in range(2,5):
31
    # Initialize Data IO Interface for NIfTI data
32
    ## We are using 4 classes due to [background, lung_left, lung_right, covid-19]
33
    interface = NIFTI_interface(channels=1, classes=4)
34
35
    # Create Data IO object to load and write samples in the file structure
36
    data_io = Data_IO(interface, input_path="data", delete_batchDir=False)
37
38
    # Access all available samples in our file structure
39
    sample_list = data_io.get_indiceslist()
40
    sample_list.sort()
41
42
    # Split samples into k (training, validation) folds
43
    split_folds(sample_list, k_fold=i, evaluation_path="evaluation.cv" + str(i))