当前位置: 首页>>代码示例>>Python>>正文


Python SimpleITK.ImageSeriesReader方法代码示例

本文整理汇总了Python中SimpleITK.ImageSeriesReader方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleITK.ImageSeriesReader方法的具体用法?Python SimpleITK.ImageSeriesReader怎么用?Python SimpleITK.ImageSeriesReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleITK的用法示例。


在下文中一共展示了SimpleITK.ImageSeriesReader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _transform

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import ImageSeriesReader [as 别名]
def _transform(dcm_dir,save_dir):
###   from dcm to nii
    reader = sitk.ImageSeriesReader()
    dicom_names = reader.GetGDCMSeriesFileNames(dcm_dir)
    reader.SetFileNames(dicom_names)
    image2 = reader.Execute()
    
###   transform 3D image to array
    image_array = sitk.GetArrayFromImage(image2)  #  z,y,x

###   crop the dark voxel
#    new_array,range_list = get_bound(image_array)


###   transform array to 3D image
    image3 = sitk.GetImageFromArray(image_array)

###   save 3D image
    name = dcm_dir.split('/')[-1] + '.nii'
    save_path = os.path.join(save_dir,name)   #   get the save path
    sitk.WriteImage(image3,save_path) 
开发者ID:wcfzl,项目名称:3D-CNNs-for-Liver-Classification,代码行数:23,代码来源:crop_transform.py

示例2: _read_dicom

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import ImageSeriesReader [as 别名]
def _read_dicom(directory: TypePath):
    directory = Path(directory)
    if not directory.is_dir():  # unreachable if called from _read_sitk
        raise FileNotFoundError(f'Directory "{directory}" not found')
    reader = sitk.ImageSeriesReader()
    dicom_names = reader.GetGDCMSeriesFileNames(str(directory))
    if not dicom_names:
        message = (
            f'The directory "{directory}"'
            ' does not seem to contain DICOM files'
        )
        raise FileNotFoundError(message)
    reader.SetFileNames(dicom_names)
    image = reader.Execute()
    return image 
开发者ID:fepegar,项目名称:torchio,代码行数:17,代码来源:io.py

示例3: main

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import ImageSeriesReader [as 别名]
def main():
    path='/home/dongnie/warehouse/pelvicSeg/newData/pelvic_0118/'
    subpath='atkinson_lafayette'
    outfn=subpath+'.nii.gz'
    inputdir=path+subpath
    scan=ScanFile(path)  
    subdirs=scan.scan_subdir()  
    for subdir in subdirs:
        if subdir==path or subdir=='..':
            continue
        
        print 'subdir is, ',subdir
        
        ss=subdir.split('/')
        print 'ss is, ',ss, 'and s7 is, ',ss[7]
        
        outfn=ss[7]+'.nii.gz'
        
        reader = sitk.ImageSeriesReader()

        dicom_names = reader.GetGDCMSeriesFileNames(subdir)
        reader.SetFileNames(dicom_names)
        
        image = reader.Execute()
        
        size = image.GetSize()
        print( "Image size:", size[0], size[1], size[2] )
        
        print( "Writing image:", outfn)
        
        sitk.WriteImage(image,outfn) 
开发者ID:ginobilinie,项目名称:medSynthesisV1,代码行数:33,代码来源:dicom2Nii.py

示例4: load_dcm

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import ImageSeriesReader [as 别名]
def load_dcm(fpath):
    reader = sitk.ImageSeriesReader()
    dicom_names = reader.GetGDCMSeriesFileNames(fpath)
    reader.SetFileNames(dicom_names)
    reader.MetaDataDictionaryArrayUpdateOn()
    reader.LoadPrivateTagsOn()
    image = reader.Execute()
    image_array = sitk.GetArrayFromImage(image) # z, y, x
    return image_array, reader 
开发者ID:microsoft,项目名称:Recursive-Cascaded-Networks,代码行数:11,代码来源:demo.py

示例5: read_scan

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import ImageSeriesReader [as 别名]
def read_scan(path):
    uid = os.path.basename(path)
    if uid.split('.')[-1] == 'mhd':
        uid = uid[:-4]
        return sitk.ReadImage(path), uid

    reader = sitk.ImageSeriesReader()
    image_files = reader.GetGDCMSeriesFileNames(path)
    assert len(image_files) > 0
    if len(image_files) < settings.chunk_size:
        print('Ignoring %s - only %d slices' % (path, len(image_files)))
        return None, uid

    reader.SetFileNames(image_files)
    return reader.Execute(), uid 
开发者ID:anlthms,项目名称:dsb-2017,代码行数:17,代码来源:convert.py

示例6: ReadImageAndLabel

# 需要导入模块: import SimpleITK [as 别名]
# 或者: from SimpleITK import ImageSeriesReader [as 别名]
def ReadImageAndLabel(CasePath,inverted=False):
    #Reading Images
    Reader = sitk.ImageSeriesReader()
    name=findfiles(CasePath+'img/','*.dcm')
    for i in range(len(name)):
        name[i]=int(name[i][0:-4])
    name=sorted(name)
    name=name[::-1]
    for i in range(len(name)):
        #print name[i],'\n'
        name[i]=CasePath+'img/'+str(name[i])+'.dcm'
 
    Reader.SetFileNames(name)
    Image = Reader.Execute()
    Spacing=Image.GetSpacing()
    Origin = Image.GetOrigin()
    Direction = Image.GetDirection()
    


    #Reading Labels
    name=findfiles(CasePath+'label/','*.PNG')
    name=sorted(name)
    for i in range(len(name)):
        name[i]=CasePath+'label/'+name[i]
    #print name
    #Sometimes labels are inverted along Z axis and should be rectified in this dataset
    if inverted:
        pass
    else:
        name=name[::-1]
#    for i in range(len(name)):
#        print name[i]+'\n'
    Reader.SetFileNames(name)
    Label = Reader.Execute()
    LabelArray=sitk.GetArrayFromImage(Label)
    LabelArray=((255-LabelArray[:,:,:,1])).astype(np.uint8)/255
    Label=sitk.GetImageFromArray(LabelArray)
    Label.SetSpacing(Spacing)
    Label.SetOrigin(Origin)
    Label.SetDirection(Direction)
    return Image,Label 
开发者ID:huangyjhust,项目名称:3D-RU-Net,代码行数:44,代码来源:Step1_PreProcessing.py


注:本文中的SimpleITK.ImageSeriesReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。