Xubuntuで用紙サイズがLetterになってしまうとき…

Xubuntuでいろいろ印刷するときに、用紙をA4と設定しても、プリンターの方で、「Letterになっています。強制印刷しますか?」のような警告が出ることがいつもでした。
原因は何だろうと思っていたら、次の変数でした。

/etc/environment
の中にLC_PAPERというものがあります。

これが、私の場合、

LC_PAPER="en_US.UTF-8"

となっていました。調べたところ、この設定だと用紙サイズのデフォルトは、Letterになること。
なので、これを

LC_PAPER="ja_JP.UTF-8"

と変えたところ、問題がなくなりました。
locale設定が用紙サイズにも影響しているんですね。
Xubuntuだけでなく、Ubuntuでも同じようなことが起こるのだと思います。

How to do Topological FDR

Many ask “how to do Topological FDR” in SPM ML. Below are the posts I found useful.

Originally Guillaume Flandin showed how to do that.
https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=SPM;44838216.0904

The height threshold you define during the Results procedure is the feature-inducing threshold (used to define local maxima and clusters).
For topological FDR, I would typically choose “none” and a small T-value, for example 3.
The MIP will display all voxels whose T-value is above 3 and the Results table will display all local maxima whose T-value is above 3 (actually, at most 3 local maxima per cluster, more than 8mm apart) and the corresponding FWE p-values and FDR q-values for peaks and clusters.

If you want to threshold the MIP to a particular significance level, go through the Results procedure again and enter the corresponding height and extent thresholds (the 0.05 critical thresholds are indicated at the bottom left of the Results table):
(height) FWEp and FDRp for peak-FWE and -FDR.
(extent) FWEc amd FDRc for cluster-FWE and -FDR.

Jonathan Peele also gave a detail instruction of how to do that. This time he focused more on cluster-thresholded FDR.
https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=SPM;6f4e0139.1110

> How can I see images with a threshold at the cluster-level instead of the peak level with the graphical user interface?

I’m not aware of a way to set a cluster-level threshold when running results the first time (i.e., “show everything that is cluster-level corrected p < .05").  What I would do is this: 1) Run results using some voxelwise threshold.  This threshold defines your clusters, and it's fine to use an uncorrected threshold (e.g., p< .001, uncorrected). 2) In the results table, for each cluster you will see the cluster extent (i.e. how many voxels) and the cluster-corrected p value.  In SPM8 you will see 2 cluster-corrected p values, one for topological FDR (Chumbley & Friston, 2009), one for random field theory (labeled FWE).  You can then look at the size of those clusters, and figure out the cluster extent  that divides p < .05 from the others.  For example, if a cluster of 300 voxels is p = .10, and a cluster of 400 voxels is p = .04, then you know that any cluster 400 voxels or larger would be p < .05. 3) Re-run the results, selecting the same voxelwise threshold. But now, in the minimum cluster extent, specify the cluster size you just figured out—in the above example, you could specify 400.

4) Now all of the displayed results should be cluster-level corrected.

5) If you want to save this thresholded image for displaying with another program, just click the “save” button, and you can write out a thresholded t map as a nifti file.

In practice this is actually fairly quick to do once you’ve done it a couple of times.

Note the difference between these two. Two-step approach is the same, but Guillaume’s way deals with peak and cluster threshold and Jonathan’s way deals with cluster threshold.

Lin4NeuroをUSBメモリから起動する方法

普段Windowsを使っているけれども、Linuxを使ってみたい。そんな人はある程度いると思います。特に、画像解析をする人は特にそうかもしれません。
そんなとき、3つのオプションがあります。

  1. WindowsにVMware playerやVirtualboxなどの仮想化ソフトをインストールし、その中にLinuxをインストールする。
  2. これはなかなか便利です。私も普段、これで仕事をしています。Lin4Neuroの開発はVMware上で行なっています。何度も試行錯誤がきくからです。具体的な方法はこちらに記載しましたので、そちらを御覧ください。

  3. USBメモリにインストール
  4. これが今から示す方法です。これが便利なのは、自分のPCでなく、手元に転がっているPCで同じ環境を再現できるということです。もしくは、チュートリアルなどで人に何かを伝えたい場合に、自分で環境を準備しておいて、USBメモリを準備することで他の人が全く同一の環境を再現することができます。

  5. Macに乗り換える
  6. Mac OSXはBSDベースで、Bシェルが普通に走ります。これは結構便利で、最近、Macに乗り換えようかどうか真剣に考えています。でも、一つのことに傾倒しすぎるのはどうかなとも思っているので、MacBookProを持ってはいますが、まだメインマシンとはなっていません…。

LinuxをUSBメモリにインストールする方法は知っておくと何かと役に立つことがあります。Windowsのファイルが壊れてしまい、Windowsが立ち上がらなくなった時、LinuxブートのUSBメモリを持っておけば、それから起動してPCから多くのファイルを救出することができます。なので、Lin4Neuroに限ったことではないのですが、便利なのでその起動方法をPDFドキュメントにまとめてみました。下のリンクからどうぞ。

