Home > fmri > utils > norm_intensity.m

norm_intensity

PURPOSE ^

[nV] = norm_intensity(V);

SYNOPSIS ^

function [nV] = norm_intensity(V)

DESCRIPTION ^

 [nV] = norm_intensity(V);

 Normalizes intensity of each image volume in a series of image volumes

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [nV] = norm_intensity(V)
0002 % [nV] = norm_intensity(V);
0003 %
0004 % Normalizes intensity of each image volume in a series of image volumes
0005 %
0006 
0007 % 05/18/00 PJ
0008 
0009 thresh_pct = 0.4;
0010 
0011 %
0012 %  Set a threshold for the brain mask to use in the intensity normalization
0013 %
0014 
0015 dims = size(V);
0016 rV = reshape(V,prod(dims(1:3)),dims(4));
0017 
0018 % Get the mean intensity of each image volume
0019 mi = mean(rV);
0020 
0021 % Set the threshold for each image volume
0022 thresh = mi*thresh_pct;
0023 
0024 % Find all voxels exceeding the threshold
0025 mask = rV >= repmat(thresh,size(rV,1),1);
0026 
0027 % Determine the scaling factor for each volume
0028 S = sum(mask)*100./sum(rV .* mask);
0029 
0030 % Multiply the entire by the scaling factor
0031 mask_idx = find(mask);
0032 
0033 rV = rV .* repmat(S,size(rV,1),1);
0034 
0035 % Reshape back to the original size
0036 nV = reshape(rV, dims);
0037

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003