Sunday, June 28, 2015

Xiaomi Mi Pad: am loving it

Apple got it right long back. Now Xiaomi got it right. I can't help but love using Xiaomi Mi Pad. One reason is its display. Unlike most other Android tabs, its 7.9 inch screen has 4:3 aspect ratio; just like an iPad mini. Common tabs (even the costlier ones), with 16:10 or 16:9 aspect ratio, are good for watching movies and playing games in landscape mode. But the screen dimension of Mi pad is better for reading ebooks, pdf, taking notes, editing and reading MS Office documents. The retina display provides crisp fonts and sharp images. With 360 gm weight, Mi pad is easy to carry and hold in one hand, for long. With light weight, sturdy built and excellent display, it feels like carrying and working with a notebook. Just hold it in portrait mode, in one hand and use it.

Another key feature of Mi Pad is its long battery life. I am using it almost for one month now. I carry it all day and use it for web surfing, reading, taking notes and for minor editing of documents. Throughout the day it remains connected with my cloud storage through Wifi. On an average I get 16 hr of battery till it reaches ~20%.

Nowadays am using my desktop only for extensive typing, editing and drawing. Rest, my Mi pad can do.





P.S:
A. Lots have been written about the smooth interface of MIUI and  almost lag free multitasking in Mi pad. I concur those.

B. Xiaomi has not launched official accessories for Mi Pad in India. Am using MOFI flip cover for Mi Pad. It's nice.




Thursday, June 25, 2015

Batch script to automate simulations in MATLAB

Many of us use MATLAB to perform simulations. Often such simulations requires multiple runs of the same program. Suppose we are simulating an ODE -based model for a cell signaling pathway. We have created a main function (say Main.m) that execute the simulation while calling and using other functions. We want to simulate the same model with large number of different values of a particular parameter. One way of doing it, is to modify the code itself to run multiple simulations with different sets of parameter values. But, I would prefer not to tamper with the code. The other option is to change the parameter value and run the simulations one after another. That's bit cumbersome and unprofessional. Can't we automate the process?

Yes, we can. Don't hard code the parameters in the main code. Let it read the parameter values from a separate file. That can be a text or m-file. Make multiple folders having all the codes and parameter file. Change the values in the parameter files in these folders. Now use a script to run the simulation from each of these folder, one after another. Note that each of the sub-folder should have all the codes to run the simulations independently.

Even, you can use this strategy to, sequentially, run completely different simulations from different sub-folders. The only requirement is that you have to use same name (Main.m) for all the main functions. 

The batch script written bellow does exactly that. My PhD student Vimalathithan wrote the script. If you find it useful, do give him the credit.

This may not be the only way or best way to automate multiple runs. Please do write back, with your take on this issue.

batch_script.bat
:: -The script automates sequential repeated run of same Matlab code. 
:: -The user should enter the location of the parent folder which contains the Sub models
:: -The user should enter the location of matlab.exe file
:: -Every event is recorded in a LogFile.txt in the parent directory
:: -The scripts does the following job 
::  1.Creates a text file holding the name of the sub folders present in the parent directory
::  2.Executes each sub folder by invoking the main function (Main.m)
::  3. If the function is not found, the error message is recorded and the loop continues with the next sub folder.
::  4.If matlab throws any error, the error message is recorded and the loop continues with the next sub folder
::-------------------------------------------------------------------------------------------------------------------------
::Enter the location of the Model 
set ModelDir=D:\Dropbox\modeling_tool\MATLAB_vimal\ODEmodeling\ODE1