Lin4Neuro_USB.pdfをダウンロード

Files generated in VBM statistics

When you do VBM analysis, you see many files are generated in your stats directory. Suppose you are doing a two sample t-test. You see files like below.

  • beta_0001
  • beta_0002
  • con_0001
  • mask
  • ResMS
  • RPV
  • spmT_001

Ged Ridgway made a clear explanation of these files in NITRC discussion forum. http://www.nitrc.org/forum/message.php?msg_id=6483
It is important to know what these files are, so I quote his post with some modification.

  • beta
  • The estimated linear model parameters at each voxel. In a two-sample design, these are just the two group mean images. beta_0001 is a mean image of group A, and beta_0002 is a mean image of group B.

  • con
  • The contrasts of the parameters. If one makes a contrast of [-1 1], the con_0001 will simply be beta_0002 – beta_0001

  • mask
  • A binary image indicating which voxels were considered in the analysis. If this mask is too small, you may miss the region you are interested in. If too big, it is less likely to survive multiple comparison. So it is worth checking the mask image before you draw some conclusion from your analysis.

  • ResMS
  • The estimated variance (residual mean squares), from which the above-mentioned standard error is derived.
    In more detail, the standard error is proportional to the square root of ResMS and a term that relates to the design matrix X and contrast c as sqrt(c’*pinv(X’*X)*c), which (in two sample t-test) roughly reflects the fact that the standard error is inversely proportional to the number of subjects one has.

  • RPV
  • The resels-per-voxel image related to the smoothness (roughness)
    estimate needed for random field theory.

  • spmT
  • The t-statistic maps formed by dividing the contrast image by its estimated standard error.

Aterm WM3600Rで無線LANの接続が頻繁に切れる場合の対策

私は普段WiMAXを使っているのですが、最近手に入れたAterm WM3600Rは非常に無線LANの接続が切れていました。
これでは、意味がないじゃん!と思っていましたが、検索すると多くの人が同じ症状で苦しんでいました。

NECが公式に対策を発表しているので、それを備忘録も含めて下に書きます。

出典はこちら

  1. クイック設定Webを開きます。
  2. http://aterm.me  で開きます。

  3. 左メニューから『無線LAN設定』-『無線LAN設定』を選択します。
  4. 『無線LAN設定』画面が開きますので、【高度な設定を表示】ボタンを押して「拡張設定」を表示させます。
  5. ここで以下の設定を行います。
    メーカーのページには以下のように書かれています。

    いずれかの設定を行うのみで改善される場合や、複数の設定を行うことで改善される場合があります。記載された内容を1つずつお試しください。また、これらの設定を行っても原因が別にある場合は、改善されない場合もあります。

    1. [無線LAN端末(子機)との通信設定]で【省電力優先】を選択する。
    2. ※上記設定を行うと、スループット(実行速度)が低下する場合があります。

    3. [無線優先制御機能]で【使用する】に入っているチェックを外す。
    4. ※上記設定を行うと、11bまたは11gでの通信となり、11nテクノロジーでの通信は行えません。

    5. [送信出力]で【100%】を選択する。
    6. ※上記設定を行うと、他の通信機器が近くにある場合は、電波の干渉が受けやすくなります。

    どうもいろんな人のブログを見ると、一番最初にある無線LAN端末との通信設定で省電力優先を選択することがよいようです。
    実際、その設定で切断が圧倒的に減りました。
    通信速度よりも接続の安定の方がずっと大事なので、そちらでしばらくやってみます。

Neurodebianのミラーサイト

このブログでも今までに紹介し、そしてLin4Neuroでも採用させていただいてきたNeurodebianですが、開発者のYarsolav Halchenkoといろいろやりとりした結果、日本でミラーサイトを立ち上げました。最近はファイルサイズの大きなものもありますので、日本からの場合、このミラーサイトを使っていただいたら、ダウンロード時間を短縮できる可能性があります。

方法を簡単に説明します。

まず、http://neuro.debian.netにいきます。

トップページにある、”How to use this repository”を見ます。

そこに、下図にあるような感じでDebianかUbuntuのリリースとダウンロードサイトを選ぶドロップダウンメニューが出てきます。

そこに出てくる2行を端末にコピペします。Ubuntu 12.04の場合は以下の2行になります。

wget -O- http://neuro.debian.net/lists/precise.jp | sudo tee etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver pgp.mit.edu 2649A5A9

その後、apt-get updateと、apt-get upgradeを行い、さらにapt-get installで必要なソフトをインストールします。

それだけで設定はおしまいです。便利ですよね。

いろいろな画像解析関連ソフトが簡単にいれられますので、どうぞ利用してみてください。
日本語版Lin4Neuroでもこの日本のミラーサイトがデフォルトになっています。

How to install FSL on Ubuntu (up to 5.0.9)

N.B.: This is the old post. If you want to install the latest FSL (5.0.10 and later), you need to use fslinstaller.py.

