Home > marsbar > @maroi_matrix > rebase.m

rebase

PURPOSE ^

rebase method - returns data from maroi_matrix in new space

SYNOPSIS ^

function [pts, vals] = rebase(obj, sp, flags)

DESCRIPTION ^

 rebase method - returns data from maroi_matrix in new space
 Unless flags contains 'i', returns [pts, vals]
 otherwise returns matrix in new space

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [pts, vals] = rebase(obj, sp, flags)
0002 % rebase method - returns data from maroi_matrix in new space
0003 % Unless flags contains 'i', returns [pts, vals]
0004 % otherwise returns matrix in new space
0005 %
0006 % $Id$
0007 
0008 if nargin < 2
0009   error('Need space to give voxel points');
0010 end
0011 if nargin < 3
0012   flags = '';
0013 end
0014 if isempty(flags), flags = ' ';end
0015 
0016 sp = mars_space(sp);
0017 vol = obj.dat;
0018 mat = spm_mat(obj);
0019 Hold = spm_hold(obj);
0020 th = roithresh(obj);
0021 binf = binarize(obj);
0022 
0023 if any(flags == 'i')
0024   pts = zeros(sp.dim(1:3));
0025   vals = [];
0026 else % points call
0027   pts = cell(1, sp.dim(3));
0028   multvc = cell(1, sp.dim(3));
0029 end
0030 
0031 for z=1:sp.dim(3),
0032   M = inv(mat) * sp.mat * spm_matrix([0 0 z]);
0033   img = spm_slice_vol(vol,M,sp.dim(1:2),Hold);
0034   tmp = abs(img) >= th;
0035   img(~tmp) = 0;
0036   if any(tmp(:))
0037     if binf, img(tmp) = 1; end
0038     if any(flags == 'i') % image to return
0039       pts(:,:,z) = img;
0040     else % point list
0041       tmp = find(tmp);
0042       multvc(z) = {img(tmp)'};
0043       tmp = tmp-1;
0044       y = floor(tmp/sp.dim(1));
0045       x = tmp - (y*sp.dim(1));
0046       o = ones(1, length(x));
0047       pts(z) = {[[x y]'+1; o*z]};
0048     end
0049   end
0050 end
0051 if ~any(flags == 'i')
0052   pts =  [pts{:}];  
0053   vals = [multvc{:}];
0054 end

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019