ins-amu / scripts

prepare data for TVB
MIT License
23 stars 12 forks source link

Handle topup=reversed automatically #39

Closed maedoc closed 7 years ago

maedoc commented 9 years ago

using bash redirection may solve this one at least where there are only two runs to choose from:

~/vibrations mrinfo dti/ol-p03 <<EOF 2> choices.txt
q
EOF
~/vibrations head -n4 choices.txt | tail -n +3
   0 -  200 MR images 12:05:46 cmrr_mbep2d_diff_ap_b1800 (ep_b5#1) [6]
   1 -  200 MR images 12:17:25 cmrr_mbep2d_diff_pa_b1800 (ep_b5#1) [12]

Calling mrconvert with a choice is then

mrconvert dti/ol-p03 -o foo.nii <<EOF
0
EOF
maedoc commented 9 years ago

or for a general utility function consider

function mrchoose () {
    choice=$1
    shift # $2 becomes $1, $3 becomes $2 etc
    $@ <<EOF
$choice
EOF
}

and use like

mrchoose 0 mrconvert dti/ol-p03 -o dwi_1.nii
mrchoose 1 mrconvert dti/ol-p03 -o dwi_2.nii
timpx commented 9 years ago

I was looking in the direction of expect scripts, but this is nice as well, I will update

maedoc commented 9 years ago

Probably we can send a PR to mrtrix so that these aren't necessary. I would avoid expect unless you need extended interactivity with process. Here it works because there's a single block of stdin and then stdout.

timpx commented 9 years ago

I don't know if it very useful for MRtrix guys, because you want to know what is in you data before doing this, and this is done by doing mrinfo. Our case is very specific, what if the data are organized differently in the DICOM? That's why their script ask directly for dwi1.mif and dwi2.mif, and I think it makes sense

maedoc commented 9 years ago

ah I see then at least we have a workaround..

timpx commented 7 years ago

done