If you use Debian or Ubuntu, you can install FSL easily using neurodebian repository.
Below is what you need to install FSL.

  1. Add the neurodebian repository
  2. Follow the guideline described here.

  3. update the sources.list
  4.         $ sudo apt-get update
            
  5. install FSL (and related packages)
  6.         $ sudo apt-get install fsl fsl-doc fslview fslview-doc fsl-atlases fsl-possum-data fsl-first-data fsl-feeds dicomnifti libvtk5-dev vtk-examples vtk-doc
            
  7. Add the following line to .bashrc
  8. This is the thing people often forget. Without this, you can’t run fsl from shell.

             . /etc/fsl/fsl.sh
             

    That’s it.

Windowsでコマンプロンプトが無効にされているときの裏ワザ

 知人にPCがおかしいから見てくれと相談され、見ました。コマンドプロンプトから確認しようと思ったところ、そのPCが管理されている職場のポリシーで、コマンドプロンプトが無効にされていました…。検索してもあまり方法はありませんでした。
 普通ならそこで諦めるところですが、なんか方法がないかなぁと思い、いろいろ試行錯誤してみました。
 非常に簡単な抜け穴がありました。

 それは、「ショートカットを作成する」という方法です。デスクトップ画面から右クリックで、「新規作成」→「ショートカット」とし、「項目の場所を入力して下さい」となっているところで、”cmd”とタイプします。そうすると、cmd.exeへのショートカットと出てきます。そこからコマンドプロンプトを立ち上げることができます。

 検索すると、Windowsには、コマンドプロンプト自体を無効にするというオプションもあるようですが、いろいろ抜け穴がありそうですね。逆にセキュリティ上はやはりもろいシステムということになるのでしょう。

 このブログでは、Windowsネタはほとんど扱わないと思いますが、気になったことだったのでアップしておきます。

Voxel-counting script

Sometimes we just want to count the number of voxels whose values are more than zero.
My friend showed me a script which can do that easily. SPM functions are used, so you need to install SPM first.

%%%%%countvx.m
%a script which counts voxels whose values are more than zero.
file = spm_select;
vol = spm_vol(file);
img = spm_read_vols(vol);
sum(img(:)>0)

If you change the value of the last line from 0 to 0.1, you will count the number of voxels whose values are more than 0.1.

Installing R and JGR on Ubuntu Lucid Lynx

The other day I wanted to install R on Ubuntu. Googling led me to this site, but I found some of them are not up-to-date. In addition, I don’t use Sun-Java but open-JDK. So I needed to change things a little bit.

Below is what I did. Note that I already installed openJDK.

  1. Add an R repository to /etc/apt/sources.list
  2. First, you need to decide a CRAN mirror close to where you live. The list can be found here. Since I live in Tsukuba Japan, I added the following line to /etc/apt/sources.list

    deb http://cran.md.tsukuba.ac.jp/bin/linux/ubuntu lucid/

    Below is the format.

    deb http://my.favorite.cran.mirror/bin/linux/ubuntu lucid/

  3. Obtain the public key of Ubuntu repository
  4. The Ubuntu archives on CRAN are signed with the key of “Michael Rutter
    ” with key ID E084DAB9. You can fetch this key then feed it to apt-key with the following lines.

    $ gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
    $ gpg -a --export E084DAB9 | sudo apt-key add -

  5. Update the respository
  6. $ sudo apt-get update

  7. Install r-base
  8. sudo apt-get install r-base r-base-dev

  9. Upgrade the repository
  10. By upgrading the repository, r-cran-* will be installed.

    $ sudo apt-get upgrade

    The following should be displayed.

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    The following packages will be upgraded:
    r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools
    r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix
    r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial
    r-cran-survival r-doc-html
    17 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 12.2MB of archives.
    After this operation, 827kB disk space will be freed.
    Do you want to continue [Y/n]?

  11. Set java configuration
  12. $ sudo R CMD javareconf

  13. Start R environment
  14. $ sudo R

  15. Install JGR inside R environment
  16. install.packages('JGR')

    A GUI will popup asking you to select a mirror to download from. Select the same mirror as before, though it doesn’t matter.

    After installation is completed. Add the library and install the ggplot2 library.

    library(JGR)
    install.packages('ggplot2', dep = TRUE)

    This will take some time.

    After that, you can start JGR by typing

    JGR()

    This will bring up JGR.

    But this is not the end. Please look at the shell carefully, which says,

    Starting JGR run script. This can be done from the shell as well, just run
    /usr/local/lib/R/site-library/JGR/scripts/run

    That means that you don’t have to run R first before running JGR.

    Now I will make a launcher of JGR.

    Right-click of GNOME menu –> “Edit Menu”

    That will pop up Main Menu Dialogue.

    In this case, I want to put the JGR launcher under Science, so click “New Item”

    Then you will see JRG in the menu. Note that I got the made the icon of JGR from the JGR site. I also customized the user interface. The screenshot is the from Lin4Neuro.