Visualization of Proj.of Schizos, Ortho to Normal, 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.00000009266148, -0.00000015265116, 
          0.11691881460231, 
          0.00928321000026, -0.07902395468564, -0.78124870467190, 
          0.00125217223040, -0.33825335520485, -0.09957028767671, -0.17000929046086, 0.12047562866866, 0.04936912063404, 
          0.07089221335272, -0.11011254078206, -0.01762331654893, -0.23282311470207, -0.00121690047905, 0.08757863620946, 
          0.02422549032222, 
          0.08658063910944, -0.05295258649932, -0.10860126855395, 
          0.07344289701922, -0.12915226834418, 
          0.07434128752165, -0.06882902168474, 
          0.01497264414622, -0.03932031995813, -0.04755723557901, -0.02250598878021, 0.04529052001421, 0.03115145082496, 0.05335567973998, 
          0.00338154455927, 
          0.04190981592936, -0.04668054149707, -0.05967648632536, -0.03720003941127, 0.02066884254217, 
          0.07975753484741, -0.03698582164967, 
          0.00792127560574, -0.00086366967172, -0.02605585785496, -0.01027905760747, 0.01465151583211, -0.02845571246573, 
          0.08789185203286, -0.06331701674459, 
          0.02868976787249, -0.02947901292262, 0.00206249868899, 
          0.02743266416634, -0.03141107215562, 0.03482404382283, 
          0.05400018148477, -0.02791523967292, 0.01500337911438, 
          0.02310318859811, 0.00568853208321, 
          0.06815216587503, -0.00802660618368, 0.04172426758825, 
          0.02405036007188, -0.01771878021727, 
          0.04867443107439, -0.02694887759469, 0.01014555900045, 
          0.03471610780945, 0.02912428155757, 
          0.01337502354730, -0.03080811799367, -0.00793598844358, 
          0.00833855295049, -0.01913418313933, -0.01219337026053, 
          0.02270090094485, 
          0.00130574369607, -0.00463757775290};

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]]