示例#1
0
class testUtils(unittest.TestCase):
    "test class for the DataProvider module"
    def setUp(self):
        self.data_provider = DataProvider()
        self.number = 2

    def test_datasets(self):
        attrs = dict(size=1, files=2)
        datasets = self.data_provider.datasets(self.number, **attrs)
        print "\ndatasets:\n", datasets
        self.assertEqual(self.number, len(datasets))

    def test_blocks(self):
        attrs = {'is-open':'y'}
        blocks = self.data_provider.blocks(self.number, **attrs)
        print "\nblocks:\n", blocks
        self.assertEqual(self.number, len(blocks))

    def test_files(self):
        attrs = dict(adler32='abcd')
        files = self.data_provider.files(self.number, **attrs)
        print "\nfiles:\n", files
        self.assertEqual(self.number, len(files))

    def test_lumis(self):
        attrs = {}
        lumis = self.data_provider.lumis(self.number, **attrs)
        print "\nlumis:\n", lumis
        self.assertEqual(self.number, len(lumis))
示例#2
0
valid_set = fold1_list.copy()
test_set = np.load(data_path +
                   '/whole_data/validation_file.npy').tolist().copy()

org_suffix = '_orig.nii.gz'
lab_suffix = '_multiclass_pve.nii.gz'

pre = {
    org_suffix: [('channelcheck', 1)],
    lab_suffix: [('one-hot', 5), ('channelcheck', 5)]
}

processor = SimpleImageProcessor(pre=pre)

train_provider = DataProvider(train_set, [org_suffix, lab_suffix],
                              is_pre_load=False,
                              processor=processor)

validation_provider = DataProvider(valid_set, [org_suffix, lab_suffix],
                                   is_pre_load=False,
                                   processor=processor)

u_net = UNet3D(n_class=5, n_layer=4, root_filters=16, use_bn=True)

model = SimpleTFModel(u_net,
                      org_suffix,
                      lab_suffix,
                      dropout=0,
                      loss_function={'cross-entropy': 1.},
                      weight_function={'balance'})
optimizer = tf.keras.optimizers.Adam(args.learning_rate)
示例#3
0
 def setUp(self):
     self.data_provider = DataProvider()
     self.number = 2
示例#4
0
train_list = file_mat['train_set']
valid_list = file_mat['validation_set']
test_list = file_mat['test_set']
# add path to filename

org_suffix = '.nii.gz'
age_suffix = '_lab.txt'

pre = {org_suffix: [('zero-mean'), ('min-max'), ('channelcheck', 1)]}
# processor = Processor()
processor = SimpleImageProcessor(pre=pre)

train_provider = DataProvider(
    train_list,
    [org_suffix, age_suffix],
    is_pre_load=False,
    is_shuffle=True,
    # temp_dir=output_path,
    processor=processor)

valid_provider = DataProvider(
    valid_list,
    [org_suffix, age_suffix],
    is_pre_load=False,
    # temp_dir=output_path,
    processor=processor)

# build model
gen = Generator(output_channels=1, use_bn=use_bn)
disc = Discriminator(use_bn=use_bn)
# gen = Generator(n_class=1, n_layer=6, root_filters=16, use_bn=use_bn, use_res=use_res)
示例#5
0
def get_phonebook_name(data_provider: DataProvider) -> Union[str, None]:
    if Validator.check_arguments(data_provider):
        return data_provider.get_argument()
    return None
示例#6
0
文件: views.py 项目: walxin/chartto
    def get_data(self):
        """ Get data to show in the view; format depends on the type """
        dp = DataProvider(
        )  # could use the Todoist API directly, this is a bit for the future; to support weird data formats

        return {}  # wx2 NotImplementedError on get data for view
示例#7
0
文件: views.py 项目: walxin/chartto
 def __init__(self, type):
     if type not in self.SUPPORTED_TYPES:
         pass  # wx3: type validation: without valid type we shouldn't init
     self.type = type
     self.dp = DataProvider()