How to use the nipype.interfaces.base.traits.List 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 nipreps / dmriprep / dmriprep / interfaces / reports.py View on Github external
return runtime

    def _generate_segment(self):
        raise NotImplementedError


class SubjectSummaryInputSpec(BaseInterfaceInputSpec):
    t1w = InputMultiObject(File(exists=True), desc="T1w structural images")
    t2w = InputMultiObject(File(exists=True), desc="T2w structural images")
    subjects_dir = Directory(desc="FreeSurfer subjects directory")
    subject_id = Str(desc="Subject ID")
    dwi = InputMultiObject(
        traits.Either(File(exists=True), traits.List(File(exists=True))),
        desc="DWI files",
    )
    std_spaces = traits.List(Str, desc="list of standard spaces")
    nstd_spaces = traits.List(Str, desc="list of non-standard spaces")


class SubjectSummaryOutputSpec(SummaryOutputSpec):
    # This exists to ensure that the summary is run prior to the first ReconAll
    # call, allowing a determination whether there is a pre-existing directory
    subject_id = Str(desc="FreeSurfer subject ID")


class SubjectSummary(SummaryInterface):
    input_spec = SubjectSummaryInputSpec
    output_spec = SubjectSummaryOutputSpec

    def _run_interface(self, runtime):
        if isdefined(self.inputs.subject_id):
            self._results["subject_id"] = self.inputs.subject_id
github nipy / nipype / nipype / interfaces / fsl / utils.py View on Github external
class AvScaleInputSpec(CommandLineInputSpec):
    all_param = traits.Bool(False, argstr='--allparams')
    mat_file = File(
        exists=True, argstr='%s', desc='mat file to read', position=-2)
    ref_file = File(
        exists=True,
        argstr='%s',
        position=-1,
        desc='reference file to get center of rotation')


class AvScaleOutputSpec(TraitedSpec):
    rotation_translation_matrix = traits.List(
        traits.List(traits.Float), desc='Rotation and Translation Matrix')
    scales = traits.List(traits.Float, desc='Scales (x,y,z)')
    skews = traits.List(traits.Float, desc='Skews')
    average_scaling = traits.Float(desc='Average Scaling')
    determinant = traits.Float(desc='Determinant')
    forward_half_transform = traits.List(
        traits.List(traits.Float), desc='Forward Half Transform')
    backward_half_transform = traits.List(
        traits.List(traits.Float), desc='Backwards Half Transform')
    left_right_orientation_preserved = traits.Bool(
        desc='True if LR orientation preserved')
    rot_angles = traits.List(traits.Float, desc='rotation angles')
    translations = traits.List(traits.Float, desc='translations')


