Skip to content

Fix/dcm2niix #2498

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 15 commits into from
Mar 23, 2018
Merged

Fix/dcm2niix #2498

merged 15 commits into from
Mar 23, 2018

Conversation

mgxd
Copy link
Member

@mgxd mgxd commented Mar 16, 2018

Fixes? #2474 .

Changes proposed in this pull request

  • Add support for new parameters
  • Some refactoring of dcm2niix interface
  • Regression test with datalad
  • Add dcm2niix/datalad to travis testing matrix

@codecov-io
Copy link

codecov-io commented Mar 16, 2018

Codecov Report

Merging #2498 into master will decrease coverage by 18.49%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2498      +/-   ##
==========================================
- Coverage   66.86%   48.36%   -18.5%     
==========================================
  Files         327      119     -208     
  Lines       42474    24162   -18312     
  Branches     5271        0    -5271     
==========================================
- Hits        28400    11686   -16714     
+ Misses      13373    12476     -897     
+ Partials      701        0     -701
Flag Coverage Δ
#smoketests 48.36% <ø> (-2.48%) ⬇️
#unittests ?
Impacted Files Coverage Δ
nipype/workflows/smri/freesurfer/ba_maps.py 11.11% <0%> (-79.17%) ⬇️
nipype/workflows/rsfmri/fsl/resting.py 14.51% <0%> (-70.97%) ⬇️
nipype/workflows/smri/freesurfer/autorecon2.py 2.68% <0%> (-68.59%) ⬇️
nipype/workflows/smri/freesurfer/autorecon3.py 2.43% <0%> (-66.67%) ⬇️
nipype/pipeline/plugins/pbsgraph.py 29.41% <0%> (-64.71%) ⬇️
nipype/pipeline/plugins/tools.py 24.28% <0%> (-62.86%) ⬇️
nipype/workflows/smri/freesurfer/bem.py 38.46% <0%> (-61.54%) ⬇️
nipype/workflows/fmri/spm/preprocess.py 11.22% <0%> (-61.23%) ⬇️
nipype/pipeline/plugins/multiproc.py 20.83% <0%> (-58.93%) ⬇️
nipype/interfaces/utility/csv.py 42.85% <0%> (-57.15%) ⬇️
... and 270 more

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 95e81c9...41c45b9. Read the comment docs.

@mgxd
Copy link
Member Author

mgxd commented Mar 16, 2018

looks like same issue as ReproNim/neurodocker#148

I'll save including dcm2niix and datalad to our testing suite for a later PR

>>> converter.inputs.compression = 5
>>> converter.inputs.output_dir = 'ds005'
>>> converter.cmdline
'dcm2niix -b y -z y -5 -x n -t n -m n -o ds005 -s n -v n dicomdir'
Copy link
Member

Choose a reason for hiding this comment

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

perhaps add:

>>> converter.run() # doctest: +SKIP

after this

@effigies
Copy link
Member

Is this targeting 1.0.2?

@effigies
Copy link
Member

@mgxd Is this ready for review?

@mgxd
Copy link
Member Author

mgxd commented Mar 22, 2018

@effigies yes


>>> flags = '-'.join([val.strip() + ' ' for val in sorted(' '.join(converter.cmdline.split()[1:-1]).split('-'))])
>>> flags
' -b y -f %t%p -m n -o . -s y -t n -v n -x n -z i '
' -5 -b y -m n -o ds005 -s n -t n -v n -x n -z y '
Copy link
Member

Choose a reason for hiding this comment

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

What is the point of this flags line, if we're already showing cmdline?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine to remove this as well, just kept around since it previously existed

Copy link
Member

Choose a reason for hiding this comment

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

Looks like @satra specifically added this in #1529. Guessing the flag ordering was non-deterministic, since he also added #doctest: +SKIP to the cmdline line. If the cmdline check is working consistently, I'd say go ahead and drop.

@@ -251,6 +263,8 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
argstr="%s",
position=-1,
copyfile=False,
deprecated='1.0.2',
new_name='source_dir',
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why this is being deprecated. Is it no longer available in dcm2niix, or is it simply disrecommended? Should we use max_ver instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

usage: dcm2niix [options] <in_folder>

I would prefer to remove this entirely, as it's misleading to dcm2niix's actual usage (I've checked as far back as version 28Aug2016)

Copy link
Member

Choose a reason for hiding this comment

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

Okay. Looks like you added this interface in the first place, so nobody else really to consult with. I'm fine with this.

output_dir = Directory(
exists=True, argstr='-o %s', genfile=True, desc="Output directory")
os.getcwd(),
Copy link
Member

Choose a reason for hiding this comment

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

This will be evaluated at import time, and thus output to the working directory from which the python interpreter was started (usually). If you want the base directory of the node (or CWD at interface runtime), I think you'll want ".".

has_private = traits.Bool(
False,
argstr='-t',
usedefault=True,
desc="Flag if text notes includes private patient details")
compression = traits.Enum(
1, 2, 3, 4, 5, 6, 7, 8, 9,
argstr='-%s',
Copy link
Member

Choose a reason for hiding this comment

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

-%d?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

desc="Ignore derived, localizer and 2D images")
series_numbers = InputMultiPath(
traits.Str(),
argstr='-n %s',
Copy link
Member

Choose a reason for hiding this comment

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

Just to check: If this is series_numbers = ["a", "b", "c"], is the desired output -n a b c or -n a -n b -n c? Right now it's coded for the former.

Copy link
Member Author

Choose a reason for hiding this comment

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

after checking, it should be the latter, making a fix now

Copy link
Member

Choose a reason for hiding this comment

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

You can just do argstr='-n %s...', rather than add a special case to _format_arg.

Copy link
Member Author

Choose a reason for hiding this comment

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

TIL, nice!

else:
output_dir = self._gen_filename('output_dir')
out_file = os.path.abspath(os.path.join(output_dir, fname))
out_file = os.path.abspath(fname)
Copy link
Member

Choose a reason for hiding this comment

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

Do you not want to use output_dir at all? It no longer seems to have any effect in this interface.

Copy link
Member Author

Choose a reason for hiding this comment

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

if omitted, dcm2niix defaults to save within input folder, so I'd prefer to have it save within the node directory/cwd. The output_dir is parsed from dcm2niix's stdout as fname

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, I misunderstood what was going on here.

>>> flags = '-'.join([val.strip() + ' ' for val in sorted(' '.join(converter.cmdline.split()[1:-1]).split('-'))])
>>> flags
' -5 -b y -m n -o ds005 -s n -t n -v n -x n -z y '
>>> converter.run() # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

I think we did still want the converter.run() line, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

😅

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

LGTM. I assume the tests pass locally?

@effigies
Copy link
Member

Passing, but Circle's not updating right now.

@effigies effigies merged commit 803982c into nipy:master Mar 23, 2018
@effigies effigies added this to the 1.0.2 milestone Mar 23, 2018
@effigies effigies mentioned this pull request Mar 29, 2018
@mgxd mgxd deleted the fix/dcm2niix branch May 17, 2018 20:44
@mgxd mgxd mentioned this pull request Sep 13, 2019
1 task
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