コード例 #1
0
def test_spec(tmpdir):
    interface_name = "BET"
    converter = FSLConverter(interface_name=interface_name)
    input_spec_pydra, output_spec_pydra = converter.pydra_specs()

    in_file = Path(os.path.dirname(__file__)) / "data_tests/test.nii.gz"
    out_file = Path(os.path.dirname(__file__)) / "data_tests/test_brain.nii.gz"
    cmd = "bet"

    shelly = pydra.ShellCommandTask(name="bet_task",
                                    executable=cmd,
                                    input_spec=input_spec_pydra,
                                    output_spec=output_spec_pydra)
    shelly.inputs.in_file = in_file
    assert shelly.inputs.executable == "bet"
    assert shelly.cmdline == f"bet {in_file} {str(shelly.output_dir / 'test_brain.nii.gz')}"
    res = shelly()
    assert res.output.out_file.exists()
    print("\n Result: ", res)

    shelly_mask = pydra.ShellCommandTask(name="bet_task",
                                         executable=cmd,
                                         input_spec=input_spec_pydra,
                                         output_spec=output_spec_pydra)
    shelly_mask.inputs.in_file = in_file
    shelly_mask.inputs.mask = True
    assert shelly_mask.cmdline == f"bet {in_file} {str(shelly_mask.output_dir / 'test_brain.nii.gz')} -m"
    res = shelly_mask()
    assert res.output.out_file.exists()
    assert res.output.mask_file.exists()
    print("\n Result: ", res)
コード例 #2
0
ファイル: testing.py プロジェクト: chasejohnson3/hbmhack
    ),
    (
        "ro",
        attr.ib(type=InputMultiPath, metadata={"argstr": "--ro %s..."}),
    ),
]

output_fields = []

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

CLIROITest_task = pydra.ShellCommandTask(
    name="CLIROITest",
    executable=" CLIROITest ",
    input_spec=input_spec_pdr,
)

