Experiment() {

  Context() {

    AssignmentGroup() {
      ExperimentName = lang2("Interocular Transfer of Motion Aftereffect", "Interokularer Transfer des Bewegungsnacheffektes");
      SubjectCode = "pxlab";
      SkipBoundingBlockDisplays = 0;
      RandomizeBlocks = 1;
      new watchLeftMsg = lang2("Please watch the following grating with your left eye only!", 
		"Bitte betrachten Sie das folgende Muster mit dem linken Auge!");
      new watchRightMsg = lang2("Please watch the following grating with your right eye only!", 
		"Bitte betrachten Sie das folgende Muster mit dem rechten Auge!");
      new changeMsg = lang2("Please view with OTHER eye now!", 
		"Bitte wechseln Sie jetzt auf das andere Auge!");
      new noChangeMsg = lang2("Please view with SAME eye now!", 
		"Bitte behalten Sie das Auge zum Betrachten bei!");
      // ScreenBackgroundColor = gray();
    }

    Session() {
      Instruction() {
        Text = lang2(["Interocular Transfer of Motion Aftereffect",
		" ",
		"A moving grating will be presented for 30 seconds.",
		"Before the grating is shown you will be told which eye you should use to view the grating. Try to fixate its center as well as you can. After 30 s a stationary grating will be presented and you will be told which eye with which to view it.",
		"You will see apparent motion in the opposite direction. Please press any key when the apparent motion has disappeared.",
		"There will then be a 60 s pause before the next trial. Stop experiment to view data in the data file.",
		" ",
		"Press any key to start!"],
	        ["Interokularer Transfer", 
		" ",
		"Wir zeigen Ihnen für 30 Sekunden ein bewegtes Streifenmuster.",
		"Davor wird Ihnen mitgeteilt, welches Auge Sie zum Betrachten benutzen sollen. Bitte versuchen Sie das Muster so starr wie möglich zu fixieren. Nach 30 s bleibt das Muster stehen und es wird Ihnen erneut mitgeteilt, welches Auge Sie weiterhin benutzen sollen.",
		"Sie werden dann eine scheinbare Bewegung in die Gegenrichtung sehen.",
		"Wenn diese Bewegung abgeklungen ist, drücken Sie bitte eine beliebige Reaktionstaste.",
		"Zwischen zwei Durchgängen wird eine Pause von 1 min eingelegt.",
		" ",
		"Bitte drücken Sie jetzt eine beliebige Taste zum Start."]);
      }
    }

    SessionEnd() {
      SessionEndMessage();
    } 


    Block(Message.Text) {
      Counter() {
	Execute = BlockCounter != 0;
        Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
	Duration = 60000;
	InitialCount = 60;
        Step = -1;
        LocationY = 240;
        FontSize = 32;
        FrameDuration = 1000;
      }
      Message() {
        Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
	Duration = 3000;
        LocationY = 240;
        FontSize = 32;
      }        
    }


    Trial( TrialCounter, Message.Text, Nothing.ResponseTime) { 
      GaborPatternAnimation() {
        Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
	Duration = 30000;
    	FramesPerCycle = 192 / Trial.GaborPatternAnimation.VerticalFrequency;
	FrameDuration = 40;
	AmplitudeModulation = 0;
	Width = 256;
	Height = 256;
	MeanColor = gray();
	HighColor = white();
        VerticalFrequency = 8.0;
        VerticalPhase = 0.0;
	VerticalAmplitude = 1.0;
	VerticalOrientation = 0.0;
	HorizontalGaussianStandardDeviation = 64;
	VerticalGaussianStandardDeviation = 64;
        FixationType = de.pxlab.pxl.FixationCodes.FIXATION_CROSS;
        // FixationColor = white();
        // FixationType = de.pxlab.pxl.FixationCodes.CORNER_MARKS;
        FixationSize = 20;
      }
      GaborPattern() {
        Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
	Width = Trial.GaborPatternAnimation.Width;
	Height = Trial.GaborPatternAnimation.Height;
	MeanColor = Trial.GaborPatternAnimation.MeanColor;
	HighColor = Trial.GaborPatternAnimation.HighColor;
        VerticalFrequency = Trial.GaborPatternAnimation.VerticalFrequency;
        VerticalPhase = Trial.GaborPatternAnimation.VerticalPhase;
	VerticalAmplitude = Trial.GaborPatternAnimation.VerticalAmplitude;
	VerticalOrientation = Trial.GaborPatternAnimation.VerticalOrientation;
	HorizontalGaussianStandardDeviation = Trial.GaborPatternAnimation.HorizontalGaussianStandardDeviation;
	VerticalGaussianStandardDeviation = Trial.GaborPatternAnimation.VerticalGaussianStandardDeviation;
        FixationType = de.pxlab.pxl.FixationCodes.FIXATION_CROSS;
        // FixationColor = white();
        // FixationType = de.pxlab.pxl.FixationCodes.CORNER_MARKS;
        FixationSize = 20;
      }
      Message() {
        Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
	Overlay = de.pxlab.pxl.OverlayCodes.JOIN;
        LocationY = 240;
        FontSize = 32;
      }
      Nothing() {
        Timer = de.pxlab.pxl.TimerCodes.RESPONSE_TIMER;
      }
    }
  }

  Procedure() {
    Session() {
      Block(watchLeftMsg) {
        Trial(?, changeMsg, ?);
      }
      Block(watchLeftMsg) {
        Trial(?, noChangeMsg, ?);
      }
      Block(watchRightMsg) {
        Trial(?, changeMsg, ?);
      }
      Block(watchRightMsg) {
        Trial(?, noChangeMsg, ?);
      }
    }
  }
}