class AvScale(CommandLine):
    """Use FSL avscale command to extract info from mat file output of FLIRT
github nipy / nipype / nipype / interfaces / slicer / registration / specialized.py View on Github external
CommandLineInputSpec,
    SEMLikeCommandLine,
    TraitedSpec,
    File,
    Directory,
    traits,
    isdefined,
    InputMultiPath,
    OutputMultiPath,
)
import os


class ACPCTransformInputSpec(CommandLineInputSpec):
    acpc = InputMultiPath(
        traits.List(traits.Float(), minlen=3, maxlen=3),
        desc="ACPC line, two fiducial points, one at the anterior commissure and one at the posterior commissure.",
        argstr="--acpc %s...",
    )
    midline = InputMultiPath(
        traits.List(traits.Float(), minlen=3, maxlen=3),
        desc="The midline is a series of points defining the division between the hemispheres of the brain (the mid sagittal plane).",
        argstr="--midline %s...",
    )
    outputTransform = traits.Either(
        traits.Bool,
        File(),
        hash_files=False,
        desc="A transform filled in from the ACPC and Midline registration calculation",
        argstr="--outputTransform %s",
    )
    debugSwitch = traits.Bool(
github nipy / nipype / nipype / interfaces / ants / registration.py View on Github external
transforms = traits.List(traits.Enum('Rigid', 'Affine', 'CompositeAffine',
                                         'Similarity', 'Translation', 'BSpline',
                                         'GaussianDisplacementField', 'TimeVaryingVelocityField',
                                         'TimeVaryingBSplineVelocityField', 'SyN', 'BSplineSyN',
                                         'Exponential', 'BSplineExponential'), argstr='%s', mandatory=True)
    # TODO: transform_parameters currently supports rigid, affine, composite affine, translation, bspline, gaussian displacement field (gdf), and SyN -----ONLY-----!
    transform_parameters = traits.List(traits.Either(traits.Float(),
                                                     traits.Tuple(
                                                         traits.Float()),
                                                     traits.Tuple(traits.Float(),  # gdf & syn
                                                                  traits.Float(
                                                                  ),
                                                                  traits.Float())))
    # Convergence flags
    number_of_iterations = traits.List(traits.List(traits.Int()))
    smoothing_sigmas = traits.List(traits.List(traits.Int()), mandatory=True)
    sigma_units = traits.List(traits.Enum('mm', 'vox'),
                              requires=['smoothing_sigmas'],
                              desc="units for smoothing sigmas", mandatory=True)
    shrink_factors = traits.List(traits.List(traits.Int()), mandatory=True)
    convergence_threshold = traits.List(trait=traits.Float(), value=[1e-6], minlen=1, requires=['number_of_iterations'], usedefault=True)
    convergence_window_size = traits.List(trait=traits.Int(), value=[10], minlen=1, requires=['convergence_threshold'], usedefault=True)
    # Output flags
    output_transform_prefix = traits.Str(
        "transform", usedefault=True, argstr="%s", desc="")
    output_warped_image = traits.Either(
        traits.Bool, File(), hash_files=False, desc="")
    output_inverse_warped_image = traits.Either(traits.Bool, File(),
                                                hash_files=False,
                                      requires=['output_warped_image'], desc="")
    winsorize_upper_quantile = traits.Range(low=0.0, high=1.0, value=1.0, argstr='%s', usedefault=True, desc="The Upper quantile to clip image ranges")
github nipy / nipype / nipype / interfaces / fsl / preprocess.py View on Github external
dof = traits.Int(argstr="-dof %d", desc="number of transform degrees of freedom")
    no_resample = traits.Bool(argstr="-noresample", desc="do not change input sampling")
    force_scaling = traits.Bool(
        argstr="-forcescaling", desc="force rescaling even for low-res images"
    )
    min_sampling = traits.Float(
        argstr="-minsampling %f",
        units="mm",
        desc="set minimum voxel dimension for sampling",
    )
    padding_size = traits.Int(
        argstr="-paddingsize %d",
        units="voxels",
        desc="for applyxfm: interpolates outside image " "by size",
    )
    searchr_x = traits.List(
        traits.Int,
        minlen=2,
        maxlen=2,
        units="degrees",
        argstr="-searchrx %s",
        desc="search angles along x-axis, in degrees",
    )
    searchr_y = traits.List(
        traits.Int,
        minlen=2,
        maxlen=2,
        units="degrees",
        argstr="-searchry %s",
        desc="search angles along y-axis, in degrees",
    )
    searchr_z = traits.List(
github nipy / nipype / nipype / interfaces / fsl / model.py View on Github external
else:
                outputs['feat_dir'] = glob(os.path.join(os.getcwd(),
                                                        '*feat'))[0]
        print('Outputs from FEATmodel:', outputs)
        return outputs


class FEATModelInputSpec(FSLCommandInputSpec):
    fsf_file = File(
        exists=True,
        mandatory=True,
        argstr="%s",
        position=0,
        desc="File specifying the feat design spec file",
        copyfile=False)
    ev_files = traits.List(
        File(exists=True),
        mandatory=True,
        argstr="%s",
        desc="Event spec files generated by level1design",
        position=1,
        copyfile=False)


class FEATModelOutpuSpec(TraitedSpec):
    design_file = File(
        exists=True, desc='Mat file containing ascii matrix for design')
    design_image = File(
        exists=True, desc='Graphical representation of design matrix')
    design_cov = File(
        exists=True, desc='Graphical representation of design covariance')
    con_file = File(
github nipy / nipype / nipype / interfaces / fsl / model.py View on Github external
def _list_outputs(self):
        outputs = self._outputs().get()
        for field in list(outputs.keys()):
            outputs[field] = os.path.join(os.getcwd(), field.replace('_', '.'))
        return outputs


class MultipleRegressDesignInputSpec(BaseInterfaceInputSpec):
    contrasts = traits.List(
        traits.Either(
            traits.Tuple(traits.Str, traits.Enum('T'), traits.List(traits.Str),
                         traits.List(traits.Float)),
            traits.Tuple(traits.Str, traits.Enum('F'),
                         traits.List(
                             traits.Tuple(traits.Str, traits.Enum('T'),
                                          traits.List(traits.Str),
                                          traits.List(traits.Float)), ))),
        mandatory=True,
        desc="List of contrasts with each contrast being a list of the form - \
[('name', 'stat', [condition list], [weight list])]. if \
session list is None or not provided, all sessions are used. For F \
contrasts, the condition list should contain previously defined \
T-contrasts without any weight list.")
    regressors = traits.Dict(
        traits.Str,
        traits.List(traits.Float),
        mandatory=True,
        desc=('dictionary containing named lists of '
              'regressors'))
    groups = traits.List(
        traits.Int,
        desc=('list of group identifiers (defaults to single '
github nipy / nipype / nipype / interfaces / dipy / tracks.py View on Github external
class TrackDensityMapInputSpec(BaseInterfaceInputSpec):
    in_file = File(
        exists=True, mandatory=True, desc='The input TrackVis track file')
    reference = File(
        exists=True, desc='A reference file to define RAS coordinates space')
    points_space = traits.Enum(
        'rasmm',
        'voxel',
        None,
        usedefault=True,
        desc='coordinates of trk file')
    voxel_dims = traits.List(
        traits.Float, minlen=3, maxlen=3, desc='The size of each voxel in mm.')
    data_dims = traits.List(
        traits.Int,
        minlen=3,
        maxlen=3,
        desc='The size of the image in voxels.')
    out_filename = File(
        'tdi.nii',
        usedefault=True,
        desc='The output filename for the tracks in TrackVis '
        '(.trk) format')


class TrackDensityMapOutputSpec(TraitedSpec):
    out_file = File(exists=True)


class TrackDensityMap(DipyBaseInterface):
github nipy / nipype / nipype / interfaces / slicer / diffusion / diffusion.py View on Github external
)
    transform_order = traits.Enum(
        "input-to-output",
        "output-to-input",
        desc="Select in what order the transforms are read",
        argstr="--transform_order %s",
    )
    notbulk = traits.Bool(
        desc="The transform following the BSpline transform is not set as a bulk transform for the BSpline transform",
        argstr="--notbulk ",
    )
    spaceChange = traits.Bool(
        desc="Space Orientation between transform and image is different (RAS/LPS) (warning: if the transform is a Transform Node in Slicer3, do not select)",
        argstr="--spaceChange ",
    )
    rotation_point = traits.List(
        desc="Center of rotation (only for rigid and affine transforms)",
        argstr="--rotation_point %s",
    )
    centered_transform = traits.Bool(
        desc="Set the center of the transformation to the center of the input image (only for rigid and affine transforms)",
        argstr="--centered_transform ",
    )
    image_center = traits.Enum(
        "input",
        "output",
        desc="Image to use to center the transform (used only if 'Centered Transform' is selected)",
        argstr="--image_center %s",
    )
    Inverse_ITK_Transformation = traits.Bool(
        desc="Inverse the transformation before applying it from output image to input image (only for rigid and affine transforms)",
        argstr="--Inverse_ITK_Transformation ",