Visualization of Proj.of Females, Ortho to Males, for Major Axis Rescaled, Schizo Population, on Sph Data scale,

Documentation

This Mathematica notebook allows visualization of a direction in the feature space, using an animation of shapes at (mean + t*axis), for various values of t around zero.  As input, we require both a mean vector and an axis vector.

To use, simply paste in the mean and axis in the "Input data: mean and axis" section, and evaluate the entire notebook (single left click on the rightmost blue bar, and shift+Enter) (also from the menus, Kernel->Evaluation->Evaluate Notebook).

To adjust the range of the plot, adjust the values for δ and α in the "Plot options" section, and evaluate all cells from there on (click and drag on a blue bar to highlight multiple cells, and press shift+Enter).

A warning: You may need to adjust the scale of perturbations off mean (the range of t values); this is the third argument to the FourierAnim function in the final plot.

Setup subroutines

Read in required libraries

Needs["Graphics`Colors`"];

Needs["Graphics`Animation`"];

Needs["LinearAlgebra`Orthogonalization`"];

plotFourierPt subroutine

Return the {x,y} coord corresponding to s (between 0 and 2Pi), using maxorder coefficients of c.
Assumes c holds at least 4*maxorder real numbers in the order: Re((Subscript[c, 1])),  Im((Subscript[c, 1])),  Re((Subscript[c, -1])),  
      Im((Subscript[c, -1])),  Re((Subscript[c, 2])),   ...

\(\(plotFourierPt[c_List, \ maxorder_, \ 
          s_]\  := \ \((\ 
		cplxPt = \ 
            Sum[\ \((c[\([4  n - 3]\)]\  + \ c[\([4  n - 2]\)] I)\)\ Exp[
                    n\ I\ s]\  + \((c[\([4  n - 1]\)]\  + \ 
                      c[\([4  n]\)] I)\)\ Exp[\(-n\)\ I\ s], \ {n, 1, \ 
                maxorder}\ ]; 
		{Re[cplxPt], \ 
            Im[cplxPt]}\ \ )\);\)\)

The main plotting routines

These functions return a Graphics object; use ShowPlot to actually display them

plotFourier[c_List, maxorder_] := ParametricPlot[Evaluate[plotFourierPt[c, maxorder, s]], {s, 0, 2Pi},
  Evaluate[plotFourierOptions], DisplayFunction->Identity];

plotFourier[c_List] := plotFourier[c, Length[c]/4];

multiplotFourier[c_List, maxorder_] := ParametricPlot[Evaluate[Map[plotFourierPt[#, maxorder, s]&, c]],
  {s, 0, 2Pi}, Evaluate[plotFourierOptions], DisplayFunction->Identity];

This is just a macro to set the right DisplayFunction

ShowPlot[g_Graphics]  :=  
        Show[g,  DisplayFunction -> $DisplayFunction];

Animate along an axis through the mean

FourierAnim[mymean_List,  offset_List,  length_ , numframes_]  :=  
      Table[plotFourier[mymean  +  t offset],  {t,  -length,  
          length,  2 length/numframes}]

Subroutine to convert from matlab format (flat, w00z) to the format plotFourier likes (flat, cplx)

cvtw00z[w_,x_,y_,z_] := { w+z, y-x, w-z, y+x }/2;

Flatw00zToFlatCplx[c_List]  :=  
        Flatten[Apply[cvtw00z,  Partition[c,  4],  {1}]];

Plot options

After modifying plotrange, reevaluate both cells, then reevaluate the plot.

plotrange  =  { {-δ,  δ},  {-α δ,  α δ} } /.  {δ -> 1.5,  α -> 
              1/2};

plotFourierOptions  =  {PlotRange  ->  plotrange,  
          AspectRatio -> Automatic,  PlotPoints  ->  50};

Input data: mean and axis

These come from Part 1 of the file Eigenvector.txt

mean  =  {0.99999998988257, -0.00000000004249, -0.00000000815207, -0.14890885667999, 
          0.04631615579661, -0.06867955424860, -0.23594605970587, 
          0.01859252456040, 0.02438649565581, 
          0.03413432177527, -0.00469090595776, -0.08295111916888, 
          0.00533664633423, -0.07524301148546, -0.04136179149529, -0.01210875268342, 0.02309310511489, 
          0.01833272513018, -0.00846486752268, -0.04392924956181, -0.01098615476735, -0.03598997698790, -0.01058517671750, -0.01401422746211, 0.02257020063291, 0.00033072899653, 
          0.00023590085341, -0.00869156702959, -0.00345348275585, 
          0.00030597192151, -0.00137193187445, -0.00667969066486, 
          0.00904127017269, -0.00655340249989, 0.00501447359205, 
          0.00258552073912, 0.00648801952449, 0.00823373129342, 
          0.00043275898306, -0.00298887850287, -0.00332827922859, -0.00044356465178, 0.00196544293964, 0.00124098121236, 0.00592167003307, 
          0.00226352247340, -0.00014285700056, -0.00058604947765, -0.00428359723348, 0.00503898752002, 0.00075457255761, 0.00107280526054, 
          0.00042732990809, -0.00194148383409, -0.00026021270502, -0.00015924393146, -0.00055896473400, 0.00357139004531, 
          0.00018521478115, 
          0.00014204963106, -0.00227702206002, -0.00142480374493, -0.00062619308861, -0.00062940968098, 
          0.00077624011619, -0.00019058121174, 
          0.00041251634176, -0.00069431013873, -0.00088148948557, 
          0.00021433450379, -0.00037807112229, -0.00026326849121, 
          0.00019032930334, -0.00108451226204, 
          0.00002689323115, -0.00072626836349, 0.00058142750668, 
          0.00047562210024, 
          0.00043195050971, -0.00011112357174};

axis  =  {0.00000580421318, 0.00000063283691, 0.00000266569574, 
          0.06191757218265, -0.23036285244482, -0.09425388078541, -0.08348880216425, -0.09970476813023, 0.21003647206820, 
          0.06982091874489, 0.13999207726686, 0.15103396307198, 
          0.15031573284590, -0.01537792114230, -0.08555906752556, 
          0.01240356272939, 0.05231352357553, -0.05112768505175, 
          0.03035515302992, -0.07836326900063, 
          0.13125990402343, -0.04310087124098, 
          0.14428799383809, -0.18156732503443, -0.02698087222507, 
          0.04165978688936, 0.15043996431348, 0.24919154864383, 
          0.06740249410363, 
          0.22788289116638, -0.18344814434978, -0.21903078720913, -0.04856512463805, -0.00262334688644, -0.04499630935318, 
          0.43426329037237, -0.00310463263787, -0.04455108064842, 
          0.00394471832423, -0.12453471357998, 
          0.04876663905111, -0.05428706536103, -0.05755996652706, -0.11258046178048, 0.10894889784346, -0.12043170578442, 
          0.16976261577114, 0.01908354000589, 
          0.01162295114694, -0.06797862242406, 0.06888038691709, 
          0.09259171499657, 0.14544939424741, -0.08756622977094, 
          0.04673652944153, -0.01709549646658, 
          0.10367493668457, -0.05029871627848, -0.03432265574094, -0.09526792332072, -0.01308567666581, -0.09854620491074, 
          0.04096730895577, -0.16085883124028, -0.01524967655959, -0.04810142664946, -0.14594417235688, 
          0.09519451012774, -0.03309318273081, 
          0.00268459254321, -0.04055543053180, -0.08142501511506, -0.05476589401771, 0.06594181245148, 0.05868658651286, 
          0.08110599648398, -0.02746592338270, -0.10842648499120, -0.10677875950918, 0.06120640610578};

axis  =  Normalize[axis];

Plot the L1 median

ShowPlot[plotFourier[Flatw00zToFlatCplx[mean]]]

Animate the axis

The arguments to FourierAnim are the axis along which to move, the distance to move along that axis (+ and -), and the number of frames to generate.

Evaluating this cell generates many frames of output.  To view the animation, double-click on the second blue bar (from the left) in the output; this will shrink all the frames of output to show just the first frame.  Now double-click on the graphic; this should start playing the animation.  Animation controls should appear at the left of the bottom status bar; the second button makes the animation loop "ping-pong" style.

ShowAnimation[
      FourierAnim[Flatw00zToFlatCplx[mean],  Flatw00zToFlatCplx[axis],  
        0.1,  16]]