nipype icon indicating copy to clipboard operation
nipype copied to clipboard

nipype.interfaces.spm.model use_vox_fdr_correction attribute error

Open Claar727 opened this issue 1 year ago • 2 comments
trafficstars

Summary

In the documentation for the Threshold method within the nipype SPM interface it shows use_vox_fdr_correction as an optional input with description "Whether to use voxel-based FDR correction for initial threshold (height_threshold_type has to be set to q-value)." Whenever I set this to True and set height_threshold_type to 'q-value' I get the error TraitError: Cannot set the undefined 'use_vox_fdr_correction' attribute of a 'ThresholdInputSpec' object. I tried importing ThresholdInputSpec directly and creating an instance to check its available attributes via dir and did not see use_vox_fdr_correction. I also tried setting the height_threshold_type to 'q-value' without including the use_vox_fdr_correction and got an error stating that 'q-value' was not a valid value for height_threshold_type. My workflow works perfectly if I use Topographical FDR or FWE. I can replicate the error using the code snippet below.

Using the inspect module to look at the Threshold definition (i.e., inspect.getsource(spm.Threshold) I can see that there is no use_vox_fdr_correction attribute but when I look through the github it appears in the Threshold class definition. Should I be using a different NiPyPe version to use this capability or should I clone the github instead of installing NiPyPe via pip? Any help is appreciated!

Actual behavior

TraitError

Expected behavior

Voxel-wise FDR correction of contrast images with significance level set via q-value.

How to replicate the behavior

import nipype.interfaces.spm as spm matlab_cmd = 'path/to/standalone/SPM12 path/to/mcr script' spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True) spm.Threshold(height_threshold=0.05, height_threshold_type='q-value', use_vox_fdr_correction=True)

Script/Workflow details

NA Please put URL to code or code here (if not too long). import nipype.interfaces.spm as spm matlab_cmd = 'path/to/standalone/SPM12 path/to/mcr script' spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True) spm.Threshold(height_threshold=0.05, height_threshold_type='q-value', use_vox_fdr_correction=True)

Platform details:

SPM version: 12.7771 MCR: v910 Python: 3.10.14 NiPyPe: 1.8.6 OS: Linux

  • NAME="Red Hat Enterprise Linux"
  • VERSION="8.9 (Ootpa)"
  • ID="rhel"
  • ID_LIKE="fedora"
  • VERSION_ID="8.9"
  • PLATFORM_ID="platform:el8"
  • PRETTY_NAME="Red Hat Enterprise Linux 8.9 (Ootpa)"
  • ANSI_COLOR="0;31"
  • CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
  • HOME_URL="https://www.redhat.com/"
  • DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8"
  • BUG_REPORT_URL="https://bugzilla.redhat.com/"
  • REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
  • REDHAT_BUGZILLA_PRODUCT_VERSION=8.9
  • REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
  • REDHAT_SUPPORT_PRODUCT_VERSION="8.9"
{'commit_hash': '<not found>',
 'commit_source': '(none found)',
 'networkx_version': '3.3',
 'nibabel_version': '5.2.1',
 'nipype_version': '1.8.6',
 'numpy_version': '1.26.4',
 'pkg_path': '/blue/vabfmc/data/working/robert727/.conda/envs/cda2_nipype_wf/lib/python3.10/site-packages/nipype',
 'scipy_version': '1.13.0',
 'sys_executable': '/blue/vabfmc/data/working/robert727/.conda/envs/cda2_nipype_wf/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.10.14 | packaged by conda-forge | (main, Mar 20 2024, '
                '12:45:18) [GCC 12.3.0]',
 'traits_version': '6.3.2'}

Execution environment

Choose one

  • Container [Tag: ???]
  • My python environment inside container [Base Tag: ???]
  • My python environment outside container

Claar727 avatar Sep 10 '24 17:09 Claar727

Is this resolved in 1.9.0?

effigies avatar Nov 18 '24 21:11 effigies

Thanks for getting back to me and for what you do with NiPype, it's been super helpful with my PhD research.

I created a new conda environment with python version 3.11.10 just nipype 1.9.0 and its dependencies and ran my simple working example from above

import nipype.interfaces.spm as spm matlab_cmd = 'path/to/standalone/SPM12 path/to/mcr script' spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True) spm.Threshold(height_threshold=0.05, height_threshold_type='q-value', use_vox_fdr_correction=True)

This raised the error

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/blue/vabfmc/data/working/robert727/.conda/envs/test_nipype/lib/python3.11/site-packages/nipype/interfaces/spm/base.py", line 303, in __init__ super().__init__(**inputs) File "/blue/vabfmc/data/working/robert727/.conda/envs/test_nipype/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 204, in __init__ self.inputs.trait_set(**inputs) File "/blue/vabfmc/data/working/robert727/.conda/envs/test_nipype/lib/python3.11/site-packages/traits/has_traits.py", line 1509, in trait_set setattr(self, name, value) File "/blue/vabfmc/data/working/robert727/.conda/envs/test_nipype/lib/python3.11/site-packages/traits/base_trait_handler.py", line 74, in error raise TraitError( traits.trait_errors.TraitError: The 'height_threshold_type' trait of a ThresholdInputSpec instance must be 'p-value' or 'stat', but a value of 'q-value' <class 'str'> was specified.

Looking at the 1.9.0 documentation it still states

use_vox_fdr_correction (a boolean) – Whether to use voxel-based FDR correction for initial threshold (height_threshold_type has to be set to q-value). (Nipype default value: False)

and when I ran

>>> spm.Threshold(height_threshold=0.05, use_vox_fdr_correction=True)

it returned

<nipype.interfaces.spm.model.Threshold object at 0x1474eb8803d0>

with no error. So perhaps this issue was partially fixed, or maybe it was completely fixed and the documentation does not reflect it.

Claar727 avatar Nov 19 '24 00:11 Claar727