input_fields = [
    (
        "inputVolume",
        attr.ib(type=File,
                metadata={
                    "argstr": "--inputVolume %s",
                    "help_string": "Input image."
                }),
    ),
    (
        "outputCSVFile",
        attr.
コード例 #3
0
    (
        "outputImageName",
        attr.ib(type=File,
                metadata={
                    "help_string": "Result of processing",
                    "position": -1,
                    "exists": True
                }),
    ),
    (
        "outputbiasfield",
        attr.ib(type=File,
                metadata={
                    "help_string": "Recovered bias field (OPTIONAL)",
                    "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, ))

N4ITKBiasFieldCorrection_task = pydra.ShellCommandTask(
    name="N4ITKBiasFieldCorrection",
    executable=" N4ITKBiasFieldCorrection ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #4
0
                    "--outputMaskFile %s",
                    "help_string":
                    "Ouput binary mask that includes the pure plugs (.nrrd)"
                }),
    ),
]

output_fields = [
    (
        "outputMaskFile",
        attr.ib(type=File,
                metadata={
                    "help_string":
                    "Ouput binary mask that includes the pure plugs (.nrrd)",
                    "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, ))

GeneratePurePlugMask_task = pydra.ShellCommandTask(
    name="GeneratePurePlugMask",
    executable=" GeneratePurePlugMask ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #5
0
                    "output_file_template": "{args}",
                    "help_string": "output file",
                },
            ),
        ),
        (
            "out_file_index",
            attr.ib(
                type=int,
                metadata={
                    "help_string": "output file",
                    "callable": get_file_index,
                },
            ),    
        )
    ],
    bases=(pydra.specs.ShellOutSpec,),
)


shelly = pydra.ShellCommandTask(name="shelly", executable=cmd, args=args, output_spec=my_output_spec).split("args")

print("cmndline = ", shelly.cmdline)

with pydra.Submitter(plugin="cf") as sub:
    sub(shelly)
print(shelly.result())
#results = shelly.result()
#for result in results:
#    print(result.output.stdout)
コード例 #6
0
                    "argstr": "%s",
                    "help_string": "Filtered tensor volume",
                    "position": -1
                }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Filtered tensor volume",
                    "position": -1,
                    "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, ))

DiffusionTensorTest_task = pydra.ShellCommandTask(
    name="DiffusionTensorTest",
    executable=" DiffusionTensorTest ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #7
0
                    "help_string": "Volume1 + Volume2",
                    "position": -1,
                    "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, ))

AddScalarVolumes_task = pydra.ShellCommandTask(name="AddScalarVolumes",
                                               executable=" AddScalarVolumes ",
                                               input_spec=input_spec_pdr,
                                               output_spec=output_spec_pdr)

input_fields = [
    (
        "InputVolume",
        attr.ib(type=File,
                metadata={
                    "argstr": "%s",
                    "help_string": "Input volume, the volume to cast.",
                    "position": -2
                }),
    ),
    (
        "OutputVolume",
        attr.ib(type=File,
コード例 #8
0
               "--transform %s",
               "help_string":
               "Transform algorithm\nrt = Rigid Transform\na = Affine Transform"
           }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Resampled Volume",
                    "position": -1,
                    "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, ))

ResampleScalarVectorDWIVolume_task = pydra.ShellCommandTask(
    name="ResampleScalarVectorDWIVolume",
    executable=" ResampleScalarVectorDWIVolume ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #9
0
                metadata={
                    "argstr":
                    "--numberOfSamples %d",
                    "help_string":
                    "The number of voxels sampled for metric evaluation."
                }),
    ),
    (
        "numberOfHistogramBins",
        attr.
        ib(type=traits.Int,
           metadata={
               "argstr":
               "--numberOfHistogramBins %d",
               "help_string":
               "The number of historgram bins when MMI (Mattes) is metric type."
           }),
    ),
]

output_fields = []

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

PerformMetricTest_task = pydra.ShellCommandTask(
    name="PerformMetricTest",
    executable=" PerformMetricTest ",
    input_spec=input_spec_pdr,
)
コード例 #10
0
                    "argstr": "%s",
                    "help_string": "Output filtered",
                    "position": -1
                }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Output filtered",
                    "position": -1,
                    "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, ))

SimpleRegionGrowingSegmentation_task = pydra.ShellCommandTask(
    name="SimpleRegionGrowingSegmentation",
    executable=" SimpleRegionGrowingSegmentation ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #11
0
                    "argstr": "--negate ",
                    "help_string":
                    "Swap the outside value with the inside value."
                }),
    ),
]

