230 likes | 457 Views
Matlab course - Program. Today Basic matrix operations Basic visualization. Images and plots Thursday Programming, scripts, more visualization Friday Graphical user interfaces and advanced visualizaton Any suggestions wellcome, only today is fairly set. Matlab course - introduction.
E N D
Matlab course - Program • Today • Basic matrix operations • Basic visualization. Images and plots • Thursday • Programming, scripts, more visualization • Friday • Graphical user interfaces and advanced visualizaton • Any suggestions wellcome, only today is fairly set
Matlab course - introduction • Goals • Visualize data • Develop programs • GUIs • Read other peoples programs (eg. SPM) • Hands on
Matlab as a language • Vector/matrix based • Many built in functions • Few lines of code will get you far • Extensive visualization capabilities • Might run slower depending on task
Lets start • Manipulating matrices and vectors • Basically needed for all programming tasks everything • Basic operations • Add noise to a simulated signal – an example (hemodynamic response function)
Plotting data • The plot function • plot(y) • plot(x,y) • X and Y can be matrices • plot() will plot the columns • Use hold on to keep the old plot
Simulating the HRF Buxton: Introduction to FMRI hrtvectortor = hrt(timevector, tau, t0, n)
Excercise • Part 1 • Generate a timevector, L=10 s, interval=0.1 s • Use the hrf() function to generate a hemodynamic response • Use plot to verify the output • Part 2 • Imagine that you want to display 3 different hrf functions in a plot. Generate 3 functions and put them in a matrix columnwise. Use a single call to plot to view them • Part 3 • Use randn() to add noise to the curves. Use a std of XX • Plot again Example hrf parameters: timevec: from 0 to 20 secs tau: 1.2 t0: 4 s n: 3 Example noise parameters: Use a std of 0.1 – 0.3 - 0.5
Imagescaling Min value Max value Full range Partial range
imagesc() + colorbar imagesc(data) imagesc(data,[0 5000])
Loading a dicom file • Matrix=dicomread(’filename’); • Matrix=double(Matrix); • imagesc(Matrix)
Logical comparisons • Largevalues=matrix > 500 • Can be true or false, 0 or 1
Exercise • Load a dicom into a matrix • Use hist()( to identify noise and see if there is ghosting using imagesc() • ’Cut away’ the noise • Hint: use a comparison to make a noise mask and then .* • Use roipoly to mask away 1 hemisphere
Exercise • Use mean() to get a mean of an ROI selected using roipoly • Plot a histogram of your ROI
Saving work • save workspacename • save filename X saves only X. • Save filenename X Y Z saves X, Y, and Z.
The online docs • Very usefull • Good links • Good newsgroup • Tomorrow: structures – the dir command