Visualization of Proj.of Normals, Ortho to Schizos, for Major Axis Rescaled, Full Population, on MAD 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  =  {1.00000000000000, 0, 0, -0.15195084000000, 
          0.04858573000000, -0.06803209000000, -0.23511130000000, 
          0.01804597000000, 0.02809804000000, 
          0.03525404000000, -0.00142181000000, -0.08276291000000, 
          0.00474653000000, -0.07421567000000, -0.03859208000000, -0.01290857000000, 0.02544342000000, 
          0.01821591000000, -0.00840569000000, -0.04382198000000, -0.01090547000000, -0.03409100000000, -0.01027874000000, -0.01428957000000, 0.02276759000000, -0.00005591000000, 
          0.00019325000000, -0.00798167000000, -0.00412871000000, 
          0.00156547000000, -0.00104142000000, -0.00605098000000, 
          0.00905652000000, -0.00692849000000, 0.00479774000000, 
          0.00158902000000, 0.00656396000000, 0.00799122000000, 
          0.00007162000000, -0.00306726000000, -0.00452232000000, 
          0.00027030000000, 0.00232349000000, 0.00137900000000, 
          0.00553573000000, 
          0.00250358000000, -0.00026729000000, -0.00033366000000, -0.00403778000000, 0.00521687000000, 0.00053708000000, 0.00114458000000, 
          0.00011893000000, -0.00205813000000, -0.00035760000000, -0.00067585000000, -0.00014223000000, 0.00350017000000, 
          0.00016588000000, 
          0.00012998000000, -0.00211975000000, -0.00131863000000, -0.00063710000000, -0.00066186000000, 
          0.00083729000000, -0.00021953000000, 
          0.00039799000000, -0.00076859000000, -0.00063800000000, 
          0.00023349000000, -0.00025169000000, -0.00033436000000, 
          0.00015018000000, -0.00069026000000, 
          0.00001612000000, -0.00063123000000, 0.00066879000000, 
          0.00041001000000, 
          0.00057962000000, -0.00041244000000};

axis  =  {0, -0.00000028131843, -0.00000063538197, 
          0.35643814654014, -0.42068476838024, -0.05133483572074, -0.19473094269012, 0.16866731374384, 0.16397887281617, 
          0.15256293915263, -0.60035883558650, -0.07169870845208, -0.07601675756502, -0.10770683763924, -0.02098345575201, 
          0.09101389420037, 0.25390568639298, -0.02822819372170, 
          0.07947424272362, -0.06169241994187, 0.05676250326212, 
          0.11537478972116, 
          0.05591698722727, -0.06725257465094, -0.01730396614977, -0.01681574485966, 0.00813187424717, -0.00389743591353, 
          0.02030684900706, -0.00316052223392, -0.04022484940983, -0.04374617922211, -0.04319006324623, 
          0.09231660273958, -0.07447069453870, -0.06309958784042, -0.01002074876292, 
          0.00293276259178, -0.08987962971648, -0.01592798602315, -0.03920713369387, 0.08962826598974, 
          0.02425060036933, -0.04279281341795, 0.02162533569188, 
          0.08293388005512, -0.06104006501578, 
          0.03993353327999, -0.00003297827507, 0.01820384392287, 
          0.04521698231243, -0.03227248557413, 0.04903723937822, 
          0.07311112272516, 
          0.04441154260640, -0.03833513494025, -0.02144061410800, 
          0.04198225278679, -0.01768938884609, 0.03621474451128, 
          0.02407768722701, 0.01560571907788, 
          0.02232027290428, -0.01732675919322, -0.01104932990803, 
          0.02326340335531, -0.04626953973266, 
          0.02702584336371, -0.03134199117783, -0.01022696479365, -0.00318827390243, 
          0.01271626937148, -0.01507931229601, -0.01627188590456, 
          0.00505656021143, -0.03657605946153, 0.02961500483737, 
          0.00170565993620, -0.01754237370301, -0.00435296198786};

axis  =  Normalize[axis];

Plot the (coordinate wise) 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]]