예제 #1
0
def converter_sem(interface_spec):
    names = interface_spec.all_trait_names()
    fields_pdr_dict = {}
    position_dict = {}

    for nm in names:
        try:
            fld = interface_spec.traits()[nm]
        except KeyError:
            pass
        else:
            if nm in ['output_type', 'args', 'environ', 'environ_items', '__all__',
                      'trait_added', 'trait_modified', "printVersionInfo"]:
                continue
            fld_pdr, pos = pydra_input_spec(fld, nm)
            fields_pdr_dict[nm] = fld_pdr
            if pos is not None:
                position_dict[nm] = pos

    if position_dict:
        fields_pdr_dict = fix_position(fields_pdr_dict, position_dict)
    fields_pdr_l = list(fields_pdr_dict.items())

    spec_pdr = specs.SpecInfo(name="Input", fields=fields_pdr_l, bases=(specs.ShellSpec,))
    return spec_pdr
예제 #2
0
    def pydra_specs(self, write=False, dirname=None):
        """ creating pydra input/output spec from nipype specs
            if write is True, a pydra Task class will be written to the file together with tests
        """
        input_fields_pdr, inp_templates = self.convert_input_fields()
        output_fields_pdr = self.convert_output_spec(
            fields_from_template=inp_templates)

        input_spec_pydra = specs.SpecInfo(name="Input",
                                          fields=input_fields_pdr,
                                          bases=(specs.ShellSpec, ))
        output_spec_pydra = specs.SpecInfo(name="Output",
                                           fields=output_fields_pdr,
                                           bases=(specs.ShellOutSpec, ))

        if write:
            if dirname is None:
                raise Exception("dirname has to be provided if write is True")
            self.write_pydra_files(dirname=dirname,
                                   pydra_input_spec=input_fields_pdr,
                                   pydra_output_spec=output_fields_pdr)
        return input_spec_pydra, output_spec_pydra
예제 #3
0
    (
        "outputVolume", 
        attr.ib(
            type=File,
            metadata={
                "help_string": "Resulting deformed image",
                "exists": True
            }
        ),
    ),
    (
        "transform", 
        attr.ib(
            type=File,
            metadata={
                "help_string": "Filename for the transform file",
                "exists": True
            }
        ),
    ),
]

input_spec_pdr = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
output_spec_pdr = specs.SpecInfo(name="Output", fields=output_fields, bases=(specs.ShellSpec,))

BRAINSStripRotation_task = pydra.ShellCommandTask(
    name="BRAINSStripRotation",
    executable=" BRAINSStripRotation ", 
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr
)
예제 #4
0
        "argstr": "{z_size}",
        "position": 7
    }),
    ("t_min", int, {
        "help_string": "",
        "argstr": "{t_min}",
        "position": 8
    }),
    ("t_size", int, {
        "help_string": "",
        "argstr": "{t_size}",
        "position": 9
    }),
]
ExtractROI_input_spec = specs.SpecInfo(name="Input",
                                       fields=input_fields,
                                       bases=(specs.ShellSpec, ))

output_fields = []
ExtractROI_output_spec = specs.SpecInfo(name="Output",
                                        fields=output_fields,
                                        bases=(specs.ShellOutSpec, ))


class ExtractROI(ShellCommandTask):
    """
    Example
    -------
    >>> task = ExtractROI()
    >>> task.inputs.in_file = "test.nii.gz"
    >>> task.inputs.t_min = 0
예제 #5
0
            "position": 1,
            "output_file_template": "{dest_file}",
        },
    ),
    (
        "ignore_dims",
        bool,
        {
            "help_string": "Do not copy image dimensions",
            "argstr": "-d",
            "position": "-1",
        },
    ),
]
CopyGeom_input_spec = specs.SpecInfo(name="Input",
                                     fields=input_fields,
                                     bases=(specs.ShellSpec, ))

output_fields = [(
    "out_file",
    specs.File,
    {
        "help_string": "image with new geometry header",
        "requires": ["in_file", "dest_file"],
        "output_file_template": "{dest_file}",
    },
)]
CopyGeom_output_spec = specs.SpecInfo(name="Output",
                                      fields=output_fields,
                                      bases=(specs.ShellOutSpec, ))
예제 #6
0
파일: mcflirt.py 프로젝트: nipype/pydra-fsl
        {
            "help_string": "save rms displacement parameters",
            "argstr": "-rmsabs -rmsrel",
        },
    ),
    (
        "ref_file",
        specs.File,
        {
            "help_string": "target image for motion correction",
            "argstr": "-reffile {ref_file}",
        },
    ),
]
MCFLIRT_input_spec = specs.SpecInfo(
    name="Input", fields=input_fields, bases=(specs.ShellSpec,)
)

output_fields = [
    (
        "variance_img",
        specs.File,
        {
            "help_string": "variance image",
            "requires": ["in_file", ("stats_imgs", True)],
            "output_file_template": "{out_file}_variance.ext",
        },
    ),
    (
        "std_img",
        specs.File,
예제 #7
0
            "xor": ["out_relwarp"],
        },
    ),
    (
        "out_relwarp",
        bool,
        {
            "help_string":
            "If set it indicates that the warps in --out should be relative, i.e. the values in --out are displacements from the coordinates in --ref.",
            "argstr": "--relout",
            "xor": ["out_abswarp"],
        },
    ),
]
ConvertWarp_input_spec = specs.SpecInfo(name="Input",
                                        fields=input_fields,
                                        bases=(specs.ShellSpec, ))

output_fields = []
ConvertWarp_output_spec = specs.SpecInfo(name="Output",
                                         fields=output_fields,
                                         bases=(specs.ShellOutSpec, ))


class ConvertWarp(ShellCommandTask):
    """
    Example
    -------
    >>> task = ConvertWarp()
    >>> task.inputs.warp1 = "warpfield.nii"
    >>> task.inputs.reference = "test.nii.gz"
