gll89的个人博客分享 http://blog.sciencenet.cn/u/gll89

博文

batch BET

已有 2325 次阅读 2017-5-2 23:40 |个人分类:Python|系统分类:科研笔记

bet - the main command-line script which makes calling the core bet2 and betsurf programs easy. BET is a function in FSL Tool


To batch extrain brain, we use command-line script wrote in Python as follows:

   bet <input> <output> [options]

[options] is shown in the website https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/BET/UserGuide

Use simple " for " loop to access subject files to batch extract brain of subjects


The whole codes are as bellows:

import subprocess
import os

nii_dir = '/home/linlin/Data/Images/MCI'  # root path
count = 0
for path, dirs, filepaths in os.walk(nii_dir)[:1]:  
   for filepath in filepaths[:1]:
       in_path_tmp = os.path.join(path, filepath)
       out_path_tmp = in_path_tmp[:len(in_path_tmp)-4] + '_bet.nii'
       # print ("input_path is {}noutput_path is {}nn".format(in_path_tmp, out_path_tmp))
       subprocess.call(['bet', in_path_tmp, out_path_tmp])
       count = count + 1
       print("count {}".format(count))



https://blog.sciencenet.cn/blog-1969089-1052548.html

上一篇:common packages for deep learning
下一篇:allocate GPU ID to the code python
收藏 IP: 128.227.34.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-7-26 20:17

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部