How to use sdcflows - 2 common examples

To help you get started, we’ve selected a few sdcflows 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 / workflows / fmap / base.py View on Github external
"""Initialize a barebones TOPUP implementation."""
    from nipype.interfaces.afni import Automask
    from nipype.interfaces.fsl.epi import TOPUP
    from niworkflows.interfaces.nibabel import MergeSeries
    from sdcflows.interfaces.fmap import get_trt
    from ...interfaces.images import RescaleB0
    wf = Workflow(name=name)

    inputnode = pe.Node(niu.IdentityInterface(fields=["metadata", "in_data"]),
                        name="inputnode")
    outputnode = pe.Node(niu.IdentityInterface(fields=["fieldmap", "corrected", "corrected_mask"]),
                         name="outputnode")

    concat_blips = pe.Node(MergeSeries(), name="concat_blips")
    readout_time = pe.MapNode(niu.Function(
        input_names=["in_meta", "in_file"], function=get_trt), name="readout_time",
        iterfield=["in_meta", "in_file"], run_without_submitting=True
    )

    topup = pe.Node(TOPUP(config=_pkg_fname(
        "dmriprep", f"data/flirtsch/b02b0{'_quick' * debug}.cnf")), name="topup")

    pre_mask = pe.Node(Automask(dilate=1, outputtype="NIFTI_GZ"),
                       name="pre_mask")
    rescale_corrected = pe.Node(RescaleB0(), name="rescale_corrected")
    post_mask = pe.Node(Automask(outputtype="NIFTI_GZ"),
                        name="post_mask")
    wf.connect([
        (inputnode, concat_blips, [("in_data", "in_files")]),
        (inputnode, readout_time, [("in_data", "in_file"),
                                   ("metadata", "in_meta")]),
        (inputnode, topup, [(("metadata", _get_pedir), "encoding_direction")]),
github nipreps / dmriprep / dmriprep / workflows / fmap / base.py View on Github external
pedirs = [m.get("PhaseEncodingDirection", "unknown") for m in metadata]
    if len(set(pedirs) - set(("unknown",))) > 1:
        if "unknown" in pedirs or len(set(pe[0] for pe in set(pedirs))) > 1:
            raise NotImplementedError

        # Get EPI polarities and their metadata
        sdc_estimate_wf = init_pepolar_estimate_wf(debug=debug)
        sdc_estimate_wf.inputs.inputnode.metadata = metadata

        wf.connect([
            (inputnode, sdc_estimate_wf, [("dwi_reference", "inputnode.in_data")]),
        ])
        if generate_report:
            from sdcflows.interfaces.reportlets import FieldmapReportlet
            pepolar_report = pe.Node(FieldmapReportlet(reference_label="SDC'd B0"),
                                     name="pepolar_report")
            ds_report_pepolar = pe.Node(DerivativesDataSink(
                base_directory=str(config.execution.output_dir), datatype="figures",
                suffix="fieldmap", desc="pepolar", dismiss_entities=("acquisition", "dir")),
                name="ds_report_pepolar")
            ds_report_pepolar.inputs.source_file = epi_targets[0]
            wf.connect([
                (sdc_estimate_wf, pepolar_report, [
                    ("outputnode.fieldmap", "fieldmap"),
                    ("outputnode.corrected", "reference"),
                    ("outputnode.corrected_mask", "mask")]),
                (pepolar_report, ds_report_pepolar, [("out_report", "in_file")]),
            ])

    return wf

sdcflows

Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes.

Apache-2.0
Latest version published 5 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages