当前位置: 首页>>代码示例>>Python>>正文


Python dcmmeta.NiftiWrapper类代码示例

本文整理汇总了Python中dcmstack.dcmmeta.NiftiWrapper的典型用法代码示例。如果您正苦于以下问题:Python NiftiWrapper类的具体用法?Python NiftiWrapper怎么用?Python NiftiWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NiftiWrapper类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run_interface

    def _run_interface(self, runtime):
        src_nii = nb.load(self.inputs.src_file)
        src = NiftiWrapper(src_nii, make_empty=True)
        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)
        # Update the shape and slice dimension to reflect the meta extension update.
        dest.meta_ext.slice_dim = src.meta_ext.slice_dim
        dest.meta_ext.shape = src.meta_ext.shape

        self.out_path = path.join(os.getcwd(),
                                  path.basename(self.inputs.dest_file))
        dest.to_filename(self.out_path)

        return runtime
开发者ID:Alunisiira,项目名称:nipype,代码行数:30,代码来源:dcmstack.py

示例2: _run_interface

 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
开发者ID:dbanda,项目名称:nipype,代码行数:26,代码来源:dcmstack.py

示例3: get_tr_and_sliceorder

    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
开发者ID:steelec,项目名称:pipelines,代码行数:9,代码来源:resting_state_preprocessing.py

示例4: _run_interface

 def _run_interface(self, runtime):
     src_paths = self._get_filelist(self.inputs.dicom_files)
     include_regexes = dcmstack.default_key_incl_res
     if isdefined(self.inputs.include_regexes):
         include_regexes += self.inputs.include_regexes
     exclude_regexes = dcmstack.default_key_excl_res
     if isdefined(self.inputs.exclude_regexes):
         exclude_regexes += self.inputs.exclude_regexes
     meta_filter = dcmstack.make_key_regex_filter(exclude_regexes, include_regexes)
     stack = dcmstack.DicomStack(meta_filter=meta_filter)
     for src_path in src_paths:
         src_dcm = dicom.read_file(src_path, force=True)
         stack.add_dcm(src_dcm)
     nii = stack.to_nifti(embed_meta=True)
     nw = NiftiWrapper(nii)
     self.out_path = self._get_out_path(nw.meta_ext.get_class_dict(("global", "const")))
     if not self.inputs.embed_meta:
         nw.remove_extension()
     nb.save(nii, self.out_path)
     return runtime
开发者ID:rogeriofalcone,项目名称:nipype,代码行数:20,代码来源:dcmstack.py

示例5: get_tr_and_sliceorder

 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
开发者ID:RuifangLi,项目名称:pipelines,代码行数:11,代码来源:resting_state_preprocessing.py

示例6: get_tr_and_sliceorder

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")
开发者ID:JanisReinelt,项目名称:pipelines,代码行数:83,代码来源:resting_state_preprocessing.py


注:本文中的dcmstack.dcmmeta.NiftiWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。