Monday, May 28, 2012

やがて見えてきた全貌

卒論を書き続けること早数ヶ月。ようやくすべてのラフをまとめてみました。引用や目次、他所参照なども整理して、完成も近く感じます。これでうまく行けば良いのですがね。

しかし卒業よりも、まず現実的な問題を考えなければ。ラフは現段階で338ページ。これを3部、いずれハードバインドしなければならんわけです。大学の学部を卒業する際に提出した卒論はこれよりページ数が少ない上にソフトバインドだったにも関わらず、出費がかなりの痛手だったとの記憶が。大学と印刷屋間で裏の取引を疑ってしましますね。

夏は日本に3週間ほど帰る予定なので、それまでに提出しなければ。口頭試験はその後になりそうです。


これを印刷せねばならんのですよ、これを・・・(汗

Tuesday, May 8, 2012

献血に行ってきた

タイトル通りです。

最近Facebookにて、ドナーの意思表示ができるようになって以来、ドナーの数がうなぎ上りだそうですが、自分の記憶が正しければ、本人が死亡した際、ドナーとして臓器が実際に提供されるためには、自身の意思表示に加え家族の同意が必要であるはず。Facebook話題の新機能に便乗するミーハー献身的な心意気は評価しますが、実際に本人が死亡した際にスムーズに臓器提供に至るには、事前に家族に話しておくことや、法に基づいて書かれた遺書を用意しておくことが大事なのではないでしょうか。自分たちの世代の親はFacebookなんて知らない人も大勢でしょう。不慮の際に事前の断り無くして、子供の臓器提供を促されても、親は何のためらいもなくそれに従うとは思えません。少なくとも臓器提供に至る数の減少は免れないでしょう。そんな事態を未然に防ぐため、またFacebookのドナーステータスを変えるという動機の無駄を防ぐためにも法的な手段を講じておこうと、自分は思った次第であります。

とりあえず、できることから始めようということで献血に行ってきました。当たり前すぎて、いまさら書くことでもありませんが、献血で救われる命もあることも事実です。献血とは人に勧めるものでは全くありませんが、行って良かったと自分は思いました。

Saturday, May 5, 2012

Guides to PyMOL movies


Guides to making movies with PyMOL

Here is an attempt to compile my current know-hows. By no means will this guide be sufficient for you, so please Google away for further questions. I will gradually update this guide, so please comment what you want to see, and I'll help to the best of my ability. I used PyMOL 1.3, but it may make sense to buy the latest version since it only costs $99 and supposedly it makes life so much easier.

Here is a link to an example along with the scripts I used. I am still a novice, and I don't know how to contain several maneuvers into a single file, and to move from one scene to the other, so you'll find that I frequently use Fade transition effect of PowerPoint animation.

1. Brief step by step guide
 
1.1 Decide your Framerate (FPS). 24 FPS is usually sufficient.

1.2 Visit the drawing board, decide what you want to present, and how many seconds to be allocated in each motions (zoom in, rotation, rock etc). For example, to make a movie that lasts for 3 seconds at 24 FPS, then:-
#To create 24 * 3 = 72 frames
mset 1 x72

1.3 Decide/define the size (2D pixel size) of your movie. This can be of any value you want, but why not stick to a typical pixel size for a movie, for example 640 ´ 480. Some video encoder will automatically add few pixels to the edge when fed with movies with odd-numbered pixels, which is confusing when you plan to do transition effect with static pictures in Powerpoint.
#Set the current window size to 640*480
viewport 640, 480

1.4 Add commands, or compile all the commands into one script file (.pml) and run it by File / Run.
####To be updated####
Please refer to section 2 for the time being.

1.5 Save Movie As / PNG images and output each frames as a PNG image.
 
★TIP: Check the Movie/Ray Trace Frames option on for better results. It will take longer to render every frames by ray tracing, but it's prettier

1.6 Convert the consecutive PNG images into a movie. There are several ways to achieve this, and the preferred way will depend case by case. First of all, decide if you want your movie to be either :-

A.       Animated GIF file  OR
B.       Movie

An animated GIF is not bad if you want to carry out simple maneuver (e.g rocking, rotation) that occurs indefinitely. Two issues are associated with animated GIF.

1.        I found that it is not suited for single-play maneuver (zoom-in), because PowerPoint 2010 does not interpret the “-loop” flag of the GIF file correctly, and will play the movie over and over again, even if you set the flag as play once only (GIF made by ImageMagick 6.7.6.5, the correctness of the GIF output confirmed by Firefox 11.0).

2.        An attempts to increase the play speed by decreasing the “-delay” value below 3.3 (milliseconds?) was not reflected in the PowerPoint sideshow, so the resulting animation was slow.

If you're happy with GIF, then compile the PNGs into one GIF file with the following command, and copy & Paste into your PowerPoint slideshow.

#ImageMagick
#-delay: time delay between each frames in milli seconds (?)
#-loop: 0 for no loop, 1 or remove altogether for loop.
convert -delay 3.3 -loop 0 mov00??.png movie.gif



If you think a GIF won't cut it for you, then I recommend compiling the PNG pictures into a movie.

Be careful about the codec when including a movie in a slideshow :-

1.        If you are bringing your own laptop and plugging it into the project for the talk:
You don’t have to worry so much, because the projector will project whatever you see on the screen, so you only need to worry the slide works on your computer or not. You can choose whatever codec you like.
Be aware, you could still face trouble unrelated to codec, such as that the projector doesn't show what you see on the screen. (
Videos play correctly on computer but not on projector (black box))

