Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Week 2: An Introduction to Tcl Xenios Papademetris

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Programming Using Tcl/Tk These slides are based upon u several Tcl/Tk text books u material byDr. Ernest J. Friedman-Hill.
Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Xenios Papademetris BML 325,
Writing Tcl Scripts (cont.) Outline –Variable Scoping –Strings –Eval –File/Channel I/O –Processes –System Info –Errors –Reflection/Debugging –Libraries.
Introduction to Tcl and Tk Outline –The Tcl Language –The Tk Toolkit –Tk Applications –Composing Applications –Status and Conclusions Goal –Understand.
Information Technology Center Hany Abdelwahab Computer Specialist.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Writing Tcl Scripts Outline Goal Reading Syntax Data Types
Guide To UNIX Using Linux Third Edition
Russell Taylor Lecturer in Computing & Business Studies.
1 Outline 7.1 Introduction 7.2 Implementing a Time Abstract Data Type with a Class 7.3 Special Attributes 7.4Controlling Access to Attributes 7.4.1Get.
1 ParaView Current Architecture and History Current Architecture and History Issues with the Current Design Issues with the Current Design.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
An Overview of Tcl and Tk John Ousterhout Sun Microsystems Laboratories Tcl/Tk Tutorial, Part I.
Xenios Papademetris Departments of Diagnostic Radiology and Biomedical Engineering Yale University School of Medicine.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
CS110/CS119 Introduction to Computing (Java)
Sikuli Ivailo Dinkov QA Engineer PhoneX Team Telerik QA Academy.
Innovation Intelligence ® 1 Chapter 1: Introduction to TCL.
INTERNET APPLICATION DEVELOPMENT For More visit:
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
November 15, 2005ICP: Chapter 7: Files and Exceptions 1 Introduction to Computer Programming Chapter 7: Files and Exceptions Michael Scherger Department.
JavaScript Part 1.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
CHAPTER FOUR COMPUTER SOFTWARE.
Tcl/Tk package in R Yichen Qin
1 Python CIS*2450 Advanced Programming Concepts Material for this lecture was developed by Dr. D. Calvert.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Computer Programming 12 Mr. Jean March 19 th, 2013.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
BLU-ICE and the Distributed Control System Constraints for Software Development Strategies Timothy M. McPhillips Stanford Synchrotron Radiation Laboratory.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Tcl/TK Tutorial. 2 Learning Tcl/TK What is Tcl/TK? –An interpreted programming language Build on-the-fly commands, procedures Platform-independent Easy.
Agenda Getting Started: Using Unix Unix Structure / Features Elements of the Unix Philosophy Unix Command Structure Command Line Editing Online Unix Command.
Tool for Automation and Testing
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Introduction to Perl Yupu Liang cbio at MSKCC
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
9-Nov-97Tri-Ada '971 TASH An Alternative to the Windows API TRI-Ada ‘97 Terry J. Westley
TCL TK. Tcl/Tk C functions can become Tcl commands that are invoked interactively Tk = scriptable, portable user interface –Windows, X (Unix), MacOS,
Introduction to Tcl/Tk TraNese Christy U.S. Army Research Laboratory.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Innovation Intelligence ® 1 Chapter 4: Using TCL to Control the HyperMesh Session.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 4 JavaScript.
 Stands for Tool Command Language  Used for rapid prototyping, GUIs, and scripted applications  Created by John Ousterhout in 1988 out of frustration.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Scripting.
The Scripting Programming Language
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
CIS 365: Visual Application Development Introduction to Computers and Programming.
An Introduction To Tcl Scripting John Ousterhout Sun Microsystems Laboratories Tcl/Tk Tutorial, Part II.
Perl & TCL Vijay Subramanian, Modified from : perl_basics_06.ppt.
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
TCL/TK Tool Command Language/Tool Kit.
CSE 303 Concepts and Tools for Software Development
LING 408/508: Computational Techniques for Linguists
Introduction to JavaScript
Web Application Development Using PHP
Presentation transcript:

Programming for Image Processing/Analysis and Visualization using The Visualization Toolkit Week 2: An Introduction to Tcl Xenios Papademetris BML 325, Man Pages etc: (See also lectures on Programming Using Tcl/Tk by Dr. Ernest J. Friedman-Hill

Schedule – Part 1 1.Introduce VTK (today) 2.Introduce Tcl/Tk 3.Simple Visualization Tasks 4.Simple Image/Surface Manipulation 5.More on Images and Volume Rendering 6.Local Extensions (Marcel: Itcl/Itk/Iwidgets, more advanced GUI generation etc.)

Schedule – Part 2 1.C++ Fundamentals, Pointers/Classes 2.Object Oriented Programming 3.Adding new VTK Commands/Cmake 4.More on Images and Surfaces 5.Case Study I – Computing t-maps in fMRI 6.Case Study II -- Iterative Closest Point surface matching 7.Case Study III – Linear Mutual Information Multimodal Registration

Scripting Language Philosophy Program size, complexity, reuse 1  Large, complex applications: Performance important. Need structure. Goal: prevent bad things. Interactive commands, scripting: Performance less important. Minimum structure: less overhead, easy interchange. Goal: enable good things. Can one language meet all needs?

Two Language Approach Program size, complexity, reuse 1  Use Tcl for scripting, C or C++ for large things. Goals for Tcl: 1. Minimal syntax: easy to learn and type. 2. Minimal structure: make things play together. 3. Simple interfaces to C/C++: extensibility. This is the Key Feature for us! CTcl

Multi-Platform Program Structure Hardware Layer (Windows/Linux/Unix/Mac OS X) Computational Aspects 3D Graphics Graphical User Interface (GUI) Our own C++ Code Open GL VTK Tcl / Tk (or Python/Tk or Java) Our own Tcl/Tk Code (or Python, Java)

Intepreters 1.Tclsh ( tclsh8.3 ) – no graphical user interfaces, base tcl language only. 2.Wish ( wish8.3 ) – tcl and graphical user interface stuff (tk) 3.Vtk ( vtk ) – wish and vtk extensions 4.Pxvtk ( pxvtk ) – vtk and local extensions written here at Yale On SGI/Linux before starting type: source /usr/local/vtk4/setvtk To set the proper paths, tested on cortex/retina/pelvis/edema/ventricle/fimbria/suture/derwent and machines in MRI group

Key Tool: TclTutor

Tcl By Example Variables (Essentially Strings) % set foo % set bar "Hello" Hello % puts stderr "$foo $bar" 10 Hello % set temp hello$foo hello10 % set temp foo foo

Flow control for { set i 0 } { $i < 10 } { incr i 1 } { puts stdout $i } set i 0 while { $i < 10 } { puts stdout “i=$i” incr i 2 } Tcl By Example if { $i < 10 } { set j 0 } else { incr i }

Procedures set var 10 proc procedure { a } { global var puts stderr "Entering procedure" set val [expr $a * $var] return $val } set val [procedure 3] [ ] is the operator for returning the result of something i.e. [ procedure 3 ] is the output of calling procedure with an argument of 3 Tcl By Example

Math Operations All math operations need expr command This is not valid as by default everything is a string! % set i % set i [ expr 2+2 ] 4 expr parses the operation numerically i.e. not as a string!

Lists Complex Variable Structure Lists are everywhere in Tcl! Create a list % set l [ list 1 2 3] Get an Element of the List (First Element has index 0) % set a [ lindex $l 1 ] 2 Get the Length of the List % set a [ llength $l ] 3 Other Commands lappend,lsort,linsert etc

Strings Every variable is implictly a string Strings can be manipulated using the string command % set l [ string length ”Hello”] 5 % string range "Hello" 2 4 llo % string index "Hello" 1 e Lots of other options ….

Associative Arrays Another Complex Variable Structure Create an array (implicitly) % set a(1) ”Hello” % set a(2) ”Help” % puts stdout ”$a(1), $a(2)” Hello, Help Modify array using array command

Calling Other Programs The exec command can be used to call other programs i.e. exec emacs or exec notepad or set f1 “inputimage.hdr” set f2 “outputimage.hdr” puts stdout “Executing myprogram to filter $f1 to $f2” exec myprogram $f1 $f2 puts stdout “myprogram done!” … code to display $f2

Text File I/O Standard Unix Files stderr/stdout New Files using open command set fileid [open "/winnt/temp/testfile" w] puts $fielid “This is the first line” puts $fielid “This is the second line” close $fileid Or set fileid [open "/winnt/temp/testfile" r] gets $fielid $firstline gets $fileid $secondline puts $stdout “Read\n $firstline \n $secondline” close $fileid

File/Filename Manipulation The file command set fname “/home/papad/vtkpxcontrib/CMakeLists.txt” set a [ file extension $fname ].txt % set a [ file rootname $fname ] /home/papad/vtkpxcontrib/CMakeLists % set a [ file tail $fname ] CMakeLists.txt % set a [ file dirname $fname ] /home/papad/vtkpxcontrib % set a [ file size $fname ] 1024 Options for copying, deleting, moving files/directories etc

User Interfaces Using Tk The problem: –Too hard to build applications with nice user interfaces. –Even harder to do so cross-platform The wrong solution: –C++, object-oriented toolkits, Java’s AWT –Only small improvement (10-20%?): must still program at a low level. The right solution: –Raise the level of programming. –Create interfaces by writing Tcl scripts.

User Interfaces Using Tk II Additional Tcl commands: –Create Motif-like widgets (on all platforms) –Arrange widgets. –Bind events to Tcl commands. –Manipulate selection, focus, window manager, etc. There exist bindings to Tk from other languages such as Python and Perl, Tcl is however the native language of Tk

User Interfaces Using Tk II Create user interfaces by writing Tcl scripts. Hello, world: button.hello -text "Hello, world" -command exit pack.hello Simple directory browser: 30 lines Web browser: 2000 lines 10x less code for simple things.

A Complex Example Load and Display a 3D Image (pxvtk) vtkpxAnalyzeImageSource ana ana Load brn_1031.hdr vtkpxGUIOrthogonalViewer ortho ortho Initialize. 1 ortho SetImage [ ana GetOutput ] [ ana GetOrientation]