fslmathsでproportional scalingをするワンライナー

Proportional scalingは割り算するだけなので大変ではありません。
スクリプトを書くまでもなく、ワンライナーでいけないかと思いました。
次のような感じでばっちりいけました。

必要なものはファイル名となんらかのglobalが記載されているテキストファイルです。ここでは、id_volume.txtとします。

1
2
3
4
5
6
7
$ cat id_volume.txt
 
filename1 1.34
filename2 1.43
filename3 1.36
...
filename4 1.47

それでは、本題です。

1
2
3
4
5
$ cat id_volume.txt | while read line; \
do id=`echo $line | awk '{ print $1 }'`; \
icv=`echo $line | awk '{ print $2 }'`; \
echo "ID=${id} and ICV=${icv}"; \
fslmaths ${id} -div ${icv} p${id}; done

これで、ファイル名の前にpがついたファイルができます。

コメントを残す

This site uses Akismet to reduce spam. Learn how your comment data is processed.