enhancement - converted script into function, some non-significant changes


git-svn-id: svn+ssh://svn.fcdonders.nl/home/svnroot/fieldtrip/trunk@10023 0cf7c7f0-3615-4144-b4e6-68da3bce3cd0