How to use the nipype.interfaces.base.traits.Str function in nipype

To help you get started, we’ve selected a few nipype examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mwaskom / lyman / lyman / workflows / model.py View on Github external
self._results.update(results)

        return runtime


class ModelResultsInput(LymanInterface):

    class input_spec(TraitedSpec):
        experiment = traits.Str()
        model = traits.Str()
        proc_dir = traits.Directory(exists=True)
        subject = traits.Str()
        run_tuple = traits.Tuple(traits.Str(), traits.Str())

    class output_spec(TraitedSpec):
        subject = traits.Str()
        session = traits.Str()
        run = traits.Str()
        anat_file = traits.File(exists=True)
        mask_file = traits.File(exists=True)
        beta_file = traits.File(exists=True)
        ols_file = traits.File(exists=True)
        error_file = traits.File(exists=True)
        model_file = traits.File(exists=True)
        output_path = traits.Directory()

    def _run_interface(self, runtime):

        subject = self.inputs.subject
        session, run = self.inputs.run_tuple
        run_key = "{}_{}".format(session, run)
github nipy / nipype / nipype / interfaces / ants / resampling.py View on Github external
argstr='--input-image-type %d',
        desc=('Option specifying the input image '
              'type of scalar (default), vector, '
              'tensor, or time series.'))
    input_image = File(
        argstr='--input %s',
        mandatory=True,
        desc=('image to apply transformation to (generally a '
              'coregistered functional)'),
        exists=True)
    output_image = traits.Str(
        argstr='--output %s',
        desc='output file name',
        genfile=True,
        hash_files=False)
    out_postfix = traits.Str(
        "_trans",
        usedefault=True,
        desc=('Postfix that is appended to all output '
              'files (default = _trans)'))
    reference_image = File(
        argstr='--reference-image %s',
        mandatory=True,
        desc='reference image space that you wish to warp INTO',
        exists=True)
    interpolation = traits.Enum(
        'Linear',
        'NearestNeighbor',
        'CosineWindowedSinc',
        'WelchWindowedSinc',
        'HammingWindowedSinc',
        'LanczosWindowedSinc',
github APPIAN-PET / APPIAN / src / dashboard / dashboard.py View on Github external
out_file = traits.File(desc="Output file")

class deployDashInput(BaseInterfaceInputSpec):
    targetDir = traits.File(mandatory=True, desc="Target directory")
    sourceDir = traits.File(mandatory=True, desc="Source directory")
    pvc_method = traits.Str(desc="PVC method")
    quant_method = traits.Str(desc="TKA method")
    analysis_space = traits.Str(desc="Analysis Space")
    pet = traits.File(exists=True, mandatory=True, desc="PET image")
    pet_space_mri = traits.File(exists=True, mandatory=True, desc="Output PETMRI image")
    mri_space_nat = traits.File(exists=True, mandatory=True, desc="Output T1 native space image")
    t1_analysis_space = traits.File(exists=True, mandatory=True, desc="Output T1 in analysis space image")
    pvc = traits.File(exists=True, desc="Output PVC image")
    quant = traits.File(exists=True, desc="Output TKA image")
    sid =traits.Str()
    cid=traits.Str()
    ses=traits.Str()
    task=traits.Str()
    run=traits.Str()

    out_file = traits.File(desc="Output file")
    clobber = traits.Bool(desc="Overwrite output file", default=False)

class deployDashCommand(BaseInterface):
    input_spec = deployDashInput
    output_spec = deployDashOutput
  
    def _gen_output(self):
        fname = "nodes.xml"
        dname = os.getcwd()
        return dname+os.sep+fname
github nipy / nipype / nipype / interfaces / ants / segmentation.py View on Github external
'image file name format.')
    out_atlas_voting_weight_name_format = traits.Str(
        'antsJointFusionVotingWeight_%d.nii.gz',
        requires=[
            'out_label_fusion', 'out_intensity_fusion_name_format',
            'out_label_post_prob_name_format'
        ],
        desc='Optional atlas voting weight image '
        'file name format.')
    verbose = traits.Bool(False, argstr="-v", desc=('Verbose output.'))


class AntsJointFusionOutputSpec(TraitedSpec):
    out_label_fusion = File(exists=True)
    out_intensity_fusion_name_format = traits.Str()
    out_label_post_prob_name_format = traits.Str()
    out_atlas_voting_weight_name_format = traits.Str()


