Am new to matlab and am trying to write a code that converts CT lung DICOM images to Hounsfield Units(HU). I've already created a function to do so and saved it in an M-file. I would like to know how can i apply this function to a series of dicom images altogether (each patient folder contains around 200 images and there are multiple folders!) or how to apply a function to a series of dicom images in general. thanks in advance! Here's the function:
function [z,y] = med (i)
z = dicominfo(i);
x = dicomread(z);
if isa(x,'int16')
y = x * z.RescaleSlope + z.RescaleIntercept;
else
a = int16(x);
y = a * z.RescaleSlope + z.RescaleIntercept;
end