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

[FIX] return non-enhanced volumes from dwi_flirt #2547

Merged
merged 2 commits into from
Apr 26, 2018

Conversation

jdkent
Copy link
Contributor

@jdkent jdkent commented Apr 21, 2018

Fixes #1787

Changes proposed in this pull request

  • applies the matrix transforms from the adjusted/enhanced non-B0 volumes to the original non-B0 volumes, so that the image intensities remain the same. Ideally flirt should just estimate/apply linear transforms, not change the image intensities. As @salma1601 mentioned, exposure.equalize_adapthist appears to be the culprit.

example dwi data for testing

related code that can be used for testing (with modification)

@codecov-io
Copy link

codecov-io commented Apr 21, 2018

Codecov Report

Merging #2547 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2547      +/-   ##
==========================================
+ Coverage   67.04%   67.04%   +<.01%     
==========================================
  Files         332      332              
  Lines       42511    42512       +1     
  Branches     5262     5262              
==========================================
+ Hits        28500    28501       +1     
  Misses      13315    13315              
  Partials      696      696
Flag Coverage Δ
#smoketests 50.67% <ø> (ø) ⬆️
#unittests 64.34% <100%> (-0.04%) ⬇️
Impacted Files Coverage Δ
nipype/workflows/dmri/fsl/utils.py 19.29% <100%> (+0.17%) ⬆️

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 5c3c413...692b6ae. Read the comment docs.

@PkuClosed
Copy link

Hi @jdkent

Thank you for the fix. I tried to revise utils.py as suggested here. However, I got some errors after running

dir_ecc = directory
ecc = ecc_pipeline()
ecc.inputs.inputnode.in_file = dwiname
ecc.inputs.inputnode.in_bval = bvalsname
ecc.inputs.inputnode.in_mask = output_mask_name
ecc.base_dir = dir_ecc
res_ecc = ecc.run()

The output log is too long, so I selected some output that might be helpful as follows

Subnode 89 failed
Error: Traceback (most recent call last):

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/utils.py", line 106, in nodelist_runner
result = node.run(updatehash=updatehash)

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 487, in run
result = self._run_interface(execute=True)

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 571, in _run_interface
return self._run_command(execute)

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 650, in _run_command
result = self._interface.run(cwd=outdir)

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base/core.py", line 516, in run
runtime = self._run_interface(runtime)

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base/core.py", line 1023, in _run_interface
self.raise_exception(runtime)

File "/home/chuyangye/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base/core.py", line 960, in raise_exception
).format(**runtime.dictcopy()))

RuntimeError: Command:
flirt -in /home/HDD1/chuyangye/PD/data2mm/20180417/SE7/eddy_correct/DWICoregistration/SplitDWIs/vol0089.nii.gz -ref /home/HDD1/chuyangye/PD/data2mm/20180417/SE7/eddy_correct/DWICoregistration/B0Equalize/S
E7_NODDI-90_20180414161922_7_float_avg_b0_corrected_enh.nii.gz -out vol0089_flirt.nii.gz -omat vol0089_flirt.mat -applyxfm -setbackground 0.000000 -init /home/HDD1/chuyangye/PD/data2mm/20180417/SE7/eddy_c
orrect/DWICoregistration/CoRegistration/mapflow/_CoRegistration89/vol0089_enh_flirt.mat -interp spline
Standard output:

Standard error:
terminate called after throwing an instance of 'NEWMAT::SingularException'
Aborted (core dumped)
Return code: 134

180421-23:11:33,453 workflow INFO:
[Node] Setting-up "eddy_correct.GatherMatrices" in "/home/HDD1/chuyangye/PD/data2mm/20180417/SE7/eddy_correct/GatherMatrices".
180421-23:11:33,890 workflow INFO:
[Node] Running "GatherMatrices" ("nipype.interfaces.utility.wrappers.Function")
180421-23:11:34,645 workflow INFO:
[Node] Finished "eddy_correct.GatherMatrices".
180421-23:11:34,646 workflow INFO:
***********************************
180421-23:11:34,647 workflow ERROR:
could not run node: eddy_correct.DWICoregistration.ApplyXFMs
180421-23:11:34,647 workflow INFO:
crashfile: /home/chuyangye/crash-20180421-231133-chuyangye-ApplyXFMs-530c0c4a-fb9b-4b9e-a6ff-2c1900da036b.pklz
180421-23:11:34,647 workflow INFO:
***********************************

I am wondering if I missed anything in the fix.

Chuyang

@jdkent
Copy link
Contributor Author

jdkent commented Apr 22, 2018

I'm not entirely sure what is causing the error, but a google search turned up this.

Thanks for posting the output, given with what we have, I think the next pertinent question is what version of FSL you are using? If it's 5.0.8 like the user in the fsl listserv is using that may be the culprit.

@effigies
Copy link
Member

@oesteban this appears to be your contribution (#903), so I think you're probably best placed to review this. I know you've got a lot on your plate, but assigning you just to remind you when you get time.

Any others who feel comfortable reviewing should go ahead and do so.

apply_xfms = pe.MapNode(
fsl.ApplyXFM(
apply_xfm=True,
interp='spline',
Copy link
Contributor

Choose a reason for hiding this comment

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

At a first sight, using spline interpolation here seems like a good idea but will introduce negative values. Thresholding after this step would be advisable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I didn't know that about spline. I'll add thresholding back in.

@effigies
Copy link
Member

@oesteban It would be good to feature freeze 1.0.3 today so we can run final tests on Friday. Your call whether this goes in.

@effigies effigies added this to the 1.0.4 milestone Apr 26, 2018
@oesteban oesteban merged commit dfcc338 into nipy:master Apr 26, 2018
@oesteban
Copy link
Contributor

Merged!

@effigies effigies modified the milestones: 1.0.4, 1.0.3 Apr 26, 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.

5 participants