-
Notifications
You must be signed in to change notification settings - Fork 0
/
go_ImportMRI.m
61 lines (51 loc) · 1.86 KB
/
go_ImportMRI.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [mri_info, mri_image] = go_ImportMRI(mri)
%
% CTF MRI Import Wrapper - George O'Neill 2015
%
% [mri_info,mri_image] = go_readCTFmri(mri)
%
% Inputs:
%
% - mri: A string with the path and name of the CTF .mri file.
%
% Outputs:
%
% - mri_info: A small header which contains the MRI resolution and
% transformation matricies required for source reconstruction.
% - mri_image: The anatomical image, presented in FSL orientation.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('Loading CTF MRI: ')
if ~exist(mri)
error('ERROR: .mri files does not exist')
end
[MRItag,MRIdata]=readCTFMRI(mri);
for ind = 1:length(MRItag);
if strmatch(MRItag(ind).name,'_CTFMRI_MMPERPIXEL');
tmp = MRItag(ind).data;
tmp(strfind(tmp,'\')) = ';';
mri_info.VoxSize = str2num(tmp)';
elseif strmatch(MRItag(ind).name,'_CTFMRI_TRANSFORMMATRIX');
tmp = MRItag(ind).data;
tmp(strfind(tmp,'\')) = ';';
mri_info.T = reshape(str2num(tmp),4,4);
end
end
anatomy = permute(MRIdata,[3 1 2]);
anatomy = flipdim(anatomy,1);
anatomy = flipdim(anatomy,2);
anatomy = flipdim(anatomy,3);
mri_image = anatomy;
fprintf(' COMPLETE\n')