2016-11-10 20 views
1

我正在使用包含尺寸爲155x240x240的三維MRI圖像的MICCAI BRATS 2015數據庫。如何在medpy.filter.IntensityRangeStandardization()中輸入3D圖像?

我想對這些圖像執行強度標準化,並試圖使用medpy.filter中的IntensityRangeStandardization類。 代碼很簡單:

負載20天才從數據庫中的圖像到一個數組:

from glob import glob 
import SimpleITK as sitk 

pth = 'C:/BRats2015/HGG' #path to the directory 
flair = glob(self.path + '*/*Flair*/*.mha') #contain paths to all images 
flair = flair[:20] #choose 20 images 

#load the 20 images in sitk format 
im = [] 
for i in flair: 
    im.append(sitk.ReadImage(i)) 

#convert them into numpy array 
for i in xrange(len(im)): 
    im[i] = sitk.GetArrayFromImage(im[i]) 

#initialize the filter 
normalizer = IntensityRangeStandardization() 

#train and transform the images 
im_n = normalizer.train_transform(im)[1] # the second returned variable contains the new images,            # hence [1] 

我收到以下錯誤信息:

File "intensity_range_standardization.py", line 268, in train 
    self.__stdrange = self.__compute_stdrange(images) 

    File "intensity_range_standardization.py", line 451, in __compute_stdrange 
    raise SingleIntensityAccumulationError('Image no.{} shows an unusual single-intensity accumulation that leads to a situation where two percentile values are equal. This situation is usually caused, when the background has not been removed from the image. Another possibility would be to reduce the number of landmark percentiles landmarkp or to change their distribution.'.format(idx)) 

SingleIntensityAccumulationError: Image no.0 shows an unusual single-intensity accumulation that leads to a situation where two percentile values are equal. This situation is usually caused, when the background has not been removed from the image. Another possibility would be to reduce the number of landmark percentiles landmarkp or to change their distribution. 

回答

0

好吧,我想通了如何調用功能train_transform如果我們分別給予圖像和他們的面具。以下是medpy github repo的代碼。

重塑圖片應該很容易,但我還是會只是張貼在任何混亂的情況下,鏈接到代碼:Reshape the new images

+0

@V Shreyas:爲了重塑形象,我使用的代碼,'R,出= n.train_transform([i [m] for i,m in zip(im_ar,im_msk)]) for i,m,o in zip(im_ar,im_msk,out): i [m] = o'。但是,當我打印'i'的形狀時,它是'155x240x240',而不是'155x240x240x20',因爲我們發送了20張圖像進行歸一化。那麼,我們如何才能獲得20張圖像的變形圖像? – user8264