VoxelValueAtTimepoint.m
2095645b
 function vValue = VoxelValueAtTimepoint (coordinate, timepoint)
 % single Voxel for single coordinate
 
 if(size(coordinate,2)>1)
     error('VoxelValueAtTimepoint:CoordinateError','only single Coordinate permitted.');
 end
 
 imageNumber = timePointToImageNumber(timepoint, 's');
 V           = evalin('base','SPM.xY.VY'); % Memory Mapped Images
 center      = round(inv(V(imageNumber).mat)*[coordinate; 1]);
 
 x           = center(1,1);
 y           = center(2,1);
 z           = center(3,1);
 
 vValue      = spm_sample_vol(V(imageNumber), x, y, z, 0);
 
 end