nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
751 stars 530 forks source link

`ts_Z_corr` not defined #3696

Closed shnizzedy closed 2 weeks ago

shnizzedy commented 2 weeks ago

Summary

In NetCorr, there's a check https://github.com/nipy/nipype/blob/237a9a7ca244ca87916e1f9c5bd73c3f08c00c5d/nipype/interfaces/afni/preprocess.py#L2744 which causes

AttributeError: 'NetCorrInputSpec' object has no attribute 'ts_Z_corr'

if ts_wb_corr is not specified.

Actual behavior

AttributeError: 'NetCorrInputSpec' object has no attribute 'ts_Z_corr'

Expected behavior

How to replicate the behavior

  1. Try to use nipype.interfaces.afni.preprocess.NetCorr without ts_wb_corr

Script/Workflow details

    timeseries_correlation = pe.Node(NetCorr(), name=name)
    if method:
        timeseries_correlation.inputs.part_corr = method == "Partial"

    strip_header_node = pe.Node(
        Function(
            input_names=["in_file", "out_file"],
            output_names=["out_file"],
            imports=["import subprocess"],
            function=strip_afni_output_header,
        ),
        name=f"netcorrStripHeader{method}_{pipe_num}",
    )

    name_output_node = pe.Node(
        Function(
            input_names=["atlas_name", "tool", "method"],
            output_names=["filename"],
            imports=["import os"],
            function=connectome_name,
        ),
        name=f"connectomeName{method}_{pipe_num}",
        as_module=True,
    )
    name_output_node.inputs.tool = "Afni"

    wf.connect(
        [
            (
                inputspec,
                timeseries_correlation,
                [("in_rois", "in_rois"), ("in_file", "in_file"), ("mask", "mask")],
            ),
            (
                inputspec,
                name_output_node,
                [("atlas_name", "atlas_name"), ("method", "method")],
            ),
            (
                timeseries_correlation,
                strip_header_node,
                [("out_corr_matrix", "in_file")],
            ),
            (name_output_node, strip_header_node, [("filename", "out_file")]),
            (strip_header_node, outputspec, [("out_file", "out_file")]),
        ]
    )

(FCP-INDI/C-PAC/CPAC/connectome/connectivity_matrix.py#L163-L209@043a004)

Platform details:

{'commit_hash': '<not found>',
 'commit_source': '(none found)',
 'networkx_version': '3.1',
 'nibabel_version': '5.1.0',
 'nipype_version': '1.8.6',
 'numpy_version': '1.25.1',
 'pkg_path': '/usr/share/fsl/6.0/lib/python3.10/site-packages/nipype',
 'scipy_version': '1.11.1',
 'sys_executable': '/usr/share/fsl/6.0/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.10.6 | packaged by conda-forge | (main, Aug 22 2022, '
                '20:36:39) [GCC 10.4.0]',
 'traits_version': '6.3.2'}

Execution environment

Choose one

effigies commented 2 weeks ago

@aghayoor Could I trouble you to have a look at this? It looks like you added the interface in #3263.

effigies commented 2 weeks ago

@shnizzedy If we don't hear back, I think you can go ahead with the most obvious fixes to you.

That seems plausible.

  • I'm also not sure, but I think the check should check if those values are True rather than just if they are defined?

Yes, just remove the isdefined(). Undefined evaluates to False, so it's almost always safe to use if self.inputs.X.

aghayoor commented 2 weeks ago

Hi @effigies , It’s been a while since I added this, so I don’t fully remember the details, but your suggested fix makes sense to me. Thanks!