Skip to content

[ENH] Add interface to SPM realign_unwarp #2635

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

Merged
merged 9 commits into from
Aug 10, 2018

Conversation

qtabs
Copy link
Contributor

@qtabs qtabs commented Jul 10, 2018

Adds am interface to SPM's realing & unwarp function.

Copy link
Member

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @qtabs , thank you for the contribution! I left a couple comments + suggestions to get past the CI errors you're encountering - if you have any questions let me know!

EDIT: can you also run make specs and add the new autotest?

@@ -437,6 +437,251 @@ def _list_outputs(self):
return outputs


class RealignUnwarpInputSpec(SPMCommandInputSpec):
in_files = InputMultiPath(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InputMultiPath is in the process of replaced by InputMultiObject, let's use that instead

@@ -437,6 +437,251 @@ def _list_outputs(self):
return outputs


class RealignUnwarpInputSpec(SPMCommandInputSpec):
in_files = InputMultiPath(
traits.Either(traits.List(File(exists=True)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you could use ImageFileSPM for image files

class ImageFileSPM(ImageFile):

instead of File, since it will not allow compressed niftis as well

Examples
--------

>>> import nipype.interfaces.spm as spm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll have to add RealignUnwarp to

from .preprocess import (FieldMap, SliceTiming, Realign, Coregister, Normalize,
Normalize12, Segment, Smooth, NewSegment, DARTEL,
DARTELNorm2MNI, CreateWarped, VBMSegment)

in order to import this way

>>> import nipype.interfaces.spm as spm
>>> realignUnwarp = spm.RealignUnwarp()
>>> realignUnwarp.inputs.in_files = ['func-run01.nii', func-run02.nii']
>>> realignUnwarp.inputs.phase_map = 'phasemap.vdm'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, these files must exist to satisfy the traits requirements - we have quite a bit included in the repo already, but for the sake of interface clarity if you cannot reuse any existing files, feel free to add necessary (empty) files

@effigies effigies changed the title [ENH] Add interface to SPM realing_unwarp [ENH] Add interface to SPM realign_unwarp Jul 23, 2018
@effigies
Copy link
Member

Hi @qtabs, do you have time to finish this up this week?

@qtabs
Copy link
Contributor Author

qtabs commented Jul 27, 2018

Thanks a lot for the help! :) I'm sorry I didn't reply any earlier, I left for vacation right after the request and couldn't check my mailbox until now. I'll try to implement your suggestions and run the tests again next week :).

@effigies effigies added this to the 1.1.2 milestone Jul 27, 2018
@effigies
Copy link
Member

effigies commented Aug 6, 2018

Hi @qtabs. Please let us know if you need anything from us. Just a heads up that we'll try to release on August 27, so it'd be great to have this within the next two weeks (by August 20).

@codecov-io
Copy link

codecov-io commented Aug 10, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@297a24c). Click here to learn what that means.
The diff coverage is 48.75%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2635   +/-   ##
========================================
  Coverage          ?   66.5%           
========================================
  Files             ?     340           
  Lines             ?   43140           
  Branches          ?    5348           
========================================
  Hits              ?   28691           
  Misses            ?   13679           
  Partials          ?     770
Flag Coverage Δ
#smoketests 48.7% <48.75%> (?)
#unittests 64.6% <48.75%> (?)
Impacted Files Coverage Δ
nipype/interfaces/spm/__init__.py 100% <100%> (ø)
nipype/interfaces/spm/preprocess.py 52.56% <48.1%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 297a24c...1b12a27. Read the comment docs.

@qtabs
Copy link
Contributor Author

qtabs commented Aug 10, 2018

Hi guys! I tried to fix the problems you hinted above but I still get some errors. I think (sorry, it's my first time dealing with automated tests!) the tests are failing to load the new module:

597     >>> realignUnwarp = spm.RealignUnwarp()
UNEXPECTED EXCEPTION: AttributeError("'module' object has no attribute 'RealignUnwarp'",)

but I have added RealignUnwarp to __init__.py as suggested by @mgxd, I'm not sure what's what I'm missing! O:)

Thanks a lot for your help!

@effigies
Copy link
Member

597     >>> realignUnwarp = spm.RealignUnwarp()
UNEXPECTED EXCEPTION: AttributeError("'module' object has no attribute 'RealignUnwarp'",)

I'm not seeing this issue in the logs. I am seeing:

NameError: name 'InputMultiObject' is not defined

Which just means you need to import InputMultiObject at the top of the file, or revert to InputMultiPath.

You should also merge master to fix the BIDSDataGrabber issue.

@effigies effigies modified the milestones: 1.1.2, 1.1.3 Aug 10, 2018
@effigies
Copy link
Member

Merged master for you. If this passes it'll make it into 1.1.2 (we need to do an emergency release). If not, we'll push it off to 1.1.3 next month.

For reference I did the following:

  1. Add your repository as a qtabs remote and the main repository as upstream.
git remote add upstream [email protected]:nipy/nipype.git
git remote add qtabs [email protected]:qtabs/nipype.git

(You wouldn't need to add your own.)

  1. Update all remotes to the latest state:
git fetch --all
  1. Check out your branch, merge upstream/master and push:
git checkout add addSPMrealingUnwarp
git merge upstream/master
git push

@qtabs
Copy link
Contributor Author

qtabs commented Aug 10, 2018

Thanks a lot @effigies! I'm trying my best but I'm still quite new to all this stuff, sorry for my noobie incompetence! O:)

@effigies
Copy link
Member

No worries. I'd usually try to be a little more helpful and give newbies a chance to practice, but with a shortened release window, I figured we could squeeze this one in. I hope you keep your eyes out for some more practice opportunities. :-)

@effigies
Copy link
Member

Well, the latest failures aren't related to this PR. I'm fixing them in #2679.

@qtabs
Copy link
Contributor Author

qtabs commented Aug 10, 2018

Thanks a lot! :) Please let me know if there's anything else from here causing problems!

@effigies effigies merged commit fdb3227 into nipy:master Aug 10, 2018
@effigies effigies modified the milestones: 1.1.3, 1.1.2 Aug 10, 2018
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

Successfully merging this pull request may close these issues.

4 participants