[SOUND] >> Okay, so you have already seen. Elizabeth and John have shown you a lot of ways to access to data, to transform it, to look at different transformations. So by now you should have a really good feel about what data look like, what to expect, and how to transform it. I will talk about, in this lecture, more about intensive transformations and relative intensive transformations and also smoothing. These are two fundamental transformations. Two fundamental ways of dealing with the data for better presentation and visualization and exploration of the data. So this is what we'll be covering in this lecture. We'll talk about transformations. And this is the first part, and we'll also talk about smoothing. So what are transformations? You probably remember from the intensities, from the grayscale images that you have seen, that there is a particular gradient in the images. You see a particular image. Well, that is an artifact of the way the intensities are shown relative to each other. You can actually change that and this is what transformation are. So you can take the image and transform the intensities. And transform the intensities relative to each other so that you actually see a different image. This is a fundamental way to look and change the contrast, adjust the contrast into an image. And we will learn how to do that. And, we will see how these transformations allow to change the intensity of the dark, the black, the white, and the gray in the image, such that you actually get different types of images. Even though the data has not changed at all. So let's have a look at the same histograms that you have seen before, shown by Elizabeth and by John. You have the r code as usual. That r code is very similar to what you had before. And the only difference is here, that, that white scale is actually, it's the log skill. So the intensities values are shown on the x axis and you see that the intensities as they are shown. And what we would like to do is to take these intensities and actually transform them in a way that we actually have a different type of image. One type of transformation is actually the linear transformation. So here you see the same histogram as on the previous slides, with a red line. And that is the linear transfer function. So what that does, it takes the the intensities values which are on the x axis, it'll transform them on the y axis to the right. And this is done in a linear way. So this is not changing too much the relative intensities of the image. So once you plug these things you actually don't get to see much of it. However, you can do a lot more than that. You can actually define a transfer function which takes the original intensities values, the ones that you have seen here on the x axis, and transforms them differentially, AKA nonlinearly into another function. So here you are given the r code. The r code seems quite involved but what it really does is just defines a linear spline. A linear spline is nothing else but a line that is broken in several places. In this case, is broken in two places. These places are called knots. And they're defined on the bottom of the slide. For example the knot values are 0.3 and 0.6, they are defined between on a normalized scale between 0 and 1. And also the lines in-between these knots have different slopes. For example 1, which is the same thing as 45 degree line, 0.5 and 0.25 which essentially is what you'll see on the next slide right here. So you have the same histogram in the bottom of the slide, and you see the transfer function, the red spline. So you see that there are two knots, as I was saying earlier, so you define the knots at 0.3 and 0.6. You see where the lines is being broken, and the slopes, the first part of the slope, which is the 45 degree line, and then the slope is actually getting shallower and shallower as you move through the slide. You also have the r codes that should help you to reproduce these plots. And it also shows you how to plot the curve using the function curve on the Intensity Values that range that you have in this particular image. So I'm not going to go through every detail but you can copy and paste the codes directly into your R command line. Which the easiest thing that I find. And just see whether you can reproduce these images and work from there. The interesting thing to remember is that, in this case for example I'm using the curve, which is linear spline. But you can use actually any other function. If you have your own transfer function, you can replace the linear spline with something else which will transform intensities in a different way. So the only thing that you have to do is, on this slide where you define the linear spline function, just define a different type of function, any type of function. And then you can apply it to the same image here, and then you will get a different curve. You can then go ahead and actually look at what these images look like before and after you do the transformation. And this is what you see here. On the left image is actually before transformation, and the right image is after transformation. So you took the original image intensities and you applied a spline with two knots to the intensity values. And then what you obtain is on the right, which arguably, may actually be, may look better than the left side. Of course we don't know what will look better before we make a transformation. So it's actually good to try several different types of transformations and understand which one of these transformations highlights the particular important feature of the image. In some situations, especially when you deal with pathology, you may be interested in finding those transformation that highlighted the particular pathology. That may be useful for segmentation, or it may be useful for visualization, or for other future studies. In this case, we were lucky to get an image that seems to indicate better contrast between white and grey matter. But as a general idea, I thinks it's important to remember that you can make any type of transformation you like. And also you actually have a lot of control over the type of transformation that you apply. In R, the nice thing is that by defining the knots as here and the slopes of an office spline. You actually have a lot of control or exactly what the transfer function is. Not only do you make a transformation of an image as in other software, but you actually, you have a lot of control over that particular function. You know exactly what the function is, and you can reproduce it. You can show the same function on a different image. And maybe the same transformation works on a different image, or it doesn't. And this is part of the neurohacking that we were talking about. The fact that having control over the data, having control over the transformation, having control over every single part of the data transformation visualization is part of what they define to be neurohacking. So, here are a few more notes about the transfer function. So as you have probably noticed, I use knot values that are 0.3 and 0.6. However, the intensities of the images were actually in the tens of millions. So one has actually to renormalize the know values to 01 just because it makes things easier. It's easier to think about this is the range of intensities and normalized to 01 and then apply it repeatedly using the same kind of numbers. This is especially useful because MRI images do not have particular units. So they may actually scale quite up differently. In certain situations you may have intensities that have done things in the millions and you have situations that can be in the thousands. So having normalization between minimum and maximum is quite useful for this presentation. This is not what we recommend for intensity normality, normal intensity normalization, but it is what we recommend in this part of our case just because it's a simple transfer function. The transfer function can actually be any function and with here we showed monotonic functions, both the linear and the spline transfer functions were monotonic. In other words, a shade of gray just becomes another shade of gray. But what was white before and to gray is still the same. So in other words, what used to be whiter stays whiter, what used to be darker stays darker. Even though the relative intensities may change. However, you may also apply transformations that are non-linear, or even non-monotonic, and I haven't seen that done a lot, but it's something that may actually find its uses in various types of application. The transfer function is widely used in imaging, and it's used for better visualization. We still do not understand what means better visualization. We are thinking about what different people will perceive as being a better image. Typically, we tend to agree. If we are shown a better image, most people will agree this is a better image. For example, for differentiation between white matter and grey matter, or for finding pathologists. However, it is still not clear that most people will agree on every single image. Sometimes, you may have a better image that is perceived as a worse image by somebody else. So this is why it's good to have different types of transfer function, how it continues transfer functions. Sometimes transformations can be better for prediction, for segmentation. Of course, you cannot know that before you actually do this transformation, you make this transformation. So it's a good idea to try several different types of transformations and apply downstream algorithms to them and see whether they actually improve the pipeline or not. So there is a lot of flexibility here in terms of what can be done in terms of transfer functions. And I just showed, a couple of functions, but there are many, many others, that can be done. In terms of smoothing, smoothing can also be done in r, and one way of doing this though it is not particularly fast, though we like it. It's AnalyzeFMRI, and this is using the GaussSmoothArray. So I'll show you one way of doing smoothing. And there are other ways, but this is one way of doing it. So this is smoothing using Analyze FMRI. So, this is the function of GaussSmoothArray. The input here is the T1 image and the kernel size was 11. Of course, one can play with the kernel size or can play with sigma which is a measure of the kernel, of how symmetric the kernel is and how correlated it is. And what you see on the bottom plot of this slide is actually a smooth image of that particular T1 image. So what this achieves, in images that are noisier, it actually reduces the amount of noise. But at the same time, if the smoothing is too aggressive, then it could actually make the image too smooth and lose too much of the information. So smoothers of different resolutions of the different types are, again, used extensively in the literature. So for example, a typical thing would be to do three or four different type of smoothers, change the kernel size, do one with kernel size five. Another one of size 10, and another one of size 20, and just look at the images and just see which one of the images makes sense and how they can be used for future analysis. Again just like the transformations that can be extensively used for visualization, that can also be used for segmentation or as inputs for various other software.