Gaussian smoothing filtering of 4D data

18 visualizaciones (últimos 30 días)
Gina Carts
Gina Carts el 10 de Jun. de 2019
Respondida: Matt J el 10 de Jun. de 2019
Hi,
I have 4D MRI data (Magnetic Resonace Imaging). Where dimensions are: x-, y-, z- dimension and time.
I would like to smooth my data with Gaussian filter.
Does anyone know if Matlab has a function to smooth 4D or 3D data?
Is imgaussfilt what I need? Can I use this function in 4D Nifty format images?

Respuestas (2)

Matt J
Matt J el 10 de Jun. de 2019
Editada: Matt J el 10 de Jun. de 2019
imgaussfilt is for 2D only, but it wouldn't be too hard to implement your own 4D separable Gaussian filter just by using my KronProd class,
%% Fake 4D image data
N=100;
Image=rand(N,N,N,N,'single');
%% Construct 1D convolution matrix
sigma=2;
t=linspace(-3*sigma,3*sigma,21);
k=exp(-t.^2/2/sigma); %1D Gaussian kernel
A=conv2(eye(N),k.','same'); % convolution matrix
%% Perform filtering
tic;
filteredImage=KronProd({A,A,A,A})*Image;
toc;
%Elapsed time is 2.844996 seconds.
Above, I've kept things simple by assuming the image is NxNxNxN. In the less simplified case when your image has different dimensions, or you want to apply different sigma along different dimensions, you would need to derive different convolution matrices appropriate to each dimension, following the same general procedure above.
filteredImage=KronProd({A4,A3,A2,A1})*Image;

Matt J
Matt J el 10 de Jun. de 2019
Does anyone know if Matlab has a function to smooth 4D or 3D data?
For 3D data there is imgaussfilt3 (introduced in R2015a).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by