Visualization of Proj.of Males, Ortho to Females, 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.00000182545561, 
          0.00000003347761, -0.00000086426077, -0.12641255131961, 
          0.13843838679534, 
          0.02381068942784, -0.23568583349728, -0.01676967114582, 
          0.30521203706262, -0.16229214840010, 
          0.20358038855350, -0.16564811681689, 
          0.15946992862629, -0.21406000385948, 
          0.19796013350408, -0.20832100220807, 
          0.31852192484948, -0.03934593967932, 
          0.29339901416011, -0.20545979268099, 
          0.00542495941528, -0.09684499056066, 
          0.11743111554211, -0.07300330316572, 0.09458175524481, 
          0.01867053753123, 
          0.13505373465020, -0.17881895985230, -0.06257497816274, 
          0.01105680212600, 0.14490545033690, 
          0.01735532296091, -0.01161291094039, 
          0.00172257356290, -0.05113430316693, 
          0.04908153691813, -0.09766329325836, 
          0.06296518684102, -0.06166989399147, 
          0.00635759598599, -0.16544139374472, 0.01195195396767, 
          0.05799382195157, 
          0.03689831095595, -0.02492765724809, -0.01960707849731, -0.18890329383082, -0.13260297756412, -0.08822859106046, 
          0.01650947063666, -0.01824420297468, 
          0.14369173720252, -0.05757151132515, -0.03061972384856, -0.01498725987633, -0.03986241019106, 0.03293442229801, 
          0.05624633371076, 0.16348419636895, 
          0.01463375680904, -0.03006945866230, -0.03706035246328, -0.06315473024030, 0.06832286483973, 
          0.03815147468789, -0.04997569309160, 
          0.02867175759177, -0.05716912610179, -0.07116054165142, 
          0.02062888640725, -0.02694813919728, 0.04996998613338, 
          0.00490397820756, -0.07296354201024, -0.08090430803446, -0.03329873875197, 0.05080425267299, 0.04179764195603, 
          0.02843368403103, -0.02064339591632};

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