예제 #8
0
파일: prelude.py 프로젝트: nipype/pydra-fsl
        "label_file",
        str,
        {
            "help_string": "saving the area labels output",
            "argstr": "--labels={label_file}",
        },
    ),
    (
        "removeramps",
        bool,
        {
            "help_string": "remove phase ramps during unwrapping",
            "argstr": "--removeramps",
        },
    ),
]
PRELUDE_input_spec = specs.SpecInfo(
    name="Input", fields=input_fields, bases=(specs.ShellSpec,)
)

output_fields = []
PRELUDE_output_spec = specs.SpecInfo(
    name="Output", fields=output_fields, bases=(specs.ShellOutSpec,)
)


class PRELUDE(ShellCommandTask):
    input_spec = PRELUDE_input_spec
    output_spec = PRELUDE_output_spec
    executable = "prelude"
예제 #9
0
        {
            "help_string": "3-tuple of new dimension order",
            "argstr": "{new_dims} {new_dims} {new_dims}",
            "mandatory": True,
        },
    ),
    (
        "out_file",
        str,
        {
            "help_string": "image to write",
            "argstr": "{out_file}",
            "output_file_template": "{in_file}_newdims",
        },
    ),
]
SwapDimensions_input_spec = specs.SpecInfo(
    name="Input", fields=input_fields, bases=(specs.ShellSpec,)
)

output_fields = []
SwapDimensions_output_spec = specs.SpecInfo(
    name="Output", fields=output_fields, bases=(specs.ShellOutSpec,)
)


class SwapDimensions(ShellCommandTask):
    input_spec = SwapDimensions_input_spec
    output_spec = SwapDimensions_output_spec
    executable = "fslswapdim"
예제 #10
0
            "argstr": ""
        },
    ),
    (
        "index_mask_file",
        specs.File,
        {
            "help_string":
            "generate seperate n submasks from indexMask, for indexvalues 1..n where n is the maximum index value in indexMask, and generate statistics for each submask",
            "argstr": "-K {index_mask_file}",
            "position": 2,
        },
    ),
]
ImageStats_input_spec = specs.SpecInfo(name="Input",
                                       fields=input_fields,
                                       bases=(specs.ShellSpec, ))

output_fields = [(
    "out_stat",
    ty.Any,
    {
        "help_string": "stats output",
        "requires": ["in_file", "op_string"]
    },
)]
ImageStats_output_spec = specs.SpecInfo(name="Output",
                                        fields=output_fields,
                                        bases=(specs.ShellOutSpec, ))

예제 #11
0
        {
            "argstr": "--tglobal",
            "help_string": "shift in fraction of TR, range 0:1 (default is 0.5 = no shift)",
        },
    ),
    (
        "custom_order",
        specs.File,
        {
            "argstr": "--ocustom={custom_order}",
            "help_string": "filename of single-column custom interleave order file (first slice is referred to as 1 not 0)",
        },
    ),
]
SliceTimer_input_spec = specs.SpecInfo(
    name="Input", fields=input_fields, bases=(specs.ShellSpec,)
)

output_fields = [
    (
        "slice_time_corrected_file",
        specs.File,
        {
            "help_string": "slice time corrected file",
            "requires": ["out_file"],
            "output_file_template": "{out_file}",
        },
    )
]
SliceTimer_output_spec = specs.SpecInfo(
    name="Output", fields=output_fields, bases=(specs.ShellOutSpec,)
예제 #12
0
    (
        "userDefineMinimum",
        attr.ib(
            type=float,
            metadata={
                "help_string": "User define minimum value",
                "argstr": "--userDefineMinimum %f",
            },
        ),
    ),
    (
        "userDefineMinimum",
        attr.ib(
            type=float,
            metadata={
                "help_string": "User define maximum value",
                "argstr": "--userDefineMaximum %f",
            },
        ),
    ),
]
input_spec_pdr = specs.SpecInfo(name="Input",
                                fields=fields,
                                bases=(specs.ShellSpec, ))

task = pydra.ShellCommandTask(name="example",
                              executable=" BRAINSLabelStats ",
                              input_spec=input_spec_pdr)

#print("task command line generated by pydra", task.cmdline)