::Enter the location of the Matlab.exe file
set MatlabDir=C:\matlab\bin\matlab.exe
::-------------------------------------------------------------------------------------------------------------------------
::Do not make any changes in the code below
::-------------------------------------------------------------------------------------------------------------------------
cd %ModelDir%
Echo Start time is %date%_%time%>LogFile.txt
::Lists the folders in the current directory and writes them in a text file
dir /A:D /O:N /B>List.txt
setlocal enableextensions enabledelayedexpansion
Echo off
::Counts the number of lines in the text file
for /F %%A in ('type "List.txt"^|find "" /V /C') do (
 set /A count=%%A
)
set /A num=1
::Executes the matlab code present in each sub folder
for /F "tokens=*" %%A in  (List.txt) do (
 Echo.>>%ModelDir%\LogFile.txt
 Echo Executing !num!-%%A of %count%
 cd %ModelDir%\%%A
 IF EXIST ErrorFile.txt (
  del ErrorFile.txt
 )
 IF EXIST %ModelDir%\%%A\Main.m (
  "%MatlabDir%" -nodisplay -nosplash -nodesktop -wait -r "run('Main.m');exit;"
  IF EXIST %ModelDir%\%%A\ErrorFile.txt (
   Echo %%A is not executed>>%ModelDir%\LogFile.txt
   Echo WARNING. Matlab has logged an error file in the location %ModelDir%\%%A>>%ModelDir%\LogFile.txt
  )
  IF NOT EXIST %ModelDir%\%%A\ErrorFile.txt (
  Echo %%A is executed successfully>>%ModelDir%\LogFile.txt
  )
 ) 
 IF NOT EXIST %ModelDir%\%%A\Main.m (
  Echo %%A is not executed>>%ModelDir%\LogFile.txt
  Echo WARNING. Main function is not found in the location %ModelDir%\%%A>>%ModelDir%\LogFile.txt
 )
 set /A num+=1
 cd %ModelDir%
)
endlocal
Echo.>>%ModelDir%\LogFile.txt
Echo End time is %date%_%time%>>LogFile.txt
::Deletes the List.txt file
del List.txt
Echo on

Monday, January 26, 2015

How to stay updated with latest literature

When I was doing Ph. D, online publishing of scientific journals had just learned walking. We were more dependent on hard copies of journals in libraries. For many of us, it used to be a ritual to regularly visit the library and flip through the pages of our favorite journals, to catch the new and relevant to our work. But, the Internet has changed the way we access journals now. It has democratized access to knowledge and also overwhelmed us with information. Hundreds of papers get published every day. Though you may have access to most of those, it’s difficult to keep track of papers of interest. Thankfully, there are tools that can help you to keep you informed about the latest literature in your field. 

E-mail alert by PubMed: NCBI PubMed has changed the way we do biomedical research. You must be searching this database at least once every day. Do you know that you can make an personal account with NCBI to save your searches? Visit MyNCBI page to make an account. Log in your account. Perform a search using a keyword suitable for your research. This time you will get a link for "Save Search", near the top of the search results page. Click it. It will take you to a page to save your search result with option to activate email alert for new results on this key word. You can select the frequency of such update. I select to get update daily, so that whenever there is a new paper, I get informed immediately. You can anytime come back to your MyNCBI page and edit your saved searches. The key of this email alert is the key word(s) used for the search. Therefore, you have to be very careful in choosing them. Use different key words and create saved searches for those. Subsequently, based on the email alerts, you may change the keywords. 

Twitter: Do you Tweet. No am not asking you to use Twitter to add spice to your social life. You can use it as a powerful tool to keep updated with what's happening in your field of study. Most of the reputed journals use social media, including Twitter, to spread news about important papers published by those. Even, scientific associations use Twitter to announce breakthrough in specific fields. Even many scientists use regularly Tweet about latest papers published by them and their peers. So join Twitter. Find out Journals and organizations of your interests in Twitter. Start following them. See if any of your peers is there in Twitter. Follow them too. Then make a habit to scroll through the tweets once daily. And don’t be just an observer. Reciprocate. Tweet about your new publication. Tweet about a recent paper that you found interesting. Build a social network around your science. 

Faculty of 1000: This is what you have always dream of. A bunch of experts reading and flagging latest literature for you. Obviously, this does come with a cost. Subscribe to F1000Prime. Choose particular topics of your interest and even experts to follow from the list. F1000 will send you email alerts whenever your experts review a brilliant paper of your interest.  One day, maybe your paper will also get reviewed by F1000 and get the prestigious badge of F1000 in the PubMed. Till then enjoy reading.