Ubuntuのキーボードセッティング

Ubuntuではキーボードのレイアウトを簡単に変えることはできますが、「システムデフォルト」はコマンドラインでしか変えられないようです。

keyboard

変えたい時は以下をタイプすれば大丈夫です。

sudo dpkg-reconfigure keyboard-configuration

ちなみに、私はThinkapd 430sの英語キーボードを使っているので、Generic 101に変更しました。

TeX Live 2012 on Ubuntu 12.04

Windows 8.1を試しに使ってみたら、あまりにも不適応を起こしたので、この際、思い切ってメイン環境をLinuxに切り替えることにしました。

OSはXubuntu 12.04ベースのLin4Neuroです。自分が使いやすいようにカスタマイズしているので、一番自分にぴったりあっています。
Latexに関しては、TeX Live 2012を入れたいと思っていたのですが、検索したら、こちらのサイトに非常にわかりやすく解説されていました。やるべきことは下記のとおりです。

sudo apt-add-repository ppa:texlive-backports/ppa
sudo apt-get update; sudo apt-get upgrade; sudo apt-get install texlive-lang-cjk

こんなに簡単にできるのは感動ものです。

Ubuntu 12.04でLibreOfficeを3.xから4.xにアップグレードする方法

Ubuntu 12.04LTSを利用していると、LibreOfiiceは3.xのままです。
しかし、LibreOfficeは4.xにアップグレードされ、互換性なども高まっているようです。
以下の方法で、簡単にLibreOfficeを3.xから4.xにアップグレードできます。

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get dist-upgrade

ここでポイントは、apt-get updateの後にapt-get dist-upgradeを行うことです。

apt-get upgradeとapt-get dist-upgradeの違いは、man apt-getに以下の記載があります。

upgrade
upgrade は、現在システムにインストールされている全パッケージの最新バージョンを、/etc/apt/sources.list に列挙した取得元からインストールするのに使用します。現在インストール中のパッケージに新しいバージョンがあれば更新しますが、いかなる時も現在インストール中のパッケージの削除は行いません。対象のパッケージが、他のパッケージのインストール状態を変更せずに更新できない場合は、現在のバージョンのままとなります。最初に update を実行しておき、apt-get にパッケージの新しいバージョンがあることを知らせる必要があります。

dist-upgrade
dist-upgrade は、upgrade の機能に加え、新バージョンのパッケージに対する依存関係の変更を知的に操作します。apt-get は「洗練された」競合解決システムを持ち、必要とあらば比較的重要でないパッケージを犠牲にして、最重要パッケージの更新を試みます。そのため dist-upgradeは、いくつかのパッケージを削除する可能性があります。/etc/apt/sources.list ファイルには、必要なパッケージファイルを検索する場所のリストが含まれています。

upgradeは全く削除されることなく、dist-upgradeは必要あらばファイルを削除する可能性があるわけですね。今回、LibreOfficeの3.xから4.xへのアップグレードには、いくつかのファイルが削除される必要もあるので、dist-upgradeを利用することとなります。

何はともあれ、この3つのコマンドで、LibreOfficeを3.xから4.xにアップグレードできます。

Script to change images to 300dpi TIFF format

When we prepare research paper, many journals require the resolution of images to be 300dpi.
Below is the script to change various image files to 300dpi TIFF format.

#!/bin/bash
#A script which converts various image file formats into 300 dpi TIFF format.
#Usage: dpi300tiff.sh filename
#Wild card can be used.</code>

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

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

ubuntuのホスト名の変更

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

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

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

備忘録として。

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.

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でも同じようなことが起こるのだと思います。

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

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

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

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

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

続きを読む

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.

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

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をダウンロード

VMware player上でのLin4Neuroの使い方

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

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

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

Lin4Neuro_VMwareのダウンロード