-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmni2voxel.m
25 lines (21 loc) · 865 Bytes
/
mni2voxel.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
function voxelspace = mni2voxel(inputvoxel)
% convert mni coordinates to voxel coordinates in the fsl 2mm standard
% brain image
% inputvoxel should be [x y z ; x y z ; x y z] MNI_152 coordinates
% original author dvsmith
% from http://www.biac.duke.edu/forums/topic.asp?TOPIC_ID=1172
%my assumptions:
%voxel size == 2mm iso
%datasize=(91,109,91)
%mniorigin=[45 63 36] %identified as MNI coordinate [0 0 0] in fslview for fsl standard brain
templateImage = 'brain1mm';
switch templateImage
case 'brain2mm'
mniorigin=[45 63 36];
yourvoxel=[-1 1 1] .* inputvoxel/2; % x and y flipped between MNI and voxel space
voxelspace = yourvoxel + mniorigin;
case 'brain1mm'
mniorigin=[90 126 72];
yourvoxel=[-1 1 1] .* inputvoxel; % x and y flipped between MNI and voxel space
voxelspace = yourvoxel + mniorigin;
end