Normalize the intensity of the data within an ROI to a zero-mean, unit-variance space
4 views (last 30 days)
Show older comments
Ghazn Khan
on 18 Aug 2020
Commented: Ghazn Khan
on 25 Aug 2020
Hi,
I have nifti neuroimaging data that I want to normalise within an ROI to a zero-mean, unit-variance space.
I tried using the code below however kept on getting an error;
ROI = niftiread('CHB_train_Case01_T1_brain_mask.nii');
Raw_brain = niftiread('CHB_train_Case01_T1.nii');
ind = find(ROI==1);
mean_val = mean(Raw_brain(ind));
std_val = std(Raw_brain(ind));
Raw_brain(ind)= Raw_brain(ind)-mean_val;
Raw_brain(ind)= (Raw_brain(ind)-mean_val)/std_val;
niftiwrite(Raw_brain,'Raw_brain_normalised_T1.nii');
the error I seem to be getting is as follows;
Error using var (line 74)
Invalid data type. First input argument must be single or double.
Error in std (line 59)
y = sqrt(var(varargin{:}));
Error in untitled8 (line 5)
std_val = std(Raw_brain(ind));
Would appreciate any guidance/help
Thanks
2 Comments
Accepted Answer
Srivardhan Gadila
on 22 Aug 2020
The error is due to the conflict with data type. Input argument of the std function must be of data type single or double. As per my knowledge the output data type of the niftiread would be unsigned integer (I think unit8 specifically).
Try with the following code:
ROI = niftiread('CHB_train_Case01_T1_brain_mask.nii');
Raw_brain = niftiread('CHB_train_Case01_T1.nii');
ind = find(ROI==1);
mean_val = mean(Raw_brain(ind));
std_val = std(double(Raw_brain(ind)));
More Answers (0)
See Also
Categories
Find more on Biomedical Imaging in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!