output_fields = [
    (
        "OutputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Thresholded input volume",
                    "position": -1,
                    "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, ))

ThresholdScalarVolume_task = pydra.ShellCommandTask(
    name="ThresholdScalarVolume",
    executable=" ThresholdScalarVolume ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #12
0
ファイル: surface.py プロジェクト: chasejohnson3/hbmhack
                    "position": -1,
                    "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, ))

GrayscaleModelMaker_task = pydra.ShellCommandTask(
    name="GrayscaleModelMaker",
    executable=" GrayscaleModelMaker ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)

input_fields = [
    (
        "labelToSmooth",
        attr.
        ib(type=traits.Int,
           metadata={
               "argstr":
               "--labelToSmooth %d",
               "help_string":
               "The label to smooth.  All others will be ignored.  If no label is selected by the user, the maximum label in the image is chosen by default."
           }),
    ),
コード例 #13
0
                "argstr": "--userDefineMaximum %f",
                "help_string": "User define maximum value"
            }
        ),
    ),
]

output_fields = [
]

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


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

input_fields = [
    (
        "petDICOMPath", 
        attr.ib(
            type=Directory,
            metadata={
                "argstr": "--petDICOMPath %s",
                "help_string": "Input path to a directory containing a PET volume containing DICOM header information for SUV computation"
            }
        ),
    ),
    (
コード例 #14
0
                metadata={
                    "argstr":
                    "--numberOfThreads %d",
                    "help_string":
                    "Explicitly specify the maximum number of threads to use."
                }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Resulting deformed image",
                    "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, ))

BRAINSResample_task = pydra.ShellCommandTask(name="BRAINSResample",
                                             executable=" BRAINSResample ",
                                             input_spec=input_spec_pdr,
                                             output_spec=output_spec_pdr)
コード例 #15
0
    def _run_pydra(self, image, soft_ver_str):
        wf = pydra.Workflow(
            name="wf",
            input_spec=["image"],
            cache_dir=self.working_dir,
        )
        wf.inputs.image = image

        # 1st task - analysis
        param_run = self.params["analysis"]
        cmd_run = [param_run["command"]]
        inp_fields_run = []
        inp_val_run = {}

        if param_run["script"]:
            script_run = param_run["script"]
            inp_fields_run.append((
                "script",
                attr.ib(type=pydra.specs.File,
                        metadata={
                            "argstr": "",
                            "position": 1,
                            "help_string": "script file",
                            "mandatory": True,
                        }),
            ))
            inp_val_run[f"script"] = script_run

        output_file_dict = {}
        for ind, inputs in enumerate(param_run["inputs"]):
            inputs = deepcopy(inputs)
            value = inputs.pop("value")
            name = inputs.pop("name", f"inp_{ind}")
            output_file = inputs.pop("output_file", False)
            # default values for metadata
            metadata = {
                "argstr": "",
                "position": ind + 2,
                "help_string": f"inp_{ind}",
                "mandatory": True,
            }
            tp = inputs.pop("type")
            if tp == "File":
                tp = pydra.specs.File
                metadata["container_path"] = True
            # updating metadata with values provided in parameters file
            metadata.update(inputs)

            field = (name, attr.ib(type=tp, metadata=metadata))
            inp_fields_run.append(field)

            if tp is pydra.specs.File:
                inp_val_run[name] = f"/data/{value}"
                process_path_obj(value, self.data_path)
            else:
                if output_file:
                    output_file_dict[name] = value
                    value = os.path.join("/output_pydra", value)
                inp_val_run[name] = value

        input_spec_run = pydra.specs.SpecInfo(name="Input",
                                              fields=inp_fields_run,
                                              bases=(pydra.specs.DockerSpec, ))

        out_fields_run = []
        for el in self.params["tests"]:
            if isinstance(el["file"], str):
                if el["file"] in output_file_dict:
                    el["file"] = output_file_dict[el["file"]]
                out_fields_run.append(
                    (f"file_{el['name']}", pydra.specs.File, el["file"]))
            elif isinstance(el["file"], list):
                for ii, file in enumerate(el["file"]):
                    out_fields_run.append(
                        (f"file_{el['name']}_{ii}", pydra.specs.File, file))
            else:
                raise Exception(
                    f"value for file in params['tests'] has to be a str or a list"
                )

        output_spec_run = pydra.specs.SpecInfo(
            name="Output",
            fields=out_fields_run,
            bases=(pydra.specs.ShellOutSpec, ))

        task_run = pydra.DockerTask(
            name="run",
            executable=cmd_run,
            image=wf.lzin.image,
            input_spec=input_spec_run,
            output_spec=output_spec_run,
            bindings=[(self.data_path, "/data", "ro")],
            **inp_val_run,
        )
        wf.add(task_run)

        # 2nd task - creating list from the 1st task output
        @pydra.mark.task
        @pydra.mark.annotate({"return": {"outfiles": list}})
        def outfiles_list(res):
            out_f = []
            for el in self.params["tests"]:
                if isinstance(el["file"], (tuple, list)):
                    out_f.append(
                        tuple([
                            res[f"file_{el['name']}_{i}"]
                            for i in range(len(el["file"]))
                        ]))
                else:
                    out_f.append(res[f"file_{el['name']}"])
            return out_f

        wf.add(outfiles_list(name="outfiles", res=wf.run.lzout.all_))

        # 3rd task - tests
        input_spec_test = pydra.specs.SpecInfo(
            name="Input",
            fields=[
                (
                    "script_test",
                    attr.ib(type=pydra.specs.File,
                            metadata={
                                "argstr": "",
                                "position": 1,
                                "help_string": "test file",
                                "mandatory": True,
                            }),
                ),
                (
                    "file_out",
                    attr.ib(type=(tuple, pydra.specs.File),
                            metadata={
                                "position": 2,
                                "help_string": "out file",
                                "argstr": "-out",
                                "mandatory": True,
                            }),
                ),
                (
                    "file_ref",
                    attr.ib(type=(tuple, pydra.specs.File),
                            metadata={
                                "position": 3,
                                "argstr": "-ref",
                                "help_string": "out file",
                                "mandatory": True,
                                "container_path": True,
                            }),
                ),
                (
                    "name_test",
                    attr.ib(type=str,
                            metadata={
                                "position": 4,
                                "argstr": "-name",
                                "help_string": "test name",
                                "mandatory": True,
                            }),
                ),
            ],
            bases=(pydra.specs.ShellSpec, ),
        )

        output_spec_test = pydra.specs.SpecInfo(
            name="Output",
            fields=[("reports", pydra.specs.File, "report_*.json")],
            bases=(pydra.specs.ShellOutSpec, ),
        )

        if self.test_image:
            container_info = ("docker", self.test_image, [(self.data_ref_path,
                                                           "/data_ref", "ro")])
            file_ref_dir = Path("/data_ref")
        else:
            container_info = None
            file_ref_dir = self.data_ref_path

        inp_val_test = {}
        inp_val_test["name_test"] = [el["name"] for el in self.params["tests"]]
        inp_val_test["script_test"] = [
            el["script"] for el in self.params["tests"]
        ]
        inp_val_test["file_ref"] = []
        for el in self.params["tests"]:
            if isinstance(el["file"], str):
                inp_val_test["file_ref"].append(file_ref_dir / el["file"])
            elif isinstance(el["file"], list):
                inp_val_test["file_ref"].append(
                    tuple([file_ref_dir / file for file in el["file"]]))

        task_test = pydra.ShellCommandTask(
            name="test",
            executable="python",
            container_info=container_info,
            input_spec=input_spec_test,
            output_spec=output_spec_test,
            file_out=wf.outfiles.lzout.outfiles,
            **inp_val_test,
        ).split((("script_test", "name_test"), ("file_out", "file_ref")))
        wf.add(task_test)

        # setting wf output
        wf.set_output([
            ("outfiles", wf.outfiles.lzout.outfiles),
            ("test_out", wf.test.lzout.stdout),
            ("reports", wf.test.lzout.reports),
        ])
        print(f"\n running pydra workflow for {self.workflow_path} "
              f"in working directory - {self.working_dir}")
        with pydra.Submitter(plugin="cf") as sub:
            sub(wf)
        res = wf.result()
        self.reports[soft_ver_str] = res.output.reports
コード例 #16
0
    (
        "outputDirectory",
        attr.ib(type=Directory,
                metadata={
                    "help_string": "Directory holding the output NRRD file",
                    "exists": True
                }),
    ),
    (
        "gradientVectorFile",
        attr.
        ib(type=File,
           metadata={
               "help_string":
               "DEPRECATED:  Use --inputBVector --inputBValue files Text file giving gradient vectors",
               "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, ))

DWIConvert_task = pydra.ShellCommandTask(name="DWIConvert",
                                         executable=" DWIConvert ",
                                         input_spec=input_spec_pdr,
                                         output_spec=output_spec_pdr)
コード例 #17
0
               "help_string":
               "A transform filled in from the ACPC and Midline registration calculation.",
               "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, ))

ACPCTransform_task = pydra.ShellCommandTask(name="ACPCTransform",
                                            executable=" ACPCTransform ",
                                            input_spec=input_spec_pdr,
                                            output_spec=output_spec_pdr)

input_fields = [
    (
        "fixedLandmarks",
        attr.ib(type=InputMultiPath,
                metadata={
                    "argstr": "--fixedLandmarks %s...",
                    "help_string":
                    "Ordered list of landmarks in the fixed image"
                }),
    ),
    (
        "movingLandmarks",
        attr.ib(type=InputMultiPath,
コード例 #18
0
ファイル: brainsfit.py プロジェクト: chasejohnson3/hbmhack
        attr.
        ib(type=File,
           metadata={
               "help_string":
               "(optional) Filename to which save the (optional) estimated transform. NOTE: You must select either the outputTransform or the outputVolume option.",
               "exists": True
           }),
    ),
    (
        "logFileReport",
        attr.
        ib(type=File,
           metadata={
               "help_string":
               "A file to write out final information report in CSV file: MetricName,MetricValue,FixedImageName,FixedMaskName,MovingImageName,MovingMaskName",
               "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, ))

BRAINSFit_task = pydra.ShellCommandTask(name="BRAINSFit",
                                        executable=" BRAINSFit ",
                                        input_spec=input_spec_pdr,
                                        output_spec=output_spec_pdr)
コード例 #19
0
                    "argstr": "%s",
                    "help_string": "Output filtered",
                    "position": -1
                }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Output filtered",
                    "position": -1,
                    "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, ))

CheckerBoardFilter_task = pydra.ShellCommandTask(
    name="CheckerBoardFilter",
    executable=" CheckerBoardFilter ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #20
0
                    "argstr": "%s",
                    "help_string": "Output filtered",
                    "position": -1
                }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.ib(type=File,
                metadata={
                    "help_string": "Output filtered",
                    "position": -1,
                    "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, ))

VotingBinaryHoleFillingImageFilter_task = pydra.ShellCommandTask(
    name="VotingBinaryHoleFillingImageFilter",
    executable=" VotingBinaryHoleFillingImageFilter ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #21
0
               "position": -1
           }),
    ),
]

output_fields = [
    (
        "outputVolume",
        attr.
        ib(type=File,
           metadata={
               "help_string":
               "Output volume. This is the input volume with intensities matched to the reference volume.",
               "position": -1,
               "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, ))

HistogramMatching_task = pydra.ShellCommandTask(
    name="HistogramMatching",
    executable=" HistogramMatching ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #22
0
                    "The directory to contain the DICOM series.",
                    "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, ))

CreateDICOMSeries_task = pydra.ShellCommandTask(
    name="CreateDICOMSeries",
    executable=" CreateDICOMSeries ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)

input_fields = [
    (
        "inputVolume1",
        attr.ib(type=File,
                metadata={
                    "argstr": "--inputVolume1 %s",
                    "help_string": "First input volume (.nhdr or .nrrd)"
                }),
    ),
    (
        "inputVolume2",
        attr.ib(type=File,
コード例 #23
0
    (
        "arg1",
        attr.ib(type=File,
                metadata={
                    "help_string": "Second index argument is an image",
                    "position": -1,
                    "exists": True
                }),
    ),
    (
        "outputDT",
        attr.ib(type=File,
                metadata={
                    "help_string": "Array of processed (output) Table values",
                    "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, ))

ExecutionModelTour_task = pydra.ShellCommandTask(
    name="ExecutionModelTour",
    executable=" ExecutionModelTour ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)
コード例 #24
0
ファイル: segmentation.py プロジェクト: chasejohnson3/hbmhack
        attr.ib(
            type=File,
            metadata={
                "help_string": "Name of the resulting Talairach Grid 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,))

BRAINSTalairach_task = pydra.ShellCommandTask(
    name="BRAINSTalairach",
    executable=" BRAINSTalairach ", 
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr
)

input_fields = [
    (
        "inputVolume", 
        attr.ib(
            type=File,
            metadata={
                "argstr": "--inputVolume %s",
                "help_string": "Input image used to define physical space of resulting mask"
            }
        ),
    ),
    (
コード例 #25
0
                    "position": -1,
                    "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, ))

CurvatureAnisotropicDiffusion_task = pydra.ShellCommandTask(
    name="CurvatureAnisotropicDiffusion",
    executable=" CurvatureAnisotropicDiffusion ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)

input_fields = [
    (
        "sigma",
        attr.
        ib(type=traits.Float,
           metadata={
               "argstr":
               "--sigma %f",
               "help_string":
               "Sigma value in physical units (e.g., mm) of the Gaussian kernel"
           }),
    ),
コード例 #26
0
ファイル: utilities.py プロジェクト: chasejohnson3/hbmhack
                metadata={
                    "help_string": "given a list of ",
                    "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, ))

BRAINSDWICleanup_task = pydra.ShellCommandTask(name="BRAINSDWICleanup",
                                               executable=" BRAINSDWICleanup ",
                                               input_spec=input_spec_pdr,
                                               output_spec=output_spec_pdr)

input_fields = [
    (
        "inputVolume",
        attr.ib(type=File,
                metadata={
                    "argstr": "%s",
                    "help_string": "Input volume to be resampled",
                    "position": -2
                }),
    ),
    (
        "outputVolume",
        attr.ib(type=File,
コード例 #27
0
nest_asyncio.apply()
# -

# ## ShellCommandTask
#
# In addition to `FunctionTask`, pydra allows for creating tasks from shell commands by using `ShellCommandTask`.
#
# Let's run a simple command `pwd` using pydra

import pydra

# +
cmd = "pwd"
# we should use an executable to pass the command we want to run
shelly = pydra.ShellCommandTask(name="shelly", executable=cmd)

# we can always check the cmdline of our task
shelly.cmdline
# -

# and now let's try to run it:

with pydra.Submitter(plugin="cf") as sub:
    sub(shelly)

# and check the result

shelly.result()

# the result should have `return_code`, `stdout` and `stderr`. If everything goes well `return_code` should be `0`, `stdout` should point to the working directory and `stderr` should be an empty string.
コード例 #28
0
                    "Save the transform that results from registration",
                    "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, ))

ExpertAutomatedRegistration_task = pydra.ShellCommandTask(
    name="ExpertAutomatedRegistration",
    executable=" ExpertAutomatedRegistration ",
    input_spec=input_spec_pdr,
    output_spec=output_spec_pdr)

input_fields = [
    (
        "gridSize",
        attr.ib(type=traits.Int,
                metadata={
                    "argstr": "--gridSize %d",
                    "help_string":
                    "Number of grid points on interior of image."
                }),
    ),
    (
        "outputtransform",
コード例 #29
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
)
コード例 #30
0
    for ii, el in enumerate(argstr_l):
        if "%" in el:
            argstr_l[ii] = "{" + el.replace("%", "{}:".format(name)) + "}"
    return " ".join(argstr_l)



if __name__ == "__main__":
    mod_sem = importlib.import_module("quantification")
    interface_name = "BRAINSLabelStats"

    # mod_sem = importlib.import_module("registration")
    # interface_name = "BRAINSFit"


    interface = getattr(mod_sem, interface_name)
    input_spec = getattr(mod_sem, interface_name + "InputSpec")()
    output_spec = getattr(mod_sem, interface_name + "OutputSpec")()

    input_spec_pdr = converter_sem(interface_spec=input_spec)
    outpur_spec_pdr = converter_sem(interface_spec=output_spec)

    print(f"\ninput_spec_pdr\n\n{input_spec_pdr}\n")
    print(f"\noutpur_spec_pdr\n\n{outpur_spec_pdr}\n")

    task = pydra.ShellCommandTask(name=interface_name, executable=interface._cmd,
                                  input_spec=input_spec_pdr, output_spec=outpur_spec_pdr)

    task.inputs.imageVolume = "path_image"
    print("task command line generated by pydra", task.cmdline)