/* This experiment is identical in procedure to Experiment 1 of
the following paper:

Rensink, R.A., O’Regan, J.K., & Clark, J.J. (1997). To See or Not to
See: The Need for Attention to Perceive Changes in
Scenes. Psychological Science, 8, 368-373.

*/

Experiment() {

  Context() {

    AssignmentGroup() {
      SubjectCode = "pxlab";
      DataFileTrialFormat = "%image% %Trial.PictureAnimation.ResponseTime@i% %Trial.PictureAnimation.ResponsePosition@b%";
      ExperimentName = "Change Blindness using Flicker Method";
      TrialFactor = 1;
      new image = "";
    }

    Session() {
      Instruction() {
	Text = ["Change Detection",
		" ",
		"In every trial you will see an image which contains short flicker breaks. Some detail of the image will be changed across flickers. Your task is to indicate whether you have detected the change by pressing a mouse button near to the location of the changing detail.",
		"Before each image starts, you will see a gray rectangle with a white bar telling you that the image sequence starts soon.",
		" ",
		"Press any key now to start the experiment!"];
      }
    }  

    SessionEnd() {
      SessionEndMessage();
    }

    Block() {
      BlockStartMessage();
    }

    BlockEnd() {
      BlockEndMessage();
    }

    Trial(image, PictureAnimation.FileName, PictureAnimation.ResponseTime, PictureAnimation.ResponsePosition) {
      SimpleBar() {
        Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
	Color = Gray;
	LocationX = 0;
	LocationY = 0;
	Width = 600;
	Height = 450;
      }
      SimpleBar:B() {
	Overlay = de.pxlab.pxl.OverlayCodes.JOIN;
        Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
	Duration = 3000;
	Color = White;
	LocationX = 0;
	LocationY = 0;
	Width = 200;
	Height = 90;
      }
      SimpleBar:C() {
        Timer = de.pxlab.pxl.TimerCodes.CLOCK_TIMER;
	Duration = 1000;
	Color = Gray;
	LocationX = 0;
	LocationY = 0;
	Width = 600;
	Height = 450;
      }
      PictureAnimation() {
	OnDuration = 235;
	OffDuration = 75;
        Timer = de.pxlab.pxl.TimerCodes.LIMITED_RESPONSE_TIMER;
	Duration = 60000;
	// Images are from http://www.usd.edu/psyc301/images
	Directory = "@./images/change_blindness_flicker";
	Color = Gray;
      }
      ClearScreen() {
        Timer = de.pxlab.pxl.TimerCodes.NO_TIMER;
      } 
    }
  }

  Procedure() {
    Session() {
      Block() {
	Trial("dinner", ["dinner1.jpg", "dinner1.jpg", "dinner2.jpg", "dinner2.jpg"], ?, ?);
	Trial("harbor", ["harbor1.jpg", "harbor1.jpg", "harbor2.jpg", "harbor2.jpg"], ?, ?);
	Trial("leopard", ["leopard1.jpg", "leopard1.jpg", "leopard2.jpg", "leopard2.jpg"], ?, ?);
	Trial("market", ["market1.jpg", "market1.jpg", "market2.jpg", "market2.jpg"], ?, ?);
	Trial("plane", ["plane1.jpg", "plane1.jpg", "plane2.jpg", "plane2.jpg"], ?, ?);
	Trial("tomb", ["tomb1.jpg", "tomb1.jpg", "tomb2.jpg", "tomb2.jpg"], ?, ?);
	Trial("tourist", ["tourist1.jpg", "tourist1.jpg", "tourist2.jpg", "tourist2.jpg"], ?, ?);
      }
    }
  }
}
