美文网首页
Note About NiftyNet_dev

Note About NiftyNet_dev

作者: SnorlaxSE | 来源:发表于2018-11-05 14:36 被阅读0次

    项目介绍

    NiftyNet是一款开源的卷积神经网络平台,专门针对医学图像处理分析以及医学影像指导治疗,由WEISS (Wellcome EPSRC Centre for Interventional and Surgical Sciences), CMIC ( Centre for Medical Image Computing),HIG(High-dimensional Imaging Group)三家研究机构共同推出。

    NiftyNet基于Tensorflow的开源卷积神经网络平台,这一模块化设计的开源平台包含了可共享的网络预训练模型,在这些模块的帮助下我们可以方便快速地搭建针对医学图像处理的神经网络模型:

    • 利用内置工具使用预训练模型
    • 现有网络应用于自有的数据上进行调整;
    • 快速为特殊的图像分析问题生成解决方案原型;

    目前的NiftyNet支持医学图像分割和生成对抗网络,这是一个研究型平台、并不保证临床使用的稳定性和准确率,它具有以下一些功能方便医学图像处理的研究:

    ·用户接口方便的修改个性化网络元件参数; 
    ·可共享网络和预训练模型; 
    ·支持2-D,2.5-D,3-D,4-D的数据输入; 
    ·支持多GPU的高效训练; 
    ·内置了当前前沿的神经网络包括HighRes3DNet, 3D U-net, V-net, DeepMedic等,可以方便的使用; 
    ·对医学图像分割的综合评价度量;
    

    NiftyNet支持:图像分割   图像分类(回归)   auto-encoder(图像模型表示)   GANs(图像生成)

    项目结构

    平台描述:NiftyNet: a deep-learning platform for medical imaging

    架构设计

    NiftyNet应用程序类通过连接四个组件封装了针对不同医学图像分析应用程序的标准分析管道:  
    Reader: 从文件中加载数据  
    Sampler: 为之后的处理生成合适的样本  
    Network: 处理输入  
    output handler: 包括在培训期间的损失和优化器,以及在推理和评估期间的聚合器  
    ApplicationDriver: 定义了跨所有应用程序的公共结构,并负责实例化数据分析管道并将计算分布到可用的计算资源
    

    实现框架

    Installation

    由于整个项目是基于Tensorflow,所以需要实现基于对应的版本:

    pip install tensorflow-gpu==1.3     //安装GPU版本
    pip install tensorflow==1.3  //安装CPU版本
    pip install niftynet    //安装NiftyNet库,所以依赖可以自动完成安装
    

    代码在PyCharm中运行源码的话,在对应脚本的解释器的配置中添加参数即可:

    1. 下载模型
    python net_download.py highres3dnet_brain_parcellation_model_zoo  
    
    1. 分割

      python net_segment.py inference -c ~/niftynet/extensions/highres3dnet_brain_parcellation/highres3dnet_config_eval.ini  
      
      • Run
      /usr/local/bin/python3.6 /Users/Captain/Desktop/NiftyNet-dev/net_segment.py inference -c ~/niftynet/extensions/highres3dnet_brain_parcellation/highres3dnet_config_eval.ini
      
      NiftyNet version f3378259018b927e8fc6b20b06c53ac3886ee3a9 (no suitable tags)
      [CUSTOM]
      -- num_classes: 160
      -- output_prob: False
      -- label_normalisation: False
      -- softmax: True
      -- min_sampling_ratio: 0
      -- compulsory_labels: (0, 1)
      -- rand_samples: 0
      -- min_numb_labels: 1
      -- proba_connect: True
      -- evaluation_units: foreground
      -- inferred: ()
      -- weight: ()
      -- sampler: ()
      -- label: ()
      -- image: ('Modality0',)
      -- name: net_segment
      [CONFIG_FILE]
      -- path: /Users/Captain/niftynet/extensions/highres3dnet_brain_parcellation/highres3dnet_config_eval.ini
      [MODALITY0]
      -- csv_file: 
      -- path_to_search: data/OASIS/
      -- filename_contains: ('nii',)
      -- filename_not_contains: ()
      -- filename_removefromid: 
      -- interp_order: 0
      -- loader: None
      -- pixdim: (1.0, 1.0, 1.0)
      -- axcodes: ('R', 'A', 'S')
      -- spatial_window_size: (96, 96, 96)
      [SYSTEM]
      -- cuda_devices: ""
      -- num_threads: 2
      -- num_gpus: 1
      -- model_dir: /Users/Captain/niftynet/models/highres3dnet_brain_parcellation
      -- dataset_split_file: ./dataset_split.csv
      -- event_handler: ('model_saver', 'model_restorer', 'sampler_threading', 'apply_gradients', 'output_interpreter', 'console_logger', 'tensorboard_logger')
      -- iteration_generator: iteration_generator
      -- action: inference
      [NETWORK]
      -- name: highres3dnet
      -- activation_function: relu
      -- batch_size: 1
      -- smaller_final_batch_mode: pad
      -- decay: 0.0
      -- reg_type: L2
      -- volume_padding_size: (10, 10, 10)
      -- volume_padding_mode: minimum
      -- window_sampling: uniform
      -- queue_length: 5
      -- multimod_foreground_type: and
      -- histogram_ref_file: databrain_std_hist_models_otsu.txt
      -- norm_type: percentile
      -- cutoff: (0.001, 0.999)
      -- foreground_type: mean_plus
      -- normalisation: True
      -- whitening: True
      -- normalise_foreground_only: True
      -- weight_initializer: he_normal
      -- bias_initializer: zeros
      -- keep_prob: 1.0
      -- weight_initializer_args: {}
      -- bias_initializer_args: {}
      [INFERENCE]
      -- spatial_window_size: (128, 128, 128)
      -- inference_iter: 33000
      -- dataset_to_infer: 
      -- save_seg_dir: ./parcellation_output
      -- output_postfix: _niftynet_out
      -- output_interp_order: 0
      -- border: (2, 2, 2)
      INFO:niftynet: starting segmentation application
      INFO:niftynet: `csv_file = ` not found, writing to "/Users/Captain/niftynet/models/highres3dnet_brain_parcellation/Modality0.csv" instead.
      INFO:niftynet: Overwriting existing: "/Users/Captain/niftynet/models/highres3dnet_brain_parcellation/Modality0.csv".
      INFO:niftynet: [Modality0] search file folders, writing csv file /Users/Captain/niftynet/models/highres3dnet_brain_parcellation/Modality0.csv
      INFO:niftynet: 
      
      Number of subjects 1, input section names: ['subject_id', 'Modality0']
      -- using all subjects (without data partitioning).
      
      INFO:niftynet: Image reader: loading 1 subjects from sections ('Modality0',) as input [image]
      INFO:niftynet: normalisation histogram reference models ready for image:('Modality0',)
      2018-11-04 18:06:59.209921: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
      INFO:niftynet: initialised window instance
      INFO:niftynet: initialised grid sampler {'image': (1, 128, 128, 128, 1, 1), 'image_location': (1, 7)}
      INFO:niftynet: using HighRes3DNet
      INFO:niftynet: Initialising dataset from generator...
      INFO:niftynet: starting from iter 33000
      INFO:niftynet: Accessing /Users/Captain/niftynet/models/highres3dnet_brain_parcellation/models/model.ckpt-33000
      INFO:niftynet: Restoring parameters from /Users/Captain/niftynet/models/highres3dnet_brain_parcellation/models/model.ckpt-33000
      INFO:niftynet: grid sampling image sizes: {'image': (180, 276, 276, 1, 1)}
      INFO:niftynet: grid sampling window sizes: {'image': (128, 128, 128, 1, 1)}
      INFO:niftynet: yielding 27 locations from image
      INFO:niftynet: inference iter 0,  (398.539150s)
      INFO:niftynet: inference iter 1,  (313.655015s)
      INFO:niftynet: inference iter 2,  (297.785388s)
      INFO:niftynet: inference iter 3,  (2059.323541s)
      INFO:niftynet: inference iter 4,  (357.954505s)
      INFO:niftynet: inference iter 5,  (315.965626s)
      INFO:niftynet: inference iter 6,  (380.311502s)
      INFO:niftynet: inference iter 7,  (312.727651s)
      INFO:niftynet: inference iter 8,  (373.855815s)
      INFO:niftynet: inference iter 9,  (386.695381s)
      INFO:niftynet: inference iter 10,  (300.015597s)
      INFO:niftynet: inference iter 11,  (268.670928s)
      INFO:niftynet: inference iter 12,  (303.761694s)
      INFO:niftynet: inference iter 13,  (308.727933s)
      INFO:niftynet: inference iter 14,  (313.504975s)
      INFO:niftynet: inference iter 15,  (283.154703s)
      INFO:niftynet: inference iter 16,  (280.827804s)
      INFO:niftynet: inference iter 17,  (286.342750s)
      INFO:niftynet: inference iter 18,  (277.392094s)
      INFO:niftynet: inference iter 19,  (289.777673s)
      INFO:niftynet: inference iter 20,  (304.182126s)
      INFO:niftynet: inference iter 21,  (304.781269s)
      INFO:niftynet: inference iter 22,  (286.984278s)
      INFO:niftynet: inference iter 23,  (299.828858s)
      INFO:niftynet: inference iter 24,  (314.818588s)
      INFO:niftynet: inference iter 25,  (322.952987s)
      INFO:niftynet: inference iter 26,  (273.040366s)
      INFO:niftynet: inference iter 27,  (280.480217s)
      Saved /Users/Captain/niftynet/models/highres3dnet_brain_parcellation/parcellation_output/OAS1_0145_MR2_mpr_n4_anon_sbj_111_niftynet_out.nii.gz
      INFO:niftynet: stopping -- event handler: OutputInterpreter.
      INFO:niftynet: cleaning up...
      INFO:niftynet: stopping sampling threads
      INFO:niftynet: SegmentationApplication stopped (time in second 10501.22).
      
      Process finished with exit code 0
      
      注:Mac pro A1502 运行了近三个小时
      
      • Run Problem

        • Install packages failed
        - cv2
          - pip3 install opencv-python
        - yaml
          - pip3 install pyyaml
        
        • Others
        - The NiftyNetExamples server is not running
           - 直接从他处拷贝至~/niftynet
        

    执行结果:(运行完成会生成一个100__niftynet_out.nii文件,此文件可以用spm12和mriCron打开)

    文档

    文档主要包括三个主要部分,分别是指引、资源和接口参考三个部分:

    • Guide部分: 主要包括平台简介、安装指南和配置文件的设置;同时还有一个模型库可供用户选择合适的模型适配具体的问题;如果无法满足需求的情况下,它还提供了如何建立网络的教程,可以一步一步创建自己的新网络;
    • Resource部分: 这里包含了一系列资源,除了项目的网络还包括源码和源码镜像、以及模型库。同时还提供了Stack Overflow提问区域供用户交流;
    • API参考部分: 网络几大模块的说明,主要有application、contrib、engine、evaluation、io、layer、network和utilities等功能包供用户使用,每一个都有详尽的参数描述和使用指南;

    相关链接:

    https://pypi.org/project/NiftyNet/

    相关文章

      网友评论

          本文标题:Note About NiftyNet_dev

          本文链接:https://www.haomeiwen.com/subject/rzksxqtx.html