class AntsJointFusion(ANTSCommand):
    """
    Examples
    --------

    >>> from nipype.interfaces.ants import AntsJointFusion
    >>> antsjointfusion = AntsJointFusion()
    >>> antsjointfusion.inputs.out_label_fusion = 'ants_fusion_label_output.nii'
    >>> antsjointfusion.inputs.atlas_image = [ ['rc1s1.nii','rc1s2.nii'] ]
    >>> antsjointfusion.inputs.atlas_segmentation_image = ['segmentation0.nii.gz']
    >>> antsjointfusion.inputs.target_image = ['im1.nii']
    >>> antsjointfusion.cmdline
    "antsJointFusion -a 0.1 -g ['rc1s1.nii', 'rc1s2.nii'] -l segmentation0.nii.gz \
github acil-bwh / ChestImagingPlatform / cip_python / nipype / interfaces / unu / unu.py View on Github external
return outputs    
    
class unu_2opInputSpec(CommandLineInputSpec):
    operator = traits.Str(desc="Binary operator", position = 0, argstr="%s")
    in1_file = File(desc="First input. Must be a nrrd.", position = 1, 
                    exists=True, argstr="%s")
    in2_file = File(desc="Second input. Must be a nrrd.", position = 2, 
                    exists=True, argstr="%s")
    in1_scalar = traits.Float(desc="First input. Must be a single value.", 
                              position = 1, argstr="%f")
    in2_scalar = traits.Float(desc="Second input. Must be a single value.", 
                              position = 2, argstr="%f")    
    seed = traits.Int(desc="seed value for RNG for nrand, so that you can get \
    repeatable results between runs, or, by not using this option, the RNG \
    seeding will be based on the current time", argstr="--seed %d")
    type = traits.Str(desc="type to convert all INPUT nrrds to, prior to doing \
    operation, useful for doing, for instance, the difference between two \
    unsigned char nrrds. This will also determine output type. By default (not \
    using this option), the types of the input nrrds are left unchanged.", 
    argstr="--type %s")
    which = traits.Int(desc="Which argument (0 or 1) should be used to \
    determine the shape of the output nrrd. By default (not using this \
    option), the first non-constant argument is used. (int)", 
    argstr="--which %d")
    output = traits.Either(traits.Bool, File(), hash_files=False, 
                           desc="Output nrrd (string)", argstr="--output %s")
    
class unu_2opOutputSpec(TraitedSpec):
    output = File(desc="Output nrrd (string)", exists=True)
    
class unu_2op(CommandLine):
    _cmd = 'unu 2op '
github poldracklab / niworkflows / niworkflows / interfaces / surf.py View on Github external
in_file = Path(self.inputs.in_file)
        extension = "".join(in_file.suffixes[-((in_file.suffixes[-1] == ".gz") + 1):])
        info = self._pattern.match(in_file.name[: -len(extension)]).groupdict()
        self._results["extension"] = f"{info.pop('extprefix', None) or ''}{extension}"
        self._results.update(info)
        if "hemi" in self._results:
            self._results["hemi"] = self._results["hemi"].upper()
        return runtime


class _GiftiNameSourceInputSpec(BaseInterfaceInputSpec):
    in_file = File(mandatory=True, exists=True, desc="input GIFTI file")
    pattern = traits.Str(
        mandatory=True, desc='input file name pattern (must capture named group "LR")'
    )
    template = traits.Str(mandatory=True, desc="output file name template")
    template_kwargs = traits.Dict(desc="additional template keyword value pairs")


class _GiftiNameSourceOutputSpec(TraitedSpec):
    out_name = traits.Str(desc="(partial) filename formatted according to template")


class GiftiNameSource(SimpleInterface):
    r"""
    Construct a new filename for a GIFTI file.

    Construct a new filename based on an input filename, a matching pattern,
    and a related template, with optionally additional keywords.

    This interface is intended for use with GIFTI files, to generate names
    conforming to Section 9.0 of the `GIFTI Standard`_.
github acil-bwh / ChestImagingPlatform / cip_python / nipype / interfaces / cip / cip_pythonWrap.py View on Github external
#import pdb
#import cip_convention_manager as cm


# example http://nipy.sourceforge.net/nipype/devel/python_interface_devel.html

class parenchyma_phenotypesInputSpec(BaseInterfaceInputSpec):
    in_ct = File(exists=True, desc='Input CT file', mandatory=True)
    in_lm = File(exists=True, desc='Input label map containing structures of interest', mandatory=True)
    out_csv = File( desc='Output csv file in which to store the computed \
                   dataframe', mandatory=True)
    cid = traits.Str(desc='The database case ID',
                     mandatory=True)
    chest_regions = traits.Str(desc='Chest regions',
                mandatory=False)
    chest_types = traits.Str(desc='Chest types',
                         mandatory=False)
    pairs = traits.Str(desc='Chest region/type pairs',
                        mandatory=False)
    pheno_names = traits.Str(desc='Phenotype names',
                           mandatory=False)
    out_csv = File( desc='Output csv file in which to store the computed \
                   dataframe', mandatory=False)
