在MATLAB中以nii格式处理多个医学图像文件

时间:2016-06-16 13:19:24

标签: matlab medical

我正在尝试处理文件夹中的多个图像。以.nii格式有大约200个医学图像。

 %% setting up the folder
fileFolder = fullfile(pwd ,'\project\data_1');
files = dir(fullfile(fileFolder ,'*.nii'));
fileNames ={files.name};
%%sample 
img =load_untouch_nii('1.nii');
im =img.img;
classJ =class(im);

%%reading the files
I =load_untouch_nii(fullfile(fileFolder,fileNames{1}));
classI =class(I);
sizeI =size(I);
numImages =length(fileNames);

%% Read slices
hwaitbar =waitbar(0,'Reading nii files');

%%Read

for i =length(fileNames):-1:1
    fname =fullfile(fileFolder, fileNames{i});
    x(i) = load_untouch_nii(fname);
    y =x(i).img;
    figure; imshow(y(:,:,70),[]); %viewing the image to the check code
    **My Transformation function**
    waitbar((length(fileNames)-i+1)/length(fileNames));
end
delete(hwaitbar);

  

img = load_untouch_nii('xyz.nii')

在struct {}中加载包含标题,图像和其他一些信息的图像。然后 img.img 提取256 * 256 * 150 uint16格式的图像。我的问题是,一旦转换功能完成,如何将这些图像保存在单独的文件夹中?

1 个答案:

答案 0 :(得分:0)

由于您似乎拥有“NIFTI和ANALYZE工具”,您可以使用以下方法保存nifti文件:

var Promise = require('bluebird'),
    mongoose = require('mongoose');

mongoose.Promise = Promise;