Beispiel #1
0
    def test_pipeline(self):
        # build
        self.config.layout.build(self.config_path, self.experiment_path)
        names = {p.name for p in self.experiment_path.iterdir()}
        assert {'resources.config'
                } | {f'experiment_{i}'
                     for i in range(len(names) - 1)} == names

        # split
        ids = set(self.config.ids)
        test_ids = []

        for exp in self.experiment_path.iterdir():
            if exp.is_dir():
                train, val, test = [
                    set(load(exp / f'{name}_ids.json'))
                    for name in ['train', 'val', 'test']
                ]
                test_ids.append(test)

                assert not train & val
                assert not train & test
                assert not val & test
                assert ids == train | val | test

        for first, second in itertools.permutations(test_ids, 2):
            assert not first & second

        # training
        self.config.layout.run(self.experiment_path / 'resources.config',
                               folds=[0])
        assert load(self.experiment_path /
                    'experiment_0/test_metrics/accuracy.json') >= .95
Beispiel #2
0
 def load_wmh(self, identifier):
     return load(self._find(identifier) / 'wmh.nii.gz')
Beispiel #3
0
 def load_t1(self, identifier, folder='pre'):
     return load(self._find(identifier) / f'{folder}/T1.nii.gz')
Beispiel #4
0
 def load_flair(self, identifier, folder='pre'):
     return load(self._find(identifier) / f'{folder}/FLAIR.nii.gz')