class parenchyma_phenotypesOutputSpec(TraitedSpec):
    out_csv = File( desc='Output csv file in which to store the computed \
                   dataframe', mandatory=False)

class parenchyma_phenotypes(BaseInterface):
    input_spec = parenchyma_phenotypesInputSpec
    output_spec = parenchyma_phenotypesOutputSpec
    
    def _run_interface(self, runtime):
github APPIAN-PET / APPIAN / Turku / dft.py View on Github external
def _parse_inputs(self, skip=None):
        if skip is None:
            skip = []
        if not isdefined(self.inputs.out_file):
            self.inputs.out_file = self._gen_output(self.inputs.in_file)
        return super(img2dftCommand, self)._parse_inputs(skip=skip)


class tacunitOutput(TraitedSpec):
    in_file = File(argstr=" %s", position=-1,  desc="dft image.")


class tacunitInput(BaseInterfaceInputSpec):
    in_file= File(exists=True, argstr="%s", position=-1, desc="dft file")
    xconv = traits.Str(argstr="-xconv=%s", position=-2, desc="Convert x (time) axis")
    yconv = traits.Str(argstr="-yconv=%s", position=-3, desc="Convert y (radioactivity) axis")
    x = traits.Bool(argstr="-x", position=-4,desc="Print x (time) axis")
    y = traits.Bool(argstr="-y", position=-5,desc="Print y (radioactivity) axis")

class tacunitCommand(CommandLine):
    input_spec =  tacunitInput
    output_spec = tacunitOutput

    _cmd = "tacunit" 
    _file_type = ".dft" 

    def _list_outputs(self):
        outputs = self.output_spec().get()
        outputs["in_file"] = self.inputs.in_file
        return outputs
github APPIAN-PET / APPIAN / src / turku.py View on Github external
def _parse_inputs(self, skip=None):
        if skip is None:
            skip = []
        if not isdefined(self.inputs.out_file):
            self.inputs.out_file = self._gen_output(self.inputs.in_file)
        return super(img2dftCommand, self)._parse_inputs(skip=skip)


class tacunitOutput(TraitedSpec):
    in_file = File(argstr=" %s", position=-1,  desc="dft image.")


class tacunitInput(BaseInterfaceInputSpec):
    in_file= File(exists=True, argstr="%s", position=-1, desc="dft file")
    xconv = traits.Str(argstr="-xconv=%s", position=-2, desc="Convert x (time) axis")
    yconv = traits.Str(argstr="-yconv=%s", position=-3, desc="Convert y (radioactivity) axis")
    x = traits.Bool(argstr="-x", position=-4,desc="Print x (time) axis")
    y = traits.Bool(argstr="-y", position=-5,desc="Print y (radioactivity) axis")

class tacunitCommand(CommandLine):
    input_spec =  tacunitInput
    output_spec = tacunitOutput

    _cmd = "tacunit" 
    _file_type = ".dft" 

    def _list_outputs(self):
        outputs = self.output_spec().get()
        outputs["in_file"] = self.inputs.in_file
        return outputs

    def _parse_inputs(self, skip=None):
github nipy / nipype / nipype / interfaces / freesurfer / preprocess.py View on Github external
)
    subjects_dir = Directory(
        exists=True,
        argstr="-sd %s",
        hash_files=False,
        desc="path to subjects directory",
        genfile=True,
    )
    flags = InputMultiPath(traits.Str, argstr="%s", desc="additional parameters")

    # Expert options
    talairach = traits.Str(desc="Flags to pass to talairach commands", xor=["expert"])
    mri_normalize = traits.Str(
        desc="Flags to pass to mri_normalize commands", xor=["expert"]
    )
    mri_watershed = traits.Str(
        desc="Flags to pass to mri_watershed commands", xor=["expert"]
    )
    mri_em_register = traits.Str(
        desc="Flags to pass to mri_em_register commands", xor=["expert"]
    )
    mri_ca_normalize = traits.Str(
        desc="Flags to pass to mri_ca_normalize commands", xor=["expert"]
    )
    mri_ca_register = traits.Str(
        desc="Flags to pass to mri_ca_register commands", xor=["expert"]
    )
    mri_remove_neck = traits.Str(
        desc="Flags to pass to mri_remove_neck commands", xor=["expert"]
    )
    mri_ca_label = traits.Str(
        desc="Flags to pass to mri_ca_label commands", xor=["expert"]