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

Ignoring Derived and Defaults #213

Closed
nmarkowitz opened this issue Aug 1, 2018 · 3 comments
Closed

Ignoring Derived and Defaults #213

nmarkowitz opened this issue Aug 1, 2018 · 3 comments

Comments

@nmarkowitz
Copy link

Hello,

Just to start, thank you for this great app. When converting dicom data I get all the derived scans which causes a massive clutter. I know I can use the '-i' flag to ignore those many derivatives but I would like to set it as a default setting mostly in the case to use for apps that are a wrapper for dcm2niix. Right now I'm running dcm2niix latest stable version v1.0.20180622. Any help would greatly appreciated. Thank you!

@neurolabusc
Copy link
Collaborator

I am open to other people's opinion on this. I personally use the ignore derived -i y option for all my conversions, as it removes scout/localizer scans, derived isotropic diffusion, and other images that are not useful for most pipelines. On the other hand, I understand @coalsont legitimate concerns that defaults make it hard to write scripts with reproducible output across even different user accounts on the same machine. Maybe a parsimonious solution is to write a tiny shell script that appends the "-i y" to any call. This would leave dcm2niix untouched, but you could run the script that would invoke your desired behavior:

#!/bin/sh
for i in $*;
do
    params=" $params $i"
done
exe=dcm2niix
$exe -i y $params

@coalsont
Copy link

coalsont commented Aug 4, 2018

The usual way to add an argument to a utility by default is with an alias in your shell startup script:

alias dcm2niix='dcm2niix -i y'

As an additional benefit, this way doesn't impact scripts, from the bash manpage:

Aliases are not expanded when the shell is not interactive, unless the
expand_aliases shell option is set using shopt (see the description of
shopt under SHELL BUILTIN COMMANDS below).

However, most unixlike utilities that people are expected to use aliases on also have the ability to override such alias options (if you specify "-i y -i n", does it go back to outputting the derived stuff?).

Also, that script is overly complicated, and not safe for spaces in file names, if I wanted to do this as a script I would do:

#!/bin/bash
dcm2niix -i y "$@"

This should work in sh also. I would not recommend writing ordinary scripts in pure sh, it is very old, missing useful syntax of newer shells, and bash is available for virtually any OS anyway (and is the default on most).

@neurolabusc
Copy link
Collaborator

Thanks Tim, that does seem like an elegant solution to help Noah (and others out). Therefore, I will close this issue.

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