Difference between revisions of "User talk:Andy"

From KitwarePublic
Jump to: navigation, search
(Looking for kw_include_file extension info)
(Looking for kw_include_file extension info)
Line 308: Line 308:
  for i in *.h.bak; do mv $i `basename $i h.bak`h; done
  for i in *.h.bak; do mv $i `basename $i h.bak`h; done
==Looking for kw_include_file extension info==
Sorry to be bothering you but I posted a question at [[User:Barre/MediaWiki/Extensions/kw_include_file]]  quite a while ago and have not had any response.  Is Barre still around?  --[[User:Ikester|Ikester]] 22:10, 12 Sep 2005 (EDT)

Revision as of 16:06, 10 February 2006

VIM is a great editor

Ok, so I use VIM. I used to use Emacs, but I guess the starting time was bothering me. Also, for small sysadmin edits I used VIM already and I was mixing key strokes from Emacs and VIM.

My VIM Settings

set nocompatible " We use a vim
set noautoindent
set tabstop=2       " Tabs are two characters
set shiftwidth=2    " Indents are two charactes too
set expandtab       " Do not use tabs

syntax on           " Turn on syntax hilighting

set hlsearch        " Hilight the search results
set incsearch       " Incrementally search. Like Emacs

set autochdir       " Automatically chdir to directory of the buffer
set matchpairs+=<:>
"set matchpairs+=<:> 
set showmatch
set laststatus=2
set guioptions-=T
set guioptions-=m
set guioptions+=f
"set guifont=Fixed\ 11
"set guifont=Fixed\ 11
set viminfo+=n$HOME/.vim/viminfo
"set guifont=-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*
"set guifont=Andale\ Mono\ 8

colorscheme darkblue

amenu F&ont.&5x7            :set guifont=5x7<CR><C-L>
amenu F&ont.&6x10           :set guifont=6x10<CR><C-L>
amenu F&ont.6x13            :set guifont=6x13<CR><C-L>
amenu F&ont.&7x13           :set guifont=7x13<CR><C-L>
amenu F&ont.&8x13           :set guifont=8x13<CR><C-L>
amenu F&ont.&9x15           :set guifont=9x15<CR><C-L>
amenu F&ont.&10x20          :set guifont=10x20<CR><C-L>
amenu F&ont.&12x24          :set guifont=12x24<CR><C-L>
amenu F&ont.&heabfix        :set guifont=-*-haebfix-medium-r-normal-*-15-*-*-*-*-*-*-*<CR><C-L>
amenu F&ont.&lucida         :set guifont=-*-lucidatypewriter-medium-r-*-*-14-*-*-*-*-*-*-*<CR><C-L>

if exists("loaded_vimspell")
  set spell_auto_type="tex,mail,text,html,sgml,otl"

set wildmode=longest " Make tabcompletion behave correctly
set selection=exclusive "  Only select up to not including last character
set ignorecase " Ignore case when searching lowercase
set smartcase " Ignore case when searching lowercase

