Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With NiPype Memory with version 0.12.1 and >=0.13.0 #2406

Closed
KamalakerDadi opened this issue Jan 26, 2018 · 12 comments
Closed

With NiPype Memory with version 0.12.1 and >=0.13.0 #2406

KamalakerDadi opened this issue Jan 26, 2018 · 12 comments
Milestone

Comments

@KamalakerDadi
Copy link

Hi Nipype team,

Summary

Trying to understand what is causing this difference between versions 0.12.1 and >=0.13.0. Is this with Memory or Realign. I am suspecting that this is the problem. But, I am sure I am missing some important details on this ?
We are experiencing this in package pypreprocess which is reliant on Nipype. See full traceback in neurospin/pypreprocess#288

Actual behavior

Nipype version:0.13.0
Traceback (most recent call last):
  File "report_nipype.py", line 11, in <module>
    print(realign)
  File "/home/kamalakar/miniconda2/envs/pypreprocess0_13/lib/python2.7/site-packages/nipype/caching/memory.py", line 98, in __repr__
    self.base_dir)
ValueError: Single '}' encountered in format string

Expected behavior

Nipype version:0.12.1
PipeFunc(nipype.interfaces.spm.preprocess.Realign, base_dir=/tmp/nipype_mem)

How to replicate the behavior

import nipype
print("Nipype version:{0}".format(nipype.__version__))

import nipype.interfaces.spm as spm
from nipype.caching import Memory

mem = Memory(base_dir='/tmp/')
realign = mem.cache(spm.Realign)
print(realign)

Thanks a lot for your time.

@effigies
Copy link
Member

That was a bug. Fixed in #2407.

You can still use the interface prior to getting the fix, you just can't print the object directly. If you need it, you can manually edit your file (/home/kamalakar/miniconda2/envs/pypreprocess0_13/lib/python2.7/site-packages/nipype/caching/memory.py) to use the fixed format string.

@KamalakerDadi
Copy link
Author

Thank you @effigies That's very quick. I will try the fix.

@KamalakerDadi
Copy link
Author

I am printing just to explain the problem. But, the actual problem lies around as I mentioned in this issue at pypreprocess neurospin/pypreprocess#288

@KamalakerDadi
Copy link
Author

It was fine with 0.12.1 but not above 0.13.0.

@effigies
Copy link
Member

Okay. That looks like it's probably an issue with Realign. The issue looks like it was probably introduced in #1949, which made it into 0.13.0. It may have been fixed in #2375, which made it into 1.0.0, which was released yesterday. Could you try upgrading your nipype to 1.0 (it will need to be installed by pip; the conda build might be out sometime today), and see if your problem persists?

@KamalakerDadi
Copy link
Author

Could you try upgrading your nipype to 1.0 (it will need to be installed by pip; the conda build might be out sometime today), and see if your problem persists?

I tried with this version too. The problem still exists.

@effigies
Copy link
Member

What does the actual input to Realign look like? Is it a list of files, or a list of a list? I can reproduce the error like so:

from nipype.interfaces.spm import Realign
realign = Realign()
realign.inputs.in_files = [['test.img']]

However, if I use the following, I get no error:

realign.inputs.in_files = ['test.img']

@KamalakerDadi
Copy link
Author

List of a list.

Is it something changed on passing input to Realign between 0.12.1 to 0.13.0 ?

@effigies
Copy link
Member

Weirdly, no. It's something that changed from 0.14.0 to 1.0 (#2375). I'm not sure why it wouldn't be working in 0.13.0.

However, I've pushed a fix in #2409. Can you check whether it resolves your issue?

@KamalakerDadi
Copy link
Author

However, I've pushed a fix in #2409. Can you check whether it resolves your issue?

yes, I cannot see the problem. Thanks a lot.

Do you have any suggestion to change the attribute or add an attribute In Realign to get back to the normal behaviour to make it work for versions until this is released ?

@effigies
Copy link
Member

You can create a patched input spec:

from nipype.interfaces import spm, base

class PatchedRealignInputSpec(spm.preprocess.RealignInputSpec):
    in_files = base.InputMultiPath(
        base.InputMultiPath(spm.base.ImageFileSPM(exists=True)),
        field='data',
        mandatory=True,
        copyfile=True,
        desc='list of filenames to realign')

class PatchedRealign(spm.preprocess.Realign):
    input_spec = PatchedRealignInputSpec

I think this will work in any version >=0.13.0. So you may need to wrap it in a version check to make sure you don't try to use spm.base.ImageFileSPM before it exists.

@djarecka
Copy link
Collaborator

@effigies - I was just checking your short example and with ver. 0.13 works perfectly fine for me. So it looks like that the problem (at least this one) comes completely from my PR, sorry for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants