Permalink
Browse files

Initial commit to SVN from old SVN at:

  • Loading branch information...
Wildcarde committed Oct 14, 2009
0 parents commit 27338da02b5ded57fe131ffbf80d4eeb4c8e93dd
Showing 1,014 changed files with 93,625 additions and 0 deletions.
36 AUTHORS
@@ -0,0 +1,36 @@
The following have contributed code to the MVPA toolbox (and
given permission for it to be redistributed under the GPL
license - see COPYING). In alphabetical order:

Michael Bannert
Michael Benharrosh
Seth Bouvier
Melissa K. Carroll
Denis Chigirev
Greg Detre
Andy Engell
Garrett McGrath
Chris Moore
Ryan Moore
Vaidehi Natu
Ken Norman
Ehren Newman
Klaus Nuissl
Joel Quamme
Francisco Pereira
Sean Polyn
Susan Robison
Chris Said
Keith Schneider
Per Sederberg
Benjamin Singer
Greg Stephens
Sylvain Takerkart
Matthew Weber
David Weiss
Thomas Wolbers


[If you think your name should be on here, email
mvpa_support@princeton.edu, and we'll be happy to rectify
the oversight.]
674 COPYING

Large diffs are not rendered by default.

Oops, something went wrong.
32 README
@@ -0,0 +1,32 @@
This the Princeton multi-voxel pattern analysis toolbox for
Matlab.

http://www.csbmb.princeton.edu/mvpa

See the website for more information, or for the latest version.

Please contact mvpa_support@princeton.edu with any suggestions, bug reports
or feedback.


Copyright Greg J Detre, Sean M Polyn, Chris D Moore, Sylvain
Takerkart, Vaidehi S Natu (2005)

Distributed under the GNU Library GPL - see COPYING for details.

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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA


@@ -0,0 +1,107 @@
function [err,maplocation, mapsign, Mtrans] = AFNI_CoordChange (Orig, Trans, Morig)
%
% [err, maplocation, mapsign, Mtrans] = AFNI_CoordChange (Orig, Trans, [Morig])
%
%Purpose:
% Change the AFNI coordinate system between the 48 different coordinate systems allowed
% Coordinates are as they appear on the top left corner of AFNI's controller
% Coord Order plugin is used to change the coordinate system in AFNI
%
%Input Parameters:
% Orig : the 1x3 letter or number code for the original orientation, like RAI or [1 3 4]
% Trans : the 1x3 letter or number code for the new orientation
% Morig : an (optional) Nx3 matrix containing the XYZ coordinates of N points
%
%Output Parameters:
% err : 0 No Problem
% : 1 Mucho Problems
% maplocation: 1x3 vector containig the map from the old coordinate to the new coordinate system
% This specifies where each dimension in Mtrans is located in Morig
% mapsign: 1x3 vector (of 1 or -1) containing the sign of the map from the old coordinate system to the new one
% This specifies if the dimension has a negative direction (see more Info for an example)
% Mtrans: if Morig is specified, Mtrans is Morig in the new coordinate system
%
%
%Key Terms:
%
%More Info :
%
% maplocation and mapsign are used as such
%
% for (i=1:1:3),
% Mtrans(:,i) = mapsign(i).* Morig(:,maplocation(i));
% end
%
% example:
%[err,maplocation, mapsign, Mtrans] = AFNI_CoordChange ('RAI', 'ALI', [1 2 3; 4 5 6])
%
% Author : Ziad Saad
% Date : Tue Sep 5 18:56:40 PDT 2000
% LBC/NIMH/ National Institutes of Health, Bethesda Maryland


%Define the function name for easy referencing
FuncName = 'AFNI_CoordChange';

%Debug Flag
DBG = 1;

if (nargin == 2),
Morig = [];
end

if (~isempty(Morig) & size(Morig,2) ~= 3),
err = ErrEval(FuncName,'Err_Bad size for Morig');
return;
end


%initailize return variables
err = 1;
Mtrans= [];
maplocation = [0 0 0];
mapsign = [0 0 0];

if (ischar(Orig)),
[err, OrCode] = AFNI_OrientCode (Orig);
else
OrCode = Orig;
end

if (ischar(Trans)),
[err, TrCode] = AFNI_OrientCode (Trans);
else
TrCode = Trans;
end

for (i=1:1:3),
%look for the orientation
itmp = find (OrCode == TrCode(i));
if (~isempty(itmp)), %found, no need for flipping
maplocation(i) = itmp;
mapsign(i) = 1;
else %look for opposite orientation, need flipping
if (rem(TrCode(i),2)),
shft = -1;
else
shft = 1;
end
itmp = find(OrCode == TrCode(i)+shft);
if (isempty(itmp)),
err = ErrEval(FuncName,'Err_Bad code duuude');
end
maplocation(i) = itmp;
mapsign(i) = -1;
end
end %for i

if (~isempty(Morig)),
Mtrans = Morig;
for (i=1:1:3),
Mtrans(:,i) = mapsign(i).* Morig(:,maplocation(i));
end
end

err = 0;
return;

@@ -0,0 +1,103 @@
function [err,XYZdic] = AFNI_Index2XYZcontinuous (Indx, Info, CoordCode)
%
% [err,XYZdic] = AFNI_Index2XYZcontinuous (Indx, Info, [CoordCode])
%
%Purpose:
% Change from voxel XYZindex (called Voxel Coords in AFNI) to XYZ in mm
% The mm and voxel coordinates refer to the values displayed
% on the top left corner of AFNI controller.
% CoordCode is the one you'd set from the Coord Order plugin
%
%
%Input Parameters:
% Indx an Mx3 matrix or an Mx1 vector containing the voxel indices to be
% transformed to voxel coordinates. (indices start at 0)
% Info is the output of BrikInfo
% CoordCode is an optional parameter used to specify the coordinates system of the output
% if empty or not specified, the default is 'RAI'. The code can be either a string or a vector
% of numbers (see AFNI_CoordChange for more on that)
%
%Output Parameters:
% err : 0 No Problem
% : 1 Mucho Problems
% XYZdic : The continuous coordinates corresponding to Indx
% The coordnate system output is in RAI (DICOM)
% unless otherwise specified by CoordCode
%
%
%Key Terms:
%
%More Info :
% BrikInfo
% Test_AFNI_Index2XYZcontinuous
% AFNI_XYZcontinuous2Index
% Test_AFNI_XYZcontinuous2Index
%
% Author : Ziad Saad
% Date : Tue Sep 5 21:48:06 PDT 2000 Latest Modification: Feb 18 04
% LBC/NIMH/ National Institutes of Health, Bethesda Maryland


%Define the function name for easy referencing
FuncName = 'AFNI_Index2XYZcontinuous';

%Debug Flag
DBG = 1;

ChangeCoord = 0;
if (nargin == 3)
if (~isempty(CoordCode)),
ChangeCoord = 1;
end
end


%initailize return variables
err = 1;
XYZmm = [];

%make sure Indx is the right size
switch size(Indx,2),
case 1, %change 1D index to XYZ index
[err, Indx] = AfniIndex2AfniXYZ (Indx, Info.DATASET_DIMENSIONS(1), Info.DATASET_DIMENSIONS(2))
case 3, %OK
otherwise,
err = ErrEval(FuncName,'Err_Bad dimension for Indx');
return
end

XYZmm = Indx;

%The equations that would change the indices to coordinate system result in a coordinate system that
% may be any permutation of RAI (like IRA or AIR or IAR or RIA or ARI) so one only needs to find the
%dimension permutation needed to bring the final result to RAI.

%determine the ordering map to go from any permutation of RAI to RAI
%[maploc(1),jnk] = find(Info.Orientation == 'R');
%[maploc(2),jnk] = find(Info.Orientation == 'A');
%[maploc(3),jnk] = find(Info.Orientation == 'I');

%pre - Wed May 23 18:20:56 PDT 2001 - WRONG !
%XYZmm(:, maploc(1)) = Info.ORIGIN(1) + Indx(:,1) .* Info.DELTA(1);
%XYZmm(:, maploc(2)) = Info.ORIGIN(2) + Indx(:,2) .* Info.DELTA(2);
%XYZmm(:, maploc(3)) = Info.ORIGIN(3) + Indx(:,3) .* Info.DELTA(3);

%post - Wed May 23 18:20:56 PDT 2001 - WRONG!
%XYZmm(:, 1) = Info.ORIGIN(maploc(1)) + Indx(:,maploc(1)) .* Info.DELTA(maploc(1));
%XYZmm(:, 2) = Info.ORIGIN(maploc(2)) + Indx(:,maploc(2)) .* Info.DELTA(maploc(2));
%XYZmm(:, 3) = Info.ORIGIN(maploc(3)) + Indx(:,maploc(3)) .* Info.DELTA(maploc(3));

