So, I have written the extra ANTsR package,
because I wanted to interface some of the ANTsR functionality
with tying it into some of the oro.nifti functionality, right.
So for the majority of the lectures, we've spoken about nifty objects in R,
implementing oro.nifti package,
and that's the main container for images I kind of use a lot.
So I wanted the ANTsR functionality to be able to work on these types of images.
So, I wrote a simple wrapper for the N3 bias correction and
the N4 bias correction.
Those are two functions in the ANTsR package.
And they're wrapped into a very simple function called bias_correct.
Right now the, again if you don't have the extra ANTsR package downloaded or
loaded up, you can install that through GitHub with
muschellij2, muschellij2/extrantsr.
And there's no double A, it's extrantsr or something like that.
I don't know exactly the name yet.
But the idea is you can use the bias_correct function.
And you can pass in either a final name or a nifti object, and then you just tell
what type of correction you would like to do, either using N4 or N3.
In general, we recommend using N4.
It is a very similar algorithm to the N3 algorithm that came around with sleds.
That's his last name, his dissertation.
And the N4 improves on that with respect to convergence property,
some speed, and just some problems that had occurred in
the N3 that they've tried to smooth out, no pun intended.
So, the function here, right, we pass in a nifti object, in this case nim.
There are a lot of instances where we previously discussed how to read in
a nifti object.
And on the left-hand side we just assigned it to a new object.
So on the left-hand side would be the bias corrected image for the N4 and the N3.
In this case we use the brainex data, the T1 image.
And on the left-hand side is the original image.
The original T1 from the brainex data on the right-hand side,
it's the N4 corrected Image.
Now, it's very hard to see any differences here.
Especially because when you do the plotting with the orthographic,
even though you might do an inhomogeneity correction,
if you don't keep the scales exactly the same, it can be hard to see.
So we wanted to just show you we took a difference between the images and
mapped those to some colors.
And you can see the color bar on the right-hand side of the image showing
where there are differences in the image between the original image and
the N4 corrected image.
So we took the original image, subtracted off the N4 image,
and we overlaid that with a color scheme here to
show you that there are differences in the top right-hand corner.
If you look at the axial sliced in the bottom left corner of the entire image,
you can see it's blue indicating that it was lower in the bias field correction.
Whereas, if you do the original minus the bias field,
that is negative which means the bias field corrected is higher.
And the red means the original image was higher so
just kind of visualize how the bias field correction did.
And the big things that we also implemented is, although there's
a function called antsRegistration in ANTsR package, and it's very good.
Just we wanted to add some additional functionality on top of that interface,
especially again to allow for oro.nifti nifti objects to be passed in.
So we wrote on the extrantsr package the ants_regwrite.
So this will allow you to do a registration.