本文整理汇总了Python中dcmstack.dcmmeta.NiftiWrapper.from_filename方法的典型用法代码示例。如果您正苦于以下问题:Python NiftiWrapper.from_filename方法的具体用法?Python NiftiWrapper.from_filename怎么用?Python NiftiWrapper.from_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dcmstack.dcmmeta.NiftiWrapper
的用法示例。
在下文中一共展示了NiftiWrapper.from_filename方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_interface
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import from_filename [as 别名]
def _run_interface(self, runtime):
src = NiftiWrapper.from_filename(self.inputs.src_file)
dest_nii = nb.load(self.inputs.dest_file)
dest = NiftiWrapper(dest_nii, make_empty=True)
classes = src.meta_ext.get_valid_classes()
if self.inputs.include_classes:
classes = [cls
for cls in classes
if cls in self.inputs.include_classes
]
if self.inputs.exclude_classes:
classes = [cls
for cls in classes
if not cls in self.inputs.exclude_classes
]
for cls in classes:
src_dict = src.meta_ext.get_class_dict(cls)
dest_dict = dest.meta_ext.get_class_dict(cls)
dest_dict.update(src_dict)
self.out_path = path.join(os.getcwd(),
path.basename(self.inputs.dest_file))
dest.to_filename(self.out_path)
return runtime
示例2: _run_interface
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import from_filename [as 别名]
def _run_interface(self, runtime):
#If the 'meta_keys' input is a list, covert it to a dict
self._make_name_map()
nw = NiftiWrapper.from_filename(self.inputs.in_file)
self.result = {}
for meta_key, out_name in self._meta_keys.iteritems():
self.result[out_name] = nw.meta_ext.get_values(meta_key)
return runtime
示例3: get_tr_and_sliceorder
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import from_filename [as 别名]
def get_tr_and_sliceorder(dicom_files):
import numpy as np
import dcmstack, dicom
from dcmstack.dcmmeta import NiftiWrapper
nii_wrp = NiftiWrapper.from_filename(dicom_files)
sliceorder = np.argsort(nii_wrp.meta_ext.get_values("CsaImage.MosaicRefAcqTimes")[0]).tolist()
tr = nii_wrp.meta_ext.get_values("RepetitionTime")
return tr / 1000.0, sliceorder
示例4: get_tr_and_sliceorder
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import from_filename [as 别名]
def get_tr_and_sliceorder(dicom_files, convention="french"):
import numpy as np
import dcmstack, dicom
from dcmstack.dcmmeta import NiftiWrapper
nii_wrp = NiftiWrapper.from_filename(dicom_files)
if convention == "french":
sliceorder = np.argsort(np.argsort(nii_wrp.meta_ext.get_values('CsaImage.MosaicRefAcqTimes')[0])).tolist()
elif convention == "SPM":
sliceorder = np.argsort(nii_wrp.meta_ext.get_values('CsaImage.MosaicRefAcqTimes')[0]).tolist()
tr = nii_wrp.meta_ext.get_values('RepetitionTime')
return tr/1000.,sliceorder
示例5: get_tr_and_sliceorder
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import from_filename [as 别名]
def get_tr_and_sliceorder(dicom_files, convention="french"):
import numpy as np
import dcmstack, dicom
from dcmstack.dcmmeta import NiftiWrapper
nii_wrp = NiftiWrapper.from_filename(dicom_files)
if convention == "french":
sliceorder = np.argsort(np.argsort(nii_wrp.meta_ext.get_values('CsaImage.MosaicRefAcqTimes')[0])).tolist()
elif convention == "SPM":
sliceorder = np.argsort(nii_wrp.meta_ext.get_values('CsaImage.MosaicRefAcqTimes')[0]).tolist()
tr = nii_wrp.meta_ext.get_values('RepetitionTime')
return tr/1000.,sliceorder
get_meta = pe.Node(util.Function(input_names=['dicom_files', 'convention'], output_names=['tr', 'sliceorder'], function=get_tr_and_sliceorder), name="get_meta")
get_meta.inputs.convention = "french"
wf.connect(datagrabber, "resting_nifti", get_meta, "dicom_files")
preproc = create_rest_prep(name="bips_resting_preproc", fieldmap=False)
zscore = preproc.get_node('z_score')
preproc.remove_nodes([zscore])
mod_realign = preproc.get_node("mod_realign")
mod_realign.plugin_args = {"submit_specs":"request_memory=4000\n"}
# inputs
preproc.inputs.inputspec.motion_correct_node = 'nipy'
ad = preproc.get_node('artifactdetect')
preproc.disconnect(mod_realign,'parameter_source',
ad,'parameter_source')
ad.inputs.parameter_source = "NiPy"
preproc.inputs.inputspec.realign_parameters = {"loops":[5],
"speedup":[5]}
preproc.inputs.inputspec.do_whitening = False
preproc.inputs.inputspec.timepoints_to_remove = 4
preproc.inputs.inputspec.smooth_type = 'susan'
preproc.inputs.inputspec.do_despike = False
preproc.inputs.inputspec.surface_fwhm = 0.0
preproc.inputs.inputspec.num_noise_components = 6
preproc.inputs.inputspec.regress_before_PCA = False
preproc.get_node('fwhm_input').iterables = ('fwhm', [5])
preproc.get_node('take_mean_art').get_node('strict_artifact_detect').inputs.save_plot = True
#preproc.get_node('take_mean_art').get_node('strict_artifact_detect').overwrite=True
preproc.inputs.inputspec.ad_normthresh = 1
preproc.inputs.inputspec.ad_zthresh = 3
preproc.inputs.inputspec.do_slicetime = True
preproc.inputs.inputspec.compcor_select = [True, True]
preproc.inputs.inputspec.filter_type = 'fsl'
preproc.get_node('bandpass_filter').iterables = [('highpass_freq', [0.01]), ('lowpass_freq', [0.1])]
# preproc.inputs.inputspec.highpass_freq = 0.01
# preproc.inputs.inputspec.lowpass_freq = 0.1
#[motion_params, composite_norm, compcorr_components, global_signal, art_outliers, motion derivatives]
preproc.inputs.inputspec.reg_params = [True, True, True, False, True, False]
preproc.inputs.inputspec.fssubject_dir = freesurferdir
wf.connect(get_meta, "tr", preproc, "inputspec.tr")
wf.connect(get_meta, "sliceorder", preproc, "inputspec.sliceorder")
wf.connect(subject_id_infosource, "subject_id", preproc, 'inputspec.fssubject_id')
wf.connect(datagrabber, "resting_nifti", preproc, "inputspec.func")
# report_wf = create_preproc_report_wf(resultsdir + "/reports")
# report_wf.inputs.inputspec.fssubjects_dir = preproc.inputs.inputspec.fssubject_dir
def pick_full_brain_ribbon(l):
import os
for path in l:
if os.path.split(path)[1] == "ribbon.mgz":
return path
# wf.connect(preproc,"artifactdetect.plot_files", report_wf, "inputspec.art_detect_plot")
# wf.connect(preproc,"take_mean_art.weighted_mean.mean_image", report_wf, "inputspec.mean_epi")
# wf.connect(preproc,("getmask.register.out_reg_file", list_to_filename), report_wf, "inputspec.reg_file")
# wf.connect(preproc,("getmask.fssource.ribbon",pick_full_brain_ribbon), report_wf, "inputspec.ribbon")
# wf.connect(preproc,("CompCor.tsnr.tsnr_file", list_to_filename), report_wf, "inputspec.tsnr_file")
# wf.connect(subject_id_infosource, "subject_id", report_wf, "inputspec.subject_id")
ds = pe.Node(nio.DataSink(), name="datasink", overwrite=True)
ds.inputs.base_directory = os.path.join(resultsdir, "volumes")
wf.connect(preproc, 'bandpass_filter.out_file', ds, "preprocessed_resting")
wf.connect(preproc, 'getmask.register.out_fsl_file', ds, "func2anat_transform")
wf.connect(preproc, 'outputspec.mask', ds, "epi_mask")
wf.write_graph()
wf.run(plugin="MultiProc")