Week 3 – LaboratoryUnderstanding k-Space
Week 3 Exercises: Understanding k-Space
This week's exercises will illustrate the principles of k-space, and how k-space images relate to real images.
Remember from the text and lecture that raw MRI data are collected as images in k-space, which then must be converted (or “reconstructed”) into real images. It is important to understand the key concepts of k-space for several reasons:
- First, the pulse sequences used for functional MRI differ in their sampling patterns in k-space. Echo-planar sequences traverse k-space in a line-by-line fashion, while spiral sequences adopt a whirlpool (i.e., spiral) motion. These different sampling patterns result in different advantages, disadvantages, and artifacts.
- Second, some imaging problems are associated with anomalies in the k-space data, which in turn result in stereotypical patterns of artifact in the real images.
- Third, and most importantly, the k-space representation of the data is integral to the signal reception process for MRI. Understanding k-space will provide a link between the basic physics principles underlying the generation of MR signal and the different pulse sequences used to create images.
This exercise uses two data sets: FUNC2 and FUNC3.Each of these data sets consists of a time series of images collected using a spiral gradient-echo pulse sequence at 1.5T. The images in Func2 have a matrix size of 64*64*14 and were collected with a TE of 40ms and a TR of 2000ms; voxel size was 3.75*3.75*5mm. The images in Func3 have a matrix size of 64*64*7 and were collected with a TE of 40ms and a TR of 2000ms; voxel size was 3.75*3.75*3.8mm. The experimental task is not relevant for today’s laboratory.
Exercise 1: Loading and Analyzing the data
1.1. Loading the MRI data
Load datasets FUNC2 and FUNC3 into MATLAB, as variables func2 and func3, respectively. Both are in the Examples subdirectory in the Class.01 directory in the “datasets” folder. Both datasets have BXH files already created for them, so you can load them directly using the readmrcommand. You need to change to the appropriate directory and then load Run1 of FUNC_2and Run2_Event of FUNC_3 into variables within MATLAB.
1.2. Identifying the problem
After viewing both sets of data, you should be able to determine which one is problematic based upon visual inspection. View each data set using showsrs2, examining the axial view most closely. Play each as a movie using the controls at bottom left.In one of the datasets, there is a recurring artifact.
Q1: Which dataset is normal and which is abnormal?
Q2: Write a description of the abnormality in the space below; what do you see that is strange looking?
** At this point, you should begin working on your own.**
** The TAs or instructor will be available for help as needed.**
Exercise 2: Quantifying the problem
2.1 Analyzing the Datasets
You should be able to navigate through both datsets using showsrs2to fill in the chart at the end of the laboratory. This should give you useful information for determining the properties of the abnormality exhibited in the “problem” dataset.
- For each dataset, select 2-3 voxels from different locations inside the brain and 2-3from outside the brain.
- For each voxel, you should be able to determine its coordinates and to estimate its minimum and maximum values (by looking at the data), the standard deviation, the run mean, and the standard deviation divided by the mean.
- DO NOT GET BOGGED DOWN IN THE MATH OR IN GETTING THE VALUES EXACTLY CORRECT. THIS IS A CONCEPTUAL EXERCISE.
To calculate standard deviation, mean, and standard deviation divided by mean for a single voxel across every timeslice, use the following commands. For the example below, we are calculating these values for the voxel at X=30, Y=31, Z=6:
std(func3.data(30,31,6,:))
mean(func3.data (30,31,6,:),4)
std(func3.data (30,31,6,:)) / mean(func3.data (30,31,6,:),4)
Note that the “,4” at the end of the mean command tells MATLAB to take the mean over the fourth dimension of your data; that is, across time.
Q3 – Q6 should be filled out on the answer key at the end of the laboratory.
Q7: How would you characterize the relative noise between the datasets? How large is the noise (i.e., the standard deviation) in the problem dataset relative to the typical BOLD signal change of about 1%?
Exercise 3: Understanding the Problem
3.1 Viewing the k-space data
Now that we have identified a problem in one of the data sets and quantified the magnitude of that problem, we are going to investigate its causesusing the concept of k-space. Add the class scripts directory to your path so that you can run the following examples:
addpath /afs/acpub/project/neurobio381/datasets/Class.01/Examples/Scripts
The first function that we will use is showkspace. This short custom script converts a raw image into a k-space image (Fourier space) and displays the output in MATLAB. Note that since reconstruction is done in 2D, it is not appropriate to view the k-space images in any view other than the acquisition plane (e.g., you should look at axially collected data only in the axial view).
We are going to look at the first 50 time points of each run. Note that three windows are created. The first is the raw data, the second is the k-space data, and the third is the mean deviation from normal k-space data. (Type help showkspacefor details.)
To run the script, execute the following command, replacing “temp.data” with the name of each dataset (e.g., “func2.data” or “func3.data”, if you used those naming conventions).
showkspace(temp.data(:,:,:,1:50))
Play around with the view in the second window. It is the k-space data.
Q8. In the second window (the k-space data), choose any slice in the middle of the brain. Play the run using the play controls in bottom left. What do you see in the middle of the screen?
Q9.Does the middle pattern from the previous question remain stable or change over time? Do the voxels on the perimeter remain stable or change over time? Can you explain why?
Q10. Is there anything different between the datasets, specifically in the third window (the difference of each image over time)?
To ensure a fair comparison between the datasets, you should set the min and max to the same values (e.g., -10,000 and +10,000) in each, by clicking on the “W+L” button.
3.2 Examining the effects of changes in k-space
We will now look at the effects of changing the k-space data upon the final images. In this section, you should gain a firmer grasp of how the relationship between the k-space data and the final images.
First, extract an arbitrary timepoint (i.e., number 10) from one of your data sets.
test = squeeze(func3.data(:,:,:,10));
Now, we will convert this data to k-space using mr2kspace. Note that this function does not rectify the data, so we will need to convert it to an absolute value. When we display it in ShowSrs2, we will use a logarithmic scale so that we can see detail.
k_test =mr2kspace(test);
ShowSrs2(20*log10(abs(k_test)))
To change a value in k_space, use the changevoxel function. This is a short function created for this laboratory that changes both a voxel and its reflection around the center of k-space. To see more information, type help changevoxel . When changing values, change to very large numbers like 500,000. Small changes may not be visible. Such very high values, which reflect energy spikes in the radiofrequency coils, are known as “white pixels”.
The sequence of commands below makes changes in the k-space data for all slices in the brain at voxels (30,40) and (36,26), and then reconstructs the image data from the k-space data.
k_test =mr2kspace(test);
k_new=changevoxel(k_test,30,40,[1:size(k_test,3)],500000);
new_test=kspace2mr(k_new);
ShowSrs2(abs(new_test));
Note that the code [1:size(k_test,3)] indicates to MATLAB to make the same changes on all slices from 1 to the maximum slice in the data; to get the maximum slice, it looks at the size of the third dimension of the k_test data.
Q11: Now, you can test the effects of "white pixels" at different locations in the k-space image.Plot what happens at different locations on the figure at the end of the laboratory. Choose at least 7 locations.
Final challenge
You now know what a white pixel in k-space (i.e., a electrical spike in the radiofrequency coil)causes to happen in the functional data. Load in the problem dataset into MATLAB, and display it (not the k-space data) in ShowSrs2. Find some problem images with large artifacts.
Q12: From your map in Exercise 3, can you predict where the "white pixel" artifacts will be located?
Q13: How accurate are your predictions? [When you attempt this, tell the instructor/TAbeforehand.]
Summary of Exercises
Q1: Which dataset is normal and which is abnormal?
Q2: Write a description of the abnormality in the space below; what do you see that is strange looking?
Q3:Problem Dataset In-Brain Points
XYZMinimumMaximumStd. Dev.Mean SD/M
______
______
______
Q4:Problem Dataset Out-of-Brain Points
XYZMinimumMaximumStd. Dev.Mean SD/M
______
______
______
Q5:Non-Problem Dataset In-Brain Points
XYZMinimumMaximumStd. Dev.Mean SD/M
______
______
______
Q6:Non-Problem Dataset Out-of-Brain Points
XYZMinimumMaximumStd. Dev.Mean SD/M
______
______
______
Q7: How would you characterize the relative noise between the datasets? How large is the noise (i.e., the standard deviation) in the problem dataset relative to the typical BOLD signal change of about 1%?
Q8. In the second window (the k-space data), choose any slice in the middle of the brain. Play the run using the play controls in bottom left. What do you see in the middle of the screen?
Q9. Does the middle pattern from the previous question remain stable or change over time? Do the voxels on the perimeter remain stable or change over time? Can you explain why?
Q10. Is there anything different between the datasets, specifically in the third window (the difference of each image over time)?
To ensure a fair comparison between the datasets, you should set the min and max to the same values (e.g., -10,000 and +10,000) in each, by clicking on the “W+L” button.
Q11: Now, you can test the effects of "white pixels" at different locations in the k-space image.Plot what happens at different locations on the figure at the end of the laboratory. Choose at least 7 locations.
Q12: From your map in Exercise 3, can you predict where the "white pixel" artifacts will be located?
Q13: How accurate are your predictions? [When you attempt this, tell the instructor/TAbeforehand.]
p. 1 of 8