set cinoptions={1s,:0,l1,g0,c0,(0,(s,m1
highlight SpellErrors guibg=Red guifg=Black
:autocmd BufRead,BufNewFile [Mm]akefile :set noexpandtab
highlight SpellErrors  guibg=Red guifg=Black

Random things that need to be put somewhere

Random Python Tricks

How do I get a current line number or file name from the scrip?

import inspect

f = inspect.currentframe()
print "Line number: %d" % f.f_lineno
print "File name: %s" % f.f_code.co_filename

Also, you can go up the stack and do the same thing:

lineno = inspect.currentframe().f_back.f_lineno

CVS branch control

Note: this script accesses the Entries file directly, it has already pointed out that it should be upgraded to use the cvs status command to be independent of Entries file format changes in the future.


# This variable contains the list of branches to lock - update this list as per
# your requirement

# This variable contains the email-ids of people to bug if the checkin fails
# You would probably want to list the ids of the Release Engineers and the CVS admins

ErrorExit () {
   echo " "
   echo "! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !WARNING ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! "
   echo "! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !COMMIT FAILED ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! "
   echo " "
   echo "${Branch} is closed for commits"
   echo "Please contact $people_to_bug"
   echo " "
   echo "! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !COMMIT FAILED ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! "
   echo " "
   exit 1

# this script would get two argument - full path to the
# directory where you are doing the checkin and the file you are checking in

# This makes $1 point to the file I am checking in

for user in $allow_users
  [ "x$CVS_USER" = "x$user" ] && exit 0

# Grab the last field - that contains the branch name
Branch=`grep "^/$1/" CVS/Entries | awk -F/ '{print $NF}' | cut -c2-`

if [[ ${Branch} != "" ]]
        for locked_branch in $locked_branches
            echo ${Branch} | grep -q $locked_branch && ErrorExit ${Branch}

ITK Filter

The first ITK filter you may want to look at is the UnaryFunctorImageFilter.


It is in


This filter takes one image as input and produces another image as output. The processing is done pixel by pixel, meaning that the pixel at the output is computed only from the corresponding (i,j) pixel in the input.

The filter uses the input and output images types as template parameters, and a third template parameter is a "Functor" class that indicates what operation must be performed in the input pixel in order to compute the output pixel.

The functor is usually written in about 10 lines of code, and with them you can instantiate a specialization of the UnaryFunctorFilter.

An example on how to instantiate this filter is in the Sinus Image Filter, ( a filter that computes

           OutputPixel = sin( InputPixel)


The code is in


In 30 lines of code, it implements the full filter by deriving from an instantiation of the Unary Functor filter.


  Create a pixel wise filter that will set to 0 all the
  pixels of an image with values below 100.


    Do not look at the BinaryThresholdImageFilter.


The second filter you want to look at is the BinaryFunctorImageFilter. http://www.itk.org/Insight/Doxygen/html/classitk_1_1BinaryFunctorImageFilter.html

This filter is very similar to the UnaryFunctorImageFilter of Lesson 1, but it accepts two input images and produces one output image. The Functor mechanism is also used here, so a new filter is created by first writing its corresponding Functor that tells how to compute the output pixel value from the pixel values of the two input image pixels.

    OuputValue = Functor(  InputPixelA , InputPixelB )

For an example of an instantiation of this filter you can look at the AddImageFilter


The code is in



   Create a MaskImageFilter using the BinaryFunctorImageFilter


   Do not look at the MaskImageFilter


You can now look a the neighborhood filters. Those are filters that compute the output pixel value based on a neighborhood of the input pixel value.

The value is computed by applying an "Operator" to the input neighborhood. The basic filter for this purpose is the NeighborhoodOperatorImageFilter http://www.itk.org/Insight/Doxygen/html/classitk_1_1NeighborhoodOperatorImageFilter.html

This filter is used internally in the DerivativeImageFilter http://www.itk.org/Insight/Doxygen/html/classitk_1_1DerivativeImageFilter.html

Note that it is instantiated internally and used for delegating the computation of the output image.

Very close to this filter is the MeanImageFilter http://www.itk.org/Insight/Doxygen/html/classitk_1_1MeanImageFilter.html

It is a good filter to look at the use of the Neighborhood iterators.


   Write a filter that computes the value of the output pixel
   by voting among the input pixels. The votes are for value 0
   if the input pixel in the neigborhood is < a threshod, and
   the votes will be for 255 if the input pixel in the neighborhood
   is >= (the same threshold).


   Don't look at the BinaryMedianImageFilter


The Insight Consortium declines any reponsability for stimulating your addiction to coffee.

Playing with math

\sum _{{n=0}}^{\infty }\partial {Z}{\frac  {x^{n}}{n!}}\int _{{x_{0}}}^{{x_{n}}}\cos {\theta /2}

Modify string in a bunch of files

For instance, replace the word windows by linux in all text files:

perl -i.bak -pe 's/windows/linux/g' *.txt

Once you checked that everything is OK, you can remove the .txt.bak files

Note: it is not recursive

perl -i.bak -pe 's/windows/linux/g' `find ./ -type f -name "*.txt"`

To restore the files:

for i in *.php3; do mv $i `basename $i php3`php; done
for i in *.h.bak; do mv $i `basename $i h.bak`h; done