%Feb 18 04, back to the original
XYZmm(:, 1) = Info.ORIGIN(1) + Indx(:,1) .* Info.DELTA(1);
XYZmm(:, 2) = Info.ORIGIN(2) + Indx(:,2) .* Info.DELTA(2);
XYZmm(:, 3) = Info.ORIGIN(3) + Indx(:,3) .* Info.DELTA(3);
%Now this is in the axis orientation which is Info.Orientation(:,1)' called 3dmm in thd_coords.c
[err,XYZdic, map] = THD_3dmm_to_dicomm (Info, XYZmm);

if (ChangeCoord),
[err, maplocation, mapsign, XYZdic] = AFNI_CoordChange ('RAI', CoordCode, XYZdic);
end

err = 0;
return;

@@ -0,0 +1,101 @@
function [err, Itrans] = AFNI_IndexChange (Info, Iorig, Direction, DispOrient)
%
% [err, Itrans] = AFNI_IndexChange (Info, Iorig, Direction, [DispOrient])
%
%Purpose:
% Change the AFNI Index system between the display's and AFNI's coordinate system
%
%
%Input Parameters:
% Info: The data structure output from BrikInfo
% Iorig : anNx3 matrix containing the Ix Iy Iz indices of N points
% Direction : A string : either 'A2D' or 'D2A' meaning Afni to Display or vice versa
% DispOrient : The orientation string (or vector) for AFNI's display. This parameter is optional
% and the defualt is 'RAI", it could be 'LAI' if AFNI's using Left is Left option.
%
%Output Parameters:
% err : 0 No Problem
% : 1 Mucho Problems
% Itrans: if Iorig is specified, Itrans is Iorig in the new coordinate system
%
%
%
%Key Terms:
%
%More Info :
% Test_AFNI_IndexChange
%
% see also AFNI_CoordChange
%
%
% Author : Ziad Saad
% Date : Fri Sep 8 12:21:01 PDT 2000
% LBC/NIMH/ National Institutes of Health, Bethesda Maryland


%Define the function name for easy referencing
FuncName = 'AFNI_IndexChange';

%Debug Flag
DBG = 1;

%initailize return variables
err = 1;
Itrans= [];
maplocation = [0 0 0];
mapsign = [0 0 0];


if (nargin == 3),
DispOrient = [0 3 4]; %that's RAI
end


%Assume we're going from Display to Afni ('D2A)
if (ischar(DispOrient)),
[err, OrCode] = AFNI_OrientCode (DispOrient);
else
OrCode = DispOrient;
end

[err, TrCode] = AFNI_OrientCode (Info.Orientation(:,1)');

%check if that's what is required
if (strmatch(Direction, 'A2D')),
%we're going from Afni to Display coordinates
tmp = TrCode;
TrCode = OrCode;
OrCode = tmp;
else
if (~strmatch(Direction, 'D2A')),
err = ErrEval(FuncName,'Err_Bad Direction string');
return;
end
end


%get maplocation and mapsign, automatically from AFNI_CoordChange (no need to rewrite the code here)
[err,maplocation, mapsign] = AFNI_CoordChange (OrCode, TrCode);

Itrans = Iorig;
if (strmatch(Direction, 'A2D')),
fprintf ('Doing A2D\n');
%(1-mapsign(i))./2 is 0 when mapsign(i) = 1 and 1 when mapsign(i) = -1; This way, the if condition for mapsign(i) can be done away with
%I left the simple method for the second loop for clarity. i don't think there's much efficiency difference between the two.
for (i=1:1:3),
Itrans(:,i) = ( (1-mapsign(i))./2 .* (Info.DATASET_DIMENSIONS(maplocation(i)) - 1) ) + ( mapsign(i) .* Iorig(:,maplocation(i)) );
end
else
fprintf ('Doing D2A: \n');
for (i=1:1:3),
Itrans(:,i) = Iorig(:,maplocation(i));
if (mapsign(i) < 0),
Itrans(:,i) = Info.DATASET_DIMENSIONS((i)) -1 - Itrans(:,i);
end
end
end


err = 0;
return;

Oops, something went wrong.

0 comments on commit 27338da

Please sign in to comment.