Created
January 3, 2019 15:16
-
-
Save jcreinhold/5b8ae8a675139aeb4c33ef071a85e864 to your computer and use it in GitHub Desktop.
dataloaders for fastai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fastai.vision as faiv | |
import nibabel as nib | |
def open_nii(fn:str) -> faiv.Image: | |
""" Return fastai `Image` object created from NIfTI image in file `fn`.""" | |
x = nib.load(str(fn)).get_data() | |
return faiv.Image(torch.Tensor(x)) | |
class NiftiItemList(faiv.ImageItemList): | |
""" custom item list for nifti files """ | |
def open(self, fn:faiv.PathOrStr)->faiv.Image: return open_nii(fn) | |
class NiftiNiftiList(NiftiItemList): | |
""" item list suitable for synthesis tasks """ | |
_label_cls = NiftiItemList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment