ubuntuのホスト名の変更

Ubuntuでホスト名を変えたい場合、以下の2つのファイルを変更します。

  • /etc/hostname
  • ホスト名だけ記載されているのでそれを変えます。

  • /etc/hosts
  • ここでは、127.0.0.1の後にホスト名が記載されているのでそれを変えます。

備忘録として。

Non-stationary correction

Christian Gaser made the following comment on non-stationary correction in SPM8.

Furthermore, SPM8 (release >= 4010) provides a non-stationarity correction, that is based on smoothed RPV-maps, which should be more reliable than the unsmoothed RPV maps in VBM8 or in the NS-toolbox. To enable this function set:

defaults.stats.rft.nonstat = 1;

in spm_defaults. However, this option will result in a much longer calculation if you print the results table.
This is maybe also the reason that this option is not set as default.

Update of Lin4Neuro (28 Feb 2013)

Lin4Neuro was updated. Some changes are…

  • 3D Slicer was updated to 4.2.2-1 (only in 64bit version).
  • MITK and MITK Diffusion was updated to 2012.12 version (only in 64bit version).
  • nfs-common was added so that it can support NFS filesystem with default settings.

I also stopped developing Lin4Neuro based on Ubuntu 10.04LTS. I focus on developing Lin4Neuro based on Xubuntu 12.04LTS.

You can download latest Lin4Neuro from here.

A study of shell script: Convert various image files formats into EPS format

I’m learning shell scripts these days.
Below is a script which converts various image file formats (jpg, png, etc…) into eps format using ImageMagick.
LaTeX user might find this script useful.

#!/bin/sh
#A script which converts various image file formats into EPS format.
#Usage: image2eps.sh filename
#Wild card can be used.

if [ $# = 0 ]
then
echo "Please specify the files you want to convert!"
echo "Usage: image2eps.sh filename"
exit 1
fi

for image in "$@"
do
if [ -f $image ]
then
convert $image `echo eps2:$image | sed 's/\..*$/.eps/'`
else
echo "$image: No such file"
fi
done

Shell color of Xubuntu

I noticed that Xubuntu overrides color of shell.
I looked for the solution and found the colorcode is in ~/.config/Terminal/terminalrc

[Configuration]
ColorForeground=#000000000000
ColorBackground=#ffffffffffff
ColorCursor=#000000000000
ColorSelection=#e3d6e3d6e3d6
ColorSelectionUseDefault=FALSE
ColorPalette2=#66660a3d0a3d
ColorPalette3=#000066661999
ColorPalette4=#4ecf2e2e6666
ColorPalette5=#171734344d4d
ColorPalette6=#800012d38000
ColorPalette7=#000080008000
ColorPalette8=#35357878b3b3
ColorPalette9=#999999999999
ColorPalette10=#80000ccd0ccd
ColorPalette11=#0000a6662999
ColorPalette12=#9d9d5c5ccccc
ColorPalette13=#262656568080
ColorPalette14=#cccc1e6dcccc
ColorPalette15=#0000aaaaaaaa
ColorPalette16=#52529393cccc
FontName=Droid Sans Mono 10
MiscAlwaysShowTabs=FALSE
MiscBell=FALSE
MiscBordersDefault=TRUE
MiscCursorBlinks=FALSE
MiscCursorShape=TERMINAL_CURSOR_SHAPE_BLOCK
MiscDefaultGeometry=80x24
MiscInheritGeometry=FALSE
MiscMenubarDefault=TRUE
MiscMouseAutohide=FALSE
MiscToolbarsDefault=FALSE
MiscConfirmClose=TRUE
MiscCycleTabs=TRUE
MiscTabCloseButtons=TRUE
MiscTabCloseMiddleClick=TRUE
MiscTabPosition=GTK_POS_TOP
MiscHighlightUrls=TRUE
TabActivityColor=#262656568080

By commenting out the items regarding Color, I got the traditional look of shell.

shell

SPM5およびSPM8でAC-PCを自動で設定できるスクリプト

この記事は、http://www.nemotos.net/?p=17で紹介したものを日本語に訳しただけのものです。

2008年10月18日に、Carlton Chu氏がSPMのメーリングリストに便利なスクリプトを投稿しました。
メーリングリストでは特に反応はなかったのですが、非常に有用だと思いますので、本ブログで紹介させていただきます。

このスクリプトの目的はいたってシンプルです:AC-PCを自動的にあわせてくれます!

若干時間がかかります(1例に数分かかります)が、何百例もAC-PCをあわせなくてはいけないような状況では、大きな時間の節約になります。
もし関心があったら、次のスクリプトを試してみて下さい。SPM5、SPM8でうまく動きます。

オリジナルの投稿では、若干動作しないバグがありました。そこを修正してあります。

使用方法:添付のファイルをダウンロードし、SPM5かSPM8に置いてください。その後、MATLABのコマンドウィンドウから、”auto_reorient”とタイプしてください。ファイル選択のウィンドウが立ち上がりますので、AC-PCを設定したいファイルを選択して下さい(複数選択できます)。

function auto_reorient(p)
spmDir=which('spm');
spmDir=spmDir(1:end-5);
tmpl=[spmDir 'canonical/avg152T1.nii'];
vg=spm_vol(tmpl);
flags.regtype='rigid';
p=spm_select(inf,'image');
for i=1:size(p,1)
f=strtrim(p(i,:));
spm_smooth(f,'temp.nii',[12 12 12]);
vf=spm_vol('temp.nii');
[M,scal] = spm_affreg(vg,vf,flags);
M3=M(1:3,1:3);
[u s v]=svd(M3);
M3=u*v';
M(1:3,1:3)=M3;
N=nifti(f);
N.mat=M*N.mat;
create(N);
end

auto_reorient.m

FSLのMacOSへのインストール方法(FSL 6.0.5以前)

*これは相当古いインストラクションです。新たなインストラクションを別に準備しますので、FSL 6.0.6 以降のインストール方法はそちらをご参照ください。

Mac OSXにFSLをインストールする機会がありました。
いくつか工夫が必要だったので、メモします。

(9/Dec/2014: fslinstaller.pyはスーパーユーザーでなくても大丈夫と気づいたので、修正しました。また、Yosemiteの場合についても追記しました。)
(1/Mar/2014: .bash_profileがない場合の対処を追記しました。また、改行コードについての注意も記載しました)

続きを読む

SPMをオンラインでアップデートする方法

SPMは定期的にアップデートされています。spm_updateというコマンドをうつと、自分のSPMのバージョンが最新かどうかチェックできます。

>> spm_update
A new version of SPM is available on:
ftp://ftp.fil.ion.ucl.ac.uk/spm/spm8_updates/
(Your version: 4290 - New version: 4667)

これまで、FTPでアップデートをとってきていましたが、ある方に、spm_update(1)とやると、自動で最新ファイルを入手してくれるよと教わりました。

自分が使っているSPMがちょうどアップデートが必要だったのでやってみました。

>> spm_update(1)
A new version of SPM is available on:
ftp://ftp.fil.ion.ucl.ac.uk/spm/spm8_updates/
(Your version: 4290 - New version: 4667)
2781 files have been updated.

確かにアップデートされます。便利ですね。

New Lin4Neuro based on Xubuntu 12.04

I am pleased to announce the new release of Lin4Neuro based on Xubuntu 12.04LTS.
Only 64-bit version is released this time, but I’m working on 32-bit version so hopefully I will be able to release the 32-bit version in the near future.

I chose Xubuntu 12.04 as a base of Lin4Neuro simply because I don’t like Unity. If you look at the screenshot of new Lin4Neuro, you can tell that I made UI as simple as I could.

At the same time, I keep working on Lin4Neuro based on Ubuntu 10.04LTS, because FSLView doesn’t work on Ubuntu 12.04… I know some of users like to use FSLView, so I keep working on it.

Other than FSLView, there are some differences between versions.

  • New Lin4Neuro (L4N12.04) includes DSI studio in response to a request by Renaud Nicolas.
  • L4N12.04 doesn’t includ N3 tools. I haven’t been able to install the software yet.

So Now you have three options. From now on I will name the each version as following (I do not change the file name of old versions);

You can download each version from http://www.nemotos.net/lin4neuro/

Hope Lin4Neuro will help you enjoy playing with your images.

VBMの結果を用いて容積を測定する方法

VBMで得られる画像を用いて、灰白質や白質画像の容積を求めることができます。

事前の準備として、以下のことが必要です。

  • get_totals.m
  • Ged Ridgwayが公開している容積算出のためのスクリプトです。http://www0.cs.ucl.ac.uk/staff/g.ridgway/vbm/get_totals.mここから入手できます(右クリックしてリンク先を保存としてください)。これをSPMのディレクトリに保存します。

  • WFU PickAtlas
  • これは、局所容積を求めたい時に便利です。マスク画像を簡単に作成することができます。http://fmri.wfubmc.edu/software/PickAtlasここから入手できます。今回はこのセットアップ方法は説明しませんのであしからず。

続きを読む

The location of config file of Menu and Panel of Xubuntu

In the process of remastering customized Xubuntu, I spent lots of time to identify the location of config file of Menu and Panel of Xubuntu. Usually files should be located to /etc/skel, but xfce seems to have different policies.

The menu settings is stored in

~/.config/menus/xfce-applications.menu

and the panel settings is stored in

~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml

And the system-wide settings are stored in the locations below.

/etc/xdg/xdg-xubuntu/menus/xfce-applications.menu (menu)
/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml (panel)
/etc/xdg/xfce4/panel/* (panel)

You also need to copy some files in home directory to /etc/skel.

So if you want to reflect your personal customization in system-wide setting, you need to type the following from the terminal.

sudo cp ~/.config/menus/xfce-applications.menu /etc/xdg/xdg-xubuntu/menus/
sudo cp ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml \
  /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/
sudo cp -r ~/.config/xfce4/panel /etc/xdg/xfce4/
sudo cp -a .config .gconf .gnome2 .local .bashrc /etc/skel
sudo cp -a ./Desktop /etc/skel/
cd /etc/skel
sudo chown -R root:root .config .gconf .gnome2 .local .bashrc Desktop

Linuxでのファイル・ディレクトリ名一括置換

ときどきファイル名やディレクトリ名を一括で置換したいことがあります。

私の場合、こんなことがありました。

あるデータがこんなディレクトリに入ってきました。

120903
120904
120910

120929

しかし、私の管理方法では、

20120903
20120904
20120910

20120929

としたいわけです。

端末から簡単に打てるコマンドがないかと探したところ、

その名も rename というコマンドがありました。

rename 's/検索文字列/置換文字列/' ファイル・ディレクトリ名(ワイルドカード可)

となるようです。

私の場合

$ rename 's/^12/2012/' *

で目的を達成することができました。
備忘録として残しておきます。

Lin4Neuro日本語版ページの開設

これまで需要がありましたが、多忙にかまけてさぼっていたLin4Neuroの日本語版のページを作成いたしました。英語が苦手な方やとりあえず、何がどうなってるのと思う方々には多少お役に立てるのではないかと思います。
このブログの上の方にある「Lin4Neuro日本語版」をクリックしていただくか、
こちらからご覧ください。

Update of Lin4Neuro (18Sep2012)

I updated Lin4Neuro. The main changes of this version are the following.

  • FSL was updated to 5.0.0.
  • Slicer was updated to 4.1.1. (only in 64bit version)

Since FSLView doesn’t work well with Ubuntu 12.04, I stick to Ubuntu 10.04 for the time being.
However, I’m in the process of developing Lin4Neuro based on Ubuntu 12.04 (actually Xubuntu 12.04) now. Hopefully I will be able to release 12.04base version by the end of this year.

You can get the iso images from www.nemotos.net/l4n-iso

VMware player上でのLin4Neuroの使い方

画像解析に特化したカスタマイズOSのLin4Neuro。一定の需要があるようで、便利という声をいただいております。
画像解析のためだけにWindowsからLinuxに乗り換えることを躊躇している人も多いと思います。正直、私も画像解析のメインマシンはLinuxですが、日頃の雑多な仕事はまだWindows上で行なっています。Linuxは基本いいのですが、つまずいたときにすぐにトラブルシューティングできるだけの能力がまだないからです。

64bitでメモリもたくさんのっかる世の中、仮想環境がずいぶん充実してきました。Lin4Neuroも仮想環境でけっこういい感じで動きます。めちゃくちゃメモリを使う仕事でなければ、ノートPCに8GBのメモリを載せ、そのうち4GBを仮想に割り当ててそこでLin4Neuroを走らせれば、けっこういい感じで解析ができます。

ということで、VMware player(無償で入手できます)上でのLin4Neuroの動かし方をPDFドキュメントにしてみました。必要な方はダウンロードしてください。

Lin4Neuro_VMwareのダウンロード

Voxel-wise FDR and Topological FDR

In SPM8, voxel-wise FDR was hidden and Topological FDR was introduced. What is Topological FDR? I find some useful notes from SPM8 Release Notes and a post by Tom Nichols to SPM-ML. I quote these two.

SPM8 Release Notes

Topological False Discovery Rate (FDR)

FDR control is an alternative to the more conservative “family-wise error” control for multiple comparisons. Historically, SPM has aimed to control FDR on voxels (the
expected fraction of false-positive/total-positive decisions made about individual voxels in an image). This is now superseded by FDR control of topological properties of the signal (i.e. control of properties that pertain to the spatial organization of activations – e.g. height and extent – and are not reducible to individual voxels). SPM is now able to identify significantly voluminous blobs according to a decision procedure that controls spatial-extent FDR. Thus, on average, the fraction of blobs falsely deemed to have significant spatial extent is controlled beneath say 5/100 = .05 or 1/100 = .01. More recent work is examining FDR control over local maxima.

A post to SPM-ML by Tom Nichols

In SPM8 FDR topological inference was introduced, and voxel-wise FDR inference hidden. Topological inference means inference on peaks and clusters; voxel-wise inference is based on every individual voxel in the image (instead of spatial features of the image). Thus “Topological FDR” means inference on clusters based on cluster size (or local peaks based on peak height), controlling the fraction of false positive clusters among all clusters (or false positive peaks among all peaks) on average, over many experiments.

While topological FDR results may be easier to interpret, in my experience it is is generally not very sensitivity and yields similar results to FWE-corrected inferences.

If you would like to use voxel-wise FDR in SPM8, edit spm_defaults, changing “topoFDR” line to read
defaults.stats.topoFDR = 0;
(quit and re-start SPM to take effect).

References
Chumbley, J., Worsley, K., Flandin, G., & Friston, K. (2010). Topological FDR for neuroimaging. NeuroImage, 49(4), 3057-64. doi: 10.1016/j.neuroimage.2009.10.090.

Chumbley, J. R., & Friston, K. J. (2009). False discovery rate revisited: FDR and topological inference using Gaussian random fields. Neuroimage, 44(1), 62–70. doi: 10.1016/j.neuroimage.2008.05.021.

Shell script to replace a part of filenames

I came across a situation I want to change a part of filenames.
I have many nvXXXX.nii files, and I want to change it to n1vXXXX.nii.
Below is the shell script I came up with.
The point is using sed.

#!/bin/bash
# A script to change a part of filenames.
for FILE in $*
do
  echo $FILE | sed -e "s/nv/n1v/" # This is optional. I just want to display the filenames on the monitor.
  mv $FILE `echo $FILE | sed -e "s/nv/n1v/"`
done

The below might be better if I want to use the new filenames as some variables.

#!/bin/bash
# A script to change a part of filenames.
for FILE in $*
do
  echo $FILE | sed -e "s/nv/n1v/"
  NEWFILE=`echo $FILE | sed -e "s/nv/n1v/"`
  mv $FILE $NEWFILE
done

openSuse 11.1 で Scan Snap S510は使えるか?

*昔に書いた内容ですが、検索でひっかかることが多いようなので、再度アップします。

確定申告の時期で、いろいろな書類のコピーをとるためにScansnapが大活躍しています。

Scansnapを導入したとき、Windowsマシンに様々なドライバをインストールしなければいけなかったので、Linuxでは使えないだろうなぁと勝手に思っていました。

しかし、何気なく”scansnap Linux”でググってみたところ、ubuntuでXSANEを使うとできちゃうみたいなことが書いてある記事を発見しました。

そこで、opensuse 11.1でできるかどうか確認。

xsaneのインストールの確認
YAST -> ソフトウェアの管理 -> xsaneで検索してみると、自分のマシンにはインストールされていました。

scansnap S510をつないでみる。
WindowsマシンにつながれていたS510のUSBコードをLinuxマシンに差し替えます。

どのように認識されるか確認
lsusb でUSBデバイスのリストを一覧で表示できます。

こんな出力がされました。

$lsusb

Bus 005 Device 002: ID 04c5:1155 Fujitsu, Ltd

対応の確認
次の2通りの方法があるかと。

SANEのサイトで確認
http://www.sane-project.org/sane-mfgs.html#Z-FUJITSU

ここには、

S510 USB 0x04c5/0×1155 Good workgroup, current, no TWAIN driver fujitsu
(1.0.55) sane-fujitsu
とかかれています。きちんと動きそうです。

/etc/sane.d/fujitsu.confを確認
$less /etc/sane.d/fujitsu.conf

最後の行にS510があります。

#scansnap S510
usb 0x04c5 0×1155

きちんと動きそうです。

xsaneの起動
メニューから、グラフィックの中にxsaneがあるので、それから起動。

感動したのが、ADFが両面も選べるようになっていること。

(ただし、その場合は、スキャン枚数(一番上の項目)を2以上に設定しなければいけません。)

ScanSnap本体の緑色ボタンは使えないものの、xsane経由で、普通にScansnapが使えるようになりました。

これで、Windowsに依存しなければいけない要素がまた一つ減りました。

それにしても、最近のLinuxは便利になりましたね。

UbuntuのカスタマイズLiveCD/DVDにおいて、日本語ディレクトリ名への変更ダイアログを抑制させる方法

Lin4Neuro日本語版の開発において、英語版を元に、日本語版を開発し、Remastersysでリマスタリングを行うと、USBブートの際に下図のダイアログが出てしまう現象に遭遇しました。

この現象をどう解決するかどうか皆目検討がつかなかったので、Ubuntuのメーリングリストに聞いたところ、親切に2つ方法を教えて頂きました。

  1. user-dirs.localeのチェック
  2. 以下、メーリングリストへの投稿からの抜粋です。
    吉田様からアドバイスをいただきました。

    この表示の有無は ~/.config/user-dirs.locale が「存在するかどうか」と、
    「中身が現在のロケールと一致するかどうか」で判定されています。
    (see also: apt-get source xdg-user-dirs-gtkで取得できるupdate.c)
    動作は以下です。
     ・そもそも存在しなければそのまま。
     ・中身が現在のロケールと一致しなければ、アップデートを試みる。
     ・中身が現在のロケールと一致すればそのまま。
    英語表示にすると、このファイルの中身は「C」とだけ書かれたファイルになるので、
    日本語環境で起動すると次のような動作になります。
     1) user-dirs.localeの中身をチェック。
     2) user-dirs.localeの中身が「C」なので、現在のロケール(ja_JP)と違うので、
      アップデートダイアログを表示。
    ここで期待の挙動にするには、次の二つの方法があります。
     ・中身として「ja_JP」とだけ書いたものを置く(現在のロケールと同じなので
      問題のダイアログの表示が抑制される)
      # 改行を含めず、単に「ja_JP」と書いた5バイトのファイルを置く。
     ・そもそも削除する(「Don’t ask me this again」した状態と同じ)
    ホームディレクトリをどのように構成されているのかにもよるのですが、
    まず /etc/skel に .config/user-dirs.locale がないか見てみて、存在するなら
    (存在する場合の期待は中身「C」なので)中身「ja_JP」にする、というのが
    手早いような気がします。

    実際、user-dires.localeを見ると、en_USとなっていたので、これをja_JPにしたところ、問題はあっさり解決しました。

  3. 自動起動するアプリの設定
  4. これもMLの投稿からの引用です。
    西山様からアドバイスをいただきました。

    まず「設定」の中の「自動起動するアプリ」で
    「ユーザ・フォルダの更新」のチェックを外せば
    そのユーザでは出てこなくなります。
    その設定は
    ~/.config/autostart/user-dirs-update-gtk.desktop
    に残っていて、このファイルを
    /etc/xdg/autostart/user-dirs-update-gtk.desktop
    にコピーすればシステム全体で無効にできます。
    違いは
    X-GNOME-Autostart-enabled=false
    だけのようなので、直接
    /etc/xdg/autostart/user-dirs-update-gtk.desktop
    に書き加えても良いと思います。

誰かの役にたつかもしれないので投稿しておきます。