||
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))
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-7-26 20:17
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社