Passed
Push — master ( 0b0a34...8a30f9 )
by Fernando
01:06
created

torchio.datasets.mni.sheep.Sheep.__init__()   A

Complexity

Conditions 2

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 15
nop 2
dl 0
loc 17
rs 9.65
c 0
b 0
f 0
1
import urllib.parse
2
from torchvision.datasets.utils import download_and_extract_archive
3
from ...utils import get_torchio_cache_dir
4
from ... import Image
5
from .mni import SubjectMNI
6
7
8
class Sheep(SubjectMNI):
9
    def __init__(self, version=1998):
10
        self.name = 'NIFTI_ovine_05mm'
11
        self.url_dir = urllib.parse.urljoin(self.url_base, 'sheep/')
12
        self.filename = f'{self.name}.zip'
13
        self.url = urllib.parse.urljoin(self.url_dir, self.filename)
14
        download_root = get_torchio_cache_dir() / self.name
15
        if download_root.is_dir():
16
            print(f'Using cache found in {download_root}')
17
        else:
18
            download_and_extract_archive(
19
                self.url,
20
                download_root=download_root,
21
                filename=self.filename,
22
            )
23
        t1_path = download_root / 'ovine_model_05.nii'
24
        super().__init__(
25
            t1=Image(t1_path)
26
        )
27