2.        If you are bringing just your presentation file in a USB stick:
You has to be sure that the codec you’ve used is also available on the computer you will be using. Usually it’s a Windows PC, so WMV format (comes default with any Windows) is the best bet. If you know that you’re using a Mac on the day, then either Quicktime (.mov) or h.264 format will do the job
.

Some software that can convert consecutive PNG images into movies.
MGen (Japanese): Used to create uncompressed AVI file from the PNG images. Can specify FPS.
QuicktimePro: It’s supposedly good, but I’ve never used it. I’m not sure if it can output in WMV format.
Or any encoder of your choice: To encode the uncompressed AVI into your favourite format.

As an example, I used :-
1. MGen to create uncompressed  AVI file from consecutive PNG files. (specify FPS)

2. TMPGEnc 4.0 Xpress to convert uncompressed AVI file into WMV file. (specify bit-rate)

You should specify FPS and the quality when converting the consecutive PNG into a movie file. I use 1500 kb/s for slow moving scene (rocking motion) and 5000 kb/s for fast moving scene (zoom-in).

Give me a shout if you want me to do the encoding for you.

1.7  Insert your movie into the PowerPoint slideshow. PowerPoint since 2007 can embed the movie into the slideshow file.


2. PyMOL commands, etc
Multiple commands can be copy &and pasted into a text file, save it with .pml extension, and be executed form  File - Run.

#make 60 frames
mset 1 x60


#Get current window pixel size
print cmd.get_session()["main"]

#Set the window pixel size to 640*480
viewport 640, 480

#label 44th residue at its CA atom
label n. CA and i. 44, "(%s, %s)" % (resn, resi)


#make label larger, size 1 (or any other value)
set label_size, -1


#zoom out along axis perpendicular to screen
move z, -70


#movie, rock. (first frame, last frame, +/- 5, 0=loop ?, axis)
movie.rock(1,60,10,0,1)


# Get the current point of view
get_view

# Set the current point of view
#An example given below. Copy & Paste the output from "get_view" command.
set_view (\
     0.774900615,   -0.588428438,    0.230829433,\
     0.420271188,    0.752415657,    0.507189453,\
    -0.472124964,   -0.296011031,    0.830345929,\
     0.000022355,    0.000021480,  -68.459259033,\
    37.393062592,  -43.430206299,  -63.053943634,\
    45.082897186,   91.842987061,  -20.000000000 )

# Smooth zoom in from one predefined point of view to the other over certain frames.
# go to the first frame
frame 1
#make sure you're at where you want to start your animation. Use "set_view" command.
mview store
# go to the last (or any other predefined) frame
frame 90
#make sure you're at where you want to end your animation. Use "set_view" command.
mview store
# now link the two stored camera positions together:
mview reinterpolate

#play your movie
mplay


#ImageMagick
#delay 3.3 seem to be the fastest for unknown reason (number in milli seconds.
#-loop: 0 for no loop, 1 or remove altogether for loop
convert -delay 3.3 -loop 0 mov00??.png movie.gif


3. Terminologies

Bitrate: Amount of information streamed per second. Larger the bitrate, clearer the picture is. But too high bitrate will result in enormous file size as well as insufficient bandwidth between where your slideshow is located (e.g. USB stick) and the PC, resulting in choppy movie. Bitrate will be affected by the FPS and quality of the picture.

Frames per second (FPS): How many pictures to be shown per seconds. Larger the number is, smoother the movie is, but will increase the bitrate.

Codec: A sub-program to encode your video. A codec is needed in order to encode and to decode a video. You need to encode your video with a codec for a certain format – otherwise uncompressed AVI will be impractically huge. Modern codec allows you to make your video file size tiny while maintaining reasonable quality.


Digital container format

180 degree rule: If your motion involves changes in point of view, it’s best to keep the positions of the objects constant relative to the audience, before and after the motion, otherwise the audience will become confused.