-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBruker2nifti.m
32 lines (27 loc) · 1.04 KB
/
Bruker2nifti.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [dest fname]=Bruker2nifti(path)
% FUNCTION Bruker2nifti.m
% Extracts scanner parameters and builds the Nifti volume
pars = get_pars(path);
total_dims = pars.dims;
if total_dims(4)>3
[Img] = read_seq(path,pars);
frames = pars.dims(4);
for p=1:frames
filename = ['Image_'];
if p<=999 filename = [filename '0']; end
if p<=99 filename = [filename '0']; end
if p<=9 filename = [filename '0']; end
filename = [filename int2str(p) '.nii'];
fprintf(' Image: %s\n',filename);
path = fullfile(fileparts(path),filename);
pars.dims = pars.dims(1:3);
im = Img(:,:,:,p);
[dest fname] = create_nifti_vol(im,path,pars);
end
pars.dims = [pars.dims;frames];
else
pars.dims = pars.dims(1:3);
[Img] = read_vol(path,pars);
[dest fname] = create_nifti_vol(Img,path,pars);
end
end