Linux packages of XPPAUT/XPP version 8.0

Here you go.

https://software.opensuse.org//download.html?project=home%3Adilawar&package=xppaut

These packages are not well tested. Except for main command xppaut, nothing else is packaged.

 

Advertisements

Image stabilization using OpenCV

This application deals with video of neural recordings. In such recordings, feature sizes are small. On top of it, recordings are quite noisy. Animal head movements introduces sharp shakes. Out of the box video stabilizer may not work very well on such recordings. Though there are quite a lot of plugins for ImageJ to do such a work, I haven’t compared their performance with this application. This application is hosted here https://github.com/dilawar/video_stabilizer and a demo video is available on youtube here  https://www.youtube.com/watch?v=vGjIFvzOOQ8 .

The summary of basic principle is following:

0. Collect all frames in a list/vector.

1. Use bilateral filter to smooth out each frame. Bilateral filter smoothens image without distorting the edges (well to a certain extent).

2.  Calculate optical flow between previous frame and current frame. This is a proxy for movement. Construct a transformation and store them in a vector. OpenCV function `goodFeatureToTrack` does almost all the work for us.

  1. Take average of these transformations and apply it on each frame of original recording; that’s correct motion.

Using mutt – saving password and writing mail in markdown

If I were to be forced to replace my mutt with some other general purpose email client I’d prefer thunderbird with plugin muttator.

If you prefer easy to setup and click-based tools then you will not find mutt very exciting, however those who loves to split hair and tweak their tools to their whims will find much in mutt to please them. Learning the full power of mutt takes time and some sort of persistence. This post is not intended for first time user. It is meant for those who have tried their hands on mutt. In the end, there are some link which can help who wants to start using mutt. I had the fleeting temptation to combine my scripts in one which can set up mutt automatically for arbitrary no of accounts, but then it beats the whole purpose of tweaking the tool.

Storing password

Mutt stores password in plain text format. To avoid this, I used gpg to encrypt a file in which password are stored. For example, a simple text file is created to store the password.

export EE_NAME="Dilawar Singh"
export EE_USER=dilawar
export EE_PASS=password1

This has export command which set an environment variable. Now I encrypt the file using gpg

gpd -c password.txt

It will ask for a pass-phrase. When decrypting the file, you have provide the same pass-phrase. Passphrase are easy to remember and hard to crack. If I were Gabbar Singh, I would have chose something like thakur a per katne chahiye the. Hard to guess and easy to remember, isn’t it? An encrypted file will be created by gpg default name password.txt.gpg. Mutt can read environment variables, let’s exploit this fact. We write a wrapper around the mutt command. Let’s name this script my_mutt or after the name of your pet doggie. And chmod +x my_mutt so it is executable. Store it somewhere like /usr/local/bin.

#!/bin/bash
pwds=`gpg -d ~/.mutt/password.txt.gpg`
eval $pwds
mutt -F ~/.mutt/mutt_server "$@"

Second line decrypt the encrypted file, text of the file is stored in pwds variable and this text is executed by eval command. The environment variables are set. We invoke mutt in this shell so that it can access environment variables EE_USER, EE_PASS etc. On line 4, -F ~/.mutt/mutt_server says that this file is my config file which mutt must read. The default configuration file is ~/.muttrc.

In the configuration file, write something like this. You need to write some more to setup mutt. This is only fragment which is relevant to one account.

# ~/Scripts/mutt/ee
set from="$EE_NAME $EE_USER@ee.iitb.ac.in"
set hostname="imaps://sandesh.ee.iitb.ac.in"
set folder="imaps://sandesh.ee.iitb.ac.in"
set imap_user="$EE_USER"
set imap_pass="$EE_PASS"
set record="+mail/Sent"
set postponed="=Drafts"
set spoolfile="imaps://sandesh.ee.iitb.ac.in/INBOX"
set signature="sign.txt"
set smtp_url="smtp://$GPO_USER@smtp-auth.iitb.ac.in:25"
set stmp_pass="$GPO_PASS"
set realname="$REAL_NAME"
my_hdr Organization: EE, IIT Bombay, http://www.ee.iitb.ac.in

In my personal opinion, this is a good solution to store password on machine unless someone has a better solution which does not involve using a green lantern, nanobots or ability of code-bending.

Writing HTML emails

Mutt works great with text emails. But if you want to write emails for wncc group where code has to be written inline, html can help. See this question for potential solutions. I have also written mine.

Resources:

  1. Mutt wiki is a good reference guide.
  2. My first mutt
  3. And this terminal lover blog

Mail server info of National Center for Biological Sciences (NCBS) Bangalore

If you are a mutt user and working at NCBS Bangalore, you can setup your account in mutt as following.


set from="REAL_NAME "
set from="USER NAME "
set hostname="imaps://imap.ncbs.res.in"
set folder="imaps://imap.ncbs.res.in"
set record="+INBOX.Sent"
set imap_user="NCBS_USER"
set imap_pass="NCBS_PASS"
set postponed="=Drafts"
set spoolfile="+INBOX"
set signature="sign.txt"
set smtp_url="smtp://NCBS_USER@mail.ncbs.res.in" smtp_pass="$NCBS_PASS"
set realname="$REAL_NAME"

In short incoming server is imap.ncbs.res.in and outgoing server is mail.ncbs.res.in. Use default ports.

To get smtp server information, you can always use (in terminal)

msmtp -v --host=mail.ncbs.res.in --serverinfo --tls=on --tls-certcheck=off --port 25

Setup in BlueMail or other Android clients

For most clients, following settings should work.

IMG-20170811-WA0004

IMG-20170811-WA0003-1

Configuring mutt to display ‘attachment missing warning’

This method works if you are using vim as your editor. In file ~/.vim/ftplugin/mail.vim, write this function definition.

 
function! CheckAttach()
     let check='attach,angehängt,attachment,Anhang'
     let oldPos=getpos('.')
     let ans=1
     let val = join(split(escape(check,' \.+*'), ','),'\|')
     1
     if search('\%('.val.'\)','W')
       let ans=input("Attach file?: (leave empty to abbort): ", "", "file")
       while (ans != '')
               normal magg}-
               call append(line('.'), 'Attach: '.ans)
               redraw
           let ans=input("Attach another file?: (leave empty to abbort): ", 
", "file")
       endwhile
     endif
     exe ":write ". expand("<amatch>")
     call setpos('.', oldPos)
 endfu
 augroup script
     au!
     au BufWriteCmd,FileWriteCmd mutt* :call CheckAttach()
 augroup END

And in .muttrc, you should have something like this.

set editor = "vim -c 'set spell spelllang=en syntax=mail ft=mail enc=utf-8' '+/^$'"

Notice that we have ft=mail. This will automatically load the funtion.

Reference

1. http://www.mail-archive.com/mutt-users@mutt.org/msg37580.html

Or you can use this script.. Remove the above line from .vimrc.