Source code for torchio.datasets.itk_snap.itk_snap
importurllib.parsefrom...dataimportLabelMapfrom...dataimportScalarImagefrom...data.subjectimport_RawSubjectCopySubjectfrom...downloadimportdownload_and_extract_archivefrom...utilsimportget_torchio_cache_dirclassSubjectITKSNAP(_RawSubjectCopySubject):"""ITK-SNAP Image Data Downloads. See `the ITK-SNAP website`_ for more information. .. _the ITK-SNAP website: http://www.itksnap.org/pmwiki/pmwiki.php?n=Downloads.Data """# noqa: B950url_base='https://www.nitrc.org/frs/download.php/'def__init__(self,name,code):self.name=nameself.url_dir=urllib.parse.urljoin(self.url_base,f'{code}/')self.filename=f'{self.name}.zip'self.url=urllib.parse.urljoin(self.url_dir,self.filename)self.download_root=get_torchio_cache_dir()/self.nameifnotself.download_root.is_dir():download_and_extract_archive(self.url,download_root=self.download_root,filename=self.filename,)super().__init__(**self.get_kwargs())defget_kwargs(self):raiseNotImplementedError