Пример #1
0
    def __getitem__(self, i):
        # Index the fname and slice using the list created in __init__

        fname, slice = self.examples[i]

        t1_path = os.path.join(self.t1_dir, fname)
        flair_path = os.path.join(self.flair_dir, fname)

        with h5py.File(flair_path, 'r') as data:

            flair_img = data[self.key_img][:, :, slice]
            flair_kspace = data[self.key_kspace][:, :, slice]
            flair_kspace = npComplexToTorch(flair_kspace)
            flair_target = data['volfs'][:, :, slice].astype(np.float64)

        with h5py.File(t1_path, 'r') as data:

            t1_img = data[self.key_img][:, :, slice]
            t1_kspace = data[self.key_kspace][:, :, slice]
            t1_kspace = npComplexToTorch(t1_kspace)
            t1_target = data['volfs'][:, :, slice].astype(np.float64)

            return torch.from_numpy(flair_img), flair_kspace, torch.from_numpy(
                t1_img), t1_kspace, torch.from_numpy(
                    flair_target), torch.from_numpy(t1_target), fname, slice
Пример #2
0
    def __getitem__(self, i):
        # Index the fname and slice using the list created in __init__
        
        fname, slice = self.examples[i]
        #print (fname)
        # Print statements 
        #print (type(fname),slice)
    
        with h5py.File(fname, 'r') as data:

            input_img  = data[self.key_img][:,:,slice]
            input_kspace  = data[self.key_kspace][:,:,slice]
            input_kspace = npComplexToTorch(input_kspace)
            target = data['volfs'][:,:,slice]

            #kspace_cmplx = np.fft.fft2(target,norm='ortho')
            #uskspace_cmplx = kspace_cmplx * self.mask
            #zf_img = np.abs(np.fft.ifft2(uskspace_cmplx,norm='ortho'))
 

            #if self.dataset_type == 'cardiac':
            if False:
                # Cardiac dataset should be padded,150 becomes 160. # this can be commented for kirby brain 
                input_img  = np.pad(input_img,(5,5),'constant',constant_values=(0,0))
                target = np.pad(target,(5,5),'constant',constant_values=(0,0))

            # Print statements
            #print (input.shape,target.shape)
            return torch.from_numpy(input_img), input_kspace, torch.from_numpy(target),str(fname.name),slice
Пример #3
0
    def __getitem__(self, i):
        
        fname = self.examples[i]
    
        with h5py.File(fname, 'r') as data:

            input_img  = data[self.key_img].value
            input_kspace  = data[self.key_kspace].value
            input_kspace = npComplexToTorch(input_kspace)
            target = data['volfs'].value
        
        return torch.from_numpy(input_img), input_kspace, torch.from_numpy(target),str(fname.name)
Пример #4
0
    def __getitem__(self, i):

        fpath, slice, context = self.examples[i]

        with h5py.File(fpath, 'r') as data:

            img = data[self.key_img][:, :, slice]
            kspace = data[self.key_kspace][:, :, slice]
            kspace = npComplexToTorch(kspace)
            target = data['volfs'][:, :, slice].astype(np.float64)

            return torch.from_numpy(img), kspace, torch.from_numpy(
                target), fpath, slice, context
Пример #5
0
    def __getitem__(self, i):
        # Index the fname and slice using the list created in __init__

        fname, slice = self.examples[i]

        data_path = os.path.join(self.data_dir, fname)

        with h5py.File(data_path, 'r') as data:

            img = data[self.key_img][:, :, slice]
            kspace = data[self.key_kspace][:, :, slice]
            kspace = npComplexToTorch(kspace)
            target = data['volfs'][:, :, slice].astype(np.float64)

            return torch.from_numpy(img), kspace, torch.from_numpy(
                target), fname, slice