python中接口的访问值
我在FMRI图像中阅读,其中我想计算一定的测量。
initial_data = os.path.join(str(subject_path)+'/derivatives/participant/fmriprep/sub-'+str(subject_label)+'/ses-'+str(k)+'/func/sub-'+str(subject_label)+'_ses-'+str(k)+'_task-rest_run-3_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii.gz')
mean_img = MeanImage(in_file=initial_data,dimension="T",nan2zeros=False,out_file=out_file_mean)
mean_img.run()
sd_img = StdImage(in_file=initial_data,dimension="T",nan2zeros=False,out_file=out_file_sd)
sd_img.run()
division = BinaryMaths(in_file=out_file_mean,operand_file=out_file_sd,operation="div",nan2zeros=False,out_file=out_file_dv)
division.run()
tsnr_value_calc = ImageStats(in_file=out_file_dv,op_string="-M")
tsnr_result = tsnr_value_calc.run()
print(tsnr_result)
输出
220628-17:34:38,962 nipype.interface INFO:
stdout 2022-06-28T17:34:38.962155:113.157831
我想最终提取数字(113.157831),然后将其保存到数组中。我该怎么做?
将接口转换为使用str()的字符串不起作用。 打印接口导致:
print(tsnr_result)
<nipype.interfaces.base.support.InterfaceResult object at 0x7fd550078be0>
以下是vars和tsnr_results.outputs的输出。
I read in a fMRI image where I want to calculate a certain measurement.
initial_data = os.path.join(str(subject_path)+'/derivatives/participant/fmriprep/sub-'+str(subject_label)+'/ses-'+str(k)+'/func/sub-'+str(subject_label)+'_ses-'+str(k)+'_task-rest_run-3_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii.gz')
mean_img = MeanImage(in_file=initial_data,dimension="T",nan2zeros=False,out_file=out_file_mean)
mean_img.run()
sd_img = StdImage(in_file=initial_data,dimension="T",nan2zeros=False,out_file=out_file_sd)
sd_img.run()
division = BinaryMaths(in_file=out_file_mean,operand_file=out_file_sd,operation="div",nan2zeros=False,out_file=out_file_dv)
division.run()
tsnr_value_calc = ImageStats(in_file=out_file_dv,op_string="-M")
tsnr_result = tsnr_value_calc.run()
print(tsnr_result)
outputs
220628-17:34:38,962 nipype.interface INFO:
stdout 2022-06-28T17:34:38.962155:113.157831
I want to extract the number (113.157831) in the end and save that into an array. How would I do that?
Converting the interface to a string with str() does not work.
Printing the interface leads to:
print(tsnr_result)
<nipype.interfaces.base.support.InterfaceResult object at 0x7fd550078be0>
Here is the output of vars and tsnr_results.outputs would be the number I would need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在用
分开的块中拆分字符串:
并获取最后一个元素:输出: 您可以使用
float()
You can split the string in chunks separated with
:
and get the last element:Output: You can convert it to float with
float()