;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;

;;;;   Author: Andrew Reifers

;;;;   Contact: alr288@psu.edu

;;;;   Institution: Penn State University

;;;;   Date: 2/05/04

;;;;   Title: Signal Detection Task

;;;;

;;;;   This task is designed to quantify participant's ability to detect

;;;;   and react to ambigous stimuli.

;;;; 

;;;;   It provides 30 circles and & squares and requests that the participant

;;;;   pushes the space bar when they see a circle.  The trial data and computed

;;;;   measures of d prime, theta, and reaction times are printed in the both

;;;;   the experimental and individual participant output file. There is also a

;;;;   simple reaction time task placed at the end of this experiment that data

;;;;   is also output to the experimental and individual output files. Absent

;;;;   reactions are represented with the integer 9999.

;;;;

;;;;   To run this code be sure to change the basepath and load it into allegro

;;;;   common lisp 6.0 or higher.  It will automatically start.

;;;;

;;;;   This task is allegro dependent, therefore also bound to a PC.

;;;;   unfortunantley this task was written by a novice lisp programmer (myself) 

;;;;   and this task has not yet been expanded to other listners.

;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

;; IMPORTANT!!!! READ

;; It is  very difficult to dynamically display the stimuli to different

;; screen settings, therefore, in order for everything to work smoothly

;; with this experiment please set your screen settings to a 1024 by 768 pixel

;; size setting. Also Set the *basepath* to the directory where you

;; would like the result files to be stored. Also please note that

;; session 2 and only session 2 will result in a complete reversal in the 

;; time, location and stimuli. 

 

;;;;;;;;;;;;;;;           BASEPATH        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  

 

;; SET THIS TO YOUR RESULTS DIRECTORY

 

(defconstant *basepath* "C:/Documents and Settings/")

 

;;;;;;;;;;;;;;;;           VERSION       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

(defconstant SDT-Version "1.1")

 

#-allegro("needs allegro")

 

; (push ':debug *features*)

 

 

;;;;;;;;;;;;;;;;;;;;; Table Of Contents ;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;

;;

;; I. Variables

;;   A. Flags and Streams

;;   B. Lists

;;   C. Counters and Miscellaneous

;;

;;

;; II. Intialization and Start  Functions

;;

;;

;; III. Display and Event Handler Methods

;;   A. Display Method

;;   B. Event Handler Method

;;

;;

;; IV. Task Relevent Functions

;;   A. Functions Evoked During the Task

;;   B. Computational Functions

;;   C. Output Function

;;

;;  V. Intiate the Experiment

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; I. Variables

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; A. Flags and Streams

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

(defvar *f* nil "Boolean which indicates true or false stimuli.")

(defvar *f2* nil "Boolean which indicates if the experiment is running.")

(defvar *show-stim* nil "Boolean which indicates if a stimuli will be shown.")

(defvar *responded* nil "Boolean which is set to true after a response.")

(defvar *notfinished* nil "Boolean which indicates when the experiment is over.")

(defvar *notstarted* nil "Boolean which indicates when the experiment is started.")

(defvar *crosshairs* nil "Boolean which indicates when the crosshais will be displayed.")

(defvar *exists* nil "Boolean which indicates if a filename already exists.")

(defvar *dataexists* nil "Boolean which indicates if the data file already exists.")

(defvar *miss* nil "Boolean which indicates a miss.")

(defvar *false* nil "Boolean which indicate a false alarm.")

(defvar *stream* nil "The main display stream.")

(defvar *out* nil "The individual output file stream.")

(defvar *data* nil "The overall output file stream.")

(defvar *finalpath* nil "String created from a merge with the basepath create an individual data file.")

(defvar *ALLDATApath* nil "String created from a merge with the basepath create an overall data file.")

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; B. Lists

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

(defvar *reactionlist* nil "List of time intervals for the simple reaction task.")

(defvar *time-list* nil "List of time intervals for the signal detection task.")

(defvar *loclist* nil "List of Locations used to dictate where the stimuli will appear.")

(defvar *beep-list* nil "List of Booleans used to set the value of *f*.")

(defvar *reactlist* nil "Temporary List of the simple reaction times.")

(defvar *reac* nil "Temporary List of the Signal Detection reaction times.")

(defvar *freac* nil "Temporary list of the false alarm reaction times.")

(defvar *tempreclist* nil "List used for analysis and therefor excludes misses." )

(defvar *hitlist* nil "List used for analysis and therefor excludes misses." )

(defvar *alarmlist* nil "List used for analysis and therefor excludes hits." )

(defvar *reactfinal* nil " List of the final simple reaction times in order.")

(defvar *falsefinal* nil " List of the final False Alarm times in order.")

(defvar *final* nil " List of the final Signal Detection Reaction times in order.")

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; C. Counters and Miscellaneous Variables

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

(defvar *count* 0 "Integer which tracks the number of trials.")

(defvar *time1* 0 "Integer used to compute the reaction time.")

(defvar *time2* 0 "Integer used to compute the reaction time.")

(defvar *partnum* nil "The Participants ID Number.")

(defvar *sessnum* nil "The Session ID Number.")

(defvar *instructions* nil "String of Instructions presented to the participant.")

(defvar *thanks* nil "String which Notifies the participant of Experiment Completion.")

(defvar *loc1* 0 "Location Integer which is set from the *locList*.")

(defvar *loc2* 0 "Location Integer which is set from the *loclist*.")

(defvar *misses* 0 "Integer which records the total misses.")

(defvar *alarms* 0 "Integer which records the total hits.")

(defvar *hitrate* 0 "Integer which records the hitrate.")

(defvar *falserate* 0 "Integer which records the falserate.")

(defvar *rejects* 0 "Integer which records the total rejects.")

(defvar *theta* 0 "Integer which records the theta value.")

(defvar *d* 0 "Integer which records the D-Prime value of the Signal Detection task.")

(defvar *hits* 0 "Integer which records the total hits.")

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; II. Intialization Functions

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

;; Intializes all variables that are not

;; explicitly intialized other places

(defun start-var ()

  (setf *count* 0)

  (setf *f* nil)

  (setf *exists* nil)

  (setf *dataexists* nil)

  (setf *f2* nil)

  (setf *false* nil)

  (setf *freac* nil)

  (setf *reactlist* nil)

  (setf *reac* nil)

  (setf *final* nil)

  (setf *notfinished* t)

  (setf *hitrate* 0)

  (setf *falserate* 0)

  (setf *rejects* 0)

  (setf *theta* 0)

  (setf *d* 0)

  (setf *hits* 0)

  (setf *loc1* 0)

  (setf *loc2* 0)

  (setf *show-stim* nil)

  (setf *hitlist* nil)

  (setf *misses* 0)

  (setf *alarms* 0)

  (setf *tempreclist* nil)

  (setf *reactfinal* nil)

  (setf *alarmlist* nil)

  (setf *falsefinal* nil)

  (setf *miss* nil)

  (setf *notstarted* t)

  (setf *crosshairs* t)

  (setf *reactionlist* '(3 5 1 4 5 1 5 2 5 2 1 4 1 3 3 ))

  (setf *beep-list* '(nil t nil t t t nil nil nil nil t nil nil t t t t nil t nil

                      t nil t nil t nil t t nil t nil nil t nil t t t nil nil nil

                      nil t nil t t t nil nil t nil nil t nil t t nil t nil t nil))

 

  (setf *time-list* '(3 5 3 1 5 1 3 3 2 3 2 4 2 5 2 3 3 3 5 4 1

                                                              4 2 5 2 3 1 5 5 4 1 5 3 1 5 1 3 3 2 3 2

                                                      1 4 5 3 3 3 2 5 2 4 2 3 2 3 3 1 5 1 3 5))

 

  (setf *loclist* '((155 483) (770 177) (410 613) (170 360)

   (608 334) (374 344) (604 422) (780 508)

   (584 525) (712 185) (376 150) (907 529)

   (448 126) (577 273) (731 578) (122 435)

   (679 502) (892 536) (677 208) (696 312)

   (604 573) (617 100) (595 588) (346 272)

   (544 450) (445 90)  (717 181) (358 453)

   (828 221) (155 540) (178 157) (531 493)

   (496 376) (636 310) (315 287) (673 477)

   (643 178) (259 635) (173 188) (384 405)

   (511 502) (408 224) (622 621) (105 98)

   (378 181) (744 217) (746 639) (710 527)

   (638 627) (852 533) (619 363) (288 595)

   (190 257) (281 151) (873 413) (709 539)

   (677 315) (728 462) (899 122) (592 97)

   (831 504) (342 417)))

 

  (setf *instructions* "Please read these instructions carefully.

 

 The experiment starts with a Plus Symbol showing you where to direct your attention.

 Squares and Circles will appear.

 When there are no Circles or Squares please focus on the Plus Symbol.

 

 Your task is to respond to the Circles by pressing the Space Bar and ignore the Squares completely.

 Please respond as quickly and as accurately as possible.

 

 When you are ready to begin press the Enter or Return key.")

 

  (setf *thanks* "You have now completed the Signal Detection Task.

 

 Thank you for your time.

 

 Please refer to your proctor if you have any questions"))

 

 

;; Starts the Experiment, Prompts the Proctor for the

;; Participants name and the session number

;; Also reverses the lists for the 2nd session.

 

(defun start ()

  (start-var)

  (format t "~%Enter the participants identification number and then press return:~%")

  (setf *partnum* (read))

  (format t "~%Enter the session number and then press return:~%")

  (setf *sessnum* (read))

  (if (equal *sessnum* 2)

               (progn

                                    (setf *time-list* (reverse *time-list*))

                                    (setf *beep-list* (reverse *beep-list*))

                                    (setf *loclist* (reverse *loclist*))))

  (setf *stream* (make-window 'SDT :state :maximized :device 'my-window)))

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; III. Display and Event Handler Methods

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

;; defclass my-window stream type frame-window

(defclass my-window (frame-window)())

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; A. Display Method

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

(defmethod redisplay-window ((window my-window) &optional box)

   (declare (ignore box))

   (call-next-method)

 

   ; count is incremented before this we really want 60

   ; trials of random location

   (if (< *count* 61)

               (progn

                           (setf *loc1* (car (nth *count* *loclist*)))

                           (setf *loc2* (car (cdr (nth *count* *loclist*)))))

               (progn (setf *loc1* 512) (setf *loc2* 374)))

 

   ; In thes if statemnts the graphics to be displayed are

   ; dictated by boolens, *f*, *show-stim*, *f2*,*crosshairs*

   ; *notstarted* and *notfinished*

 

   (if (and *f* *show-stim*)

                (progn

#+:debug  (format t "~%Circle is Visible")

          (with-font (window (make-font-ex :roman :times 24))

                                    (draw-string-in-box window "+" 0 nil (make-box 500 362 524 386) :center :center))

                          (fill-circle window (make-position *loc1* *loc2*) 6)

                  (setf *miss* t)

                          (sleep .3)

                          (setf *show-stim* nil)

                          (invalidate *stream*))

                                     

  (if *show-stim*

                        (progn

#+:debug  (format t "~%Square is Visible")

                          (with-font (window (make-font-ex :roman :times 24))

                                    (draw-string-in-box window "+" 0 nil (make-box 500 362 524 386) :center :center))

                          (fill-box window (make-box (- *loc1* 6) (- *loc2* 6) (+ *loc1* 6) (+ *loc2* 6)))

          (setf *false* t)

          (sleep .3)

          (setf *show-stim* nil)

          (invalidate *stream*))

 

  (if (and *f2* (not *crosshairs*))

              (progn

                (with-font (window (make-font-ex :roman :times 24))

                 (draw-string-in-box window "+" 0 nil (make-box 500 362 524 386) :center :center))

                (start-recording)))))

 

 (if *f2*

  (if *crosshairs*

    (progn

#+:debug  (format t "~%Crosshairs are Visible")

      (with-font (window (make-font-ex :roman :times 24))

        (draw-string-in-box window "+" 0 nil (make-box 500 362 524 386) :center :center))

              (start-recording)))

; *f2* else

            (if *notstarted*

            (progn

            (with-font (window (make-font-ex :roman :times 24))

                                       (draw-string-in-box window *instructions* 0 nil (make-box 0 200 1000 570) :center :top :wrap t)))

                                         (if (not *notfinished*)

                                                  (progn

                                                    (with-font (window (make-font-ex :roman :times 24))

                                                            (draw-string-in-box window *thanks* 0 nil (make-box 0 200 1000 570):center :top :wrap t)))))))

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; B. Event Handler Method

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

; This method handles kepyresses of the user during the experient

; as well as during the intialization of the experiment

 

(defmethod virtual-key-down ((window my-window) buttons data)

#+:debug (format t "~%Key-down")

  (case buttons

        (t

           (case data

                 (#.vk-return

#+:debug          (format t "~%Return Key pressed")

                                  (progn (setf *f2* t)

                                         (setf *notstarted* nil)

                                         (invalidate *stream*)))

                                         (#.vk-space

#+:debug          (format t "~%Space pressed with value of *F*: ~a" *f*)

                                  (if (not *responded*)

                                      (progn

                                                  (setf *time2* (get-internal-real-time))

                                  (if *f*

                                              (progn

                                                                  (my-stop-timer)

                                                          (setf *miss* nil)

                                  (setf *responded* t))

                              ; else

                              (progn

                                   (record-false)

                                   (setf *false* nil)

                                   (setf *responded* t))))))

                 ; any other char

                 (t (call-next-method))))))

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; IV. Task Relevant Functions

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; A. Functions Evoked During the Task

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

;; Pushes a correct Signal Detection response time on to the *reac* list

;; or  Pushes a simple reaction time on to the *reactlist* list

 

(defun my-stop-timer ()

#+:debug (format t "~%Stop timer")

 (if (> *count* 60)

 (push (- *time2* *time1*) *reactlist*)

 (push (- *time2* *time1*) *reac*)))

 

;; Pushes a false alarm time on to the *freac* list

 

(defun record-false ()

#+:debug (format t "~%False Reaction")

 (push (- *time2* *time1*) *freac*))

 

;; Pushes a 9999 onto the *reac* list

 

(defun record-miss ()

#+:debug (format t "~%Record Miss")

 (push 9999 *reac*)

 (setf *misses* (+ *misses* 1)))

 

;; Pushes a 9999 onto the *freac* list

 

(defun record-reject ()

#+:debug (format t "~%Recording a Correct Reject")

 (push 9999 *freac*)

 (setf *rejects* (+ *rejects* 1)))

 

;; Pushes a 9999 onto the *reactlist* list

 

(defun no-reac ()

#+:debug (format t "~%NO REACTION")

 (push 9999 *reactlist*))

 

;; Monitors the Reaction Status of the last stimuli presentation

;; then restarts the process by setting *f* and sleeping.

 

(defun start-recording ()

#+:debug (format t "~%Start Recording, count: ~a" *count*)

 (setf *crosshairs* nil)

(if (> *count* 60)

 (progn (sleep (nth (- *count* 61) *reactionlist*))

 (if (and *f* *miss*)

  (no-reac))

 (my-start-timer))

 (progn (sleep (nth *count* *time-list*))

 (if (and *f* *miss*)

  (record-miss))

 (if (and (not *f*) *false*)

  (record-reject))

 (my-start-timer))))

 

;; Sets the appropriate variables checks the count

;; starts the timer and updates the screen.

 

(defun my-start-timer ()

#+:debug (format t "~%Start timer")

 (if (> *count* 59)

     (setf *f* t)

    (setf *f* (nth *count* *beep-list*)))

 (setf *count* (+ 1 *count*))

 (setf *responded* nil)

 (if (> *count* 75)

    (finish)

   (progn

    (setf *show-stim* t)

    (setf *time1* (get-internal-real-time))

    (invalidate *stream*))))

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; B. Computational Functions

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

;; function that returns the final pathname of the output file

 

(defun my-filename ()

 (concatenate 'string (print-part)))

 

;; helper function of the my-filename function

 

(defun print-part ()

 (format nil "Participant~a.txt" *partnum*))

 

 

;; used to calculate the avg of a list

;; default list *hitlist*

 

(defun myavg (&optional (lis *hitlist*))

 (if (= (length lis) 0)

  0

 (/ (apply #'+ lis) (length lis))))

 

;; computes and returns the standard deviation

;; default list *hitlist*

 

(defun my-standard (&optional (lis *hitlist*))

(if (< (length lis) 2)

                0

               (let ((avg (myavg lis)) (stand 0))

                         (do ((count 0 (+ 1 count)))

                                     ((> (+ count 1) (length lis)))

                                     (setf stand (+ stand (* (- (nth count lis) avg) (- (nth count lis) avg)))))

                         (sqrt (/ stand (- (length lis) 1))))))

 

 

; extracts the reaction times from the final list

 

(defun hits ( &optional (lis *final*))

  (mapcan #'(lambda (x) (and (< x 9999) (list x))) lis))

 

; extracts the reaction times from the falsefinal list

 

(defun alarms ( &optional (lis *falsefinal*))

  (mapcan #'(lambda (x) (and (< x 9999) (list x))) lis)) 

 

; extracts the reaction times from the reactfinal list

 

(defun reacts ( &optional (lis *reactfinal*))

  (mapcan #'(lambda (x) (and (< x 9999) (list x))) lis)) 

 

 

;; computes and sets *theta* to the appropriate value

 

(defun compute-theta ()

  (setf *theta* (ztable (- 1 *falserate*))))

 

 

;; computes and sets *d* to the appropriate value

 

(defun compute-d ()

 (setf *d* (+ (ztable *hitrate*) (ztable (- 1 *falserate*)))))

 

;; The ztable that is uses to compute the values of theta

;; and the D-prime of this Signal Detection task.

;; This table was extracted from Signal Detection by Christopher Wickens

 

(defun ztable (num)

  (case num (0/30 0)

  (1/30 0)

  (2/30 0)

  (3/30 0)

  (4/30 0)

  (5/30 0)

  (6/30 0)

  (7/30 0)

  (8/30 0)

  (9/30 0)

  (10/30 0)

  (11/30 0)

  (12/30 0)

  (13/30 0)

  (14/30 0)

  (15/30 0)

  (16/30 .083)

  (17/30 .166)

  (18/30 .253)

  (19/30 .340)

  (20/30 .429)

  (21/30 .524)

  (22/30 .622)

  (23/30 .726)

  (24/30 .842)

  (25/30 .966)

  (26/30 1.108)

  (27/30 1.282)

  (28/30 1.498)

  (29/30 1.824)

  (1 3.093)))

 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; C. Output Function

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

;; Sets appropriate variables, updates the screen and

;; prints all relative information to the output file.

 

(defun finish ()

#+:debug (format t "~%Finished")

 (setf *notfinished* nil)

 (setf *f2* nil)

 (setf *show-stim* nil)

 (setf *f* nil)

 (invalidate *stream*)

 (setf *final* (reverse *reac*))

 (setf *falsefinal* (reverse *freac*))

 (setf *reactfinal* (reverse *reactlist*))

 (hits)

 (reacts)

 (alarms)

 (setf *hits* (- 30 *misses*))

 (setf *hitrate* (/ *hits* 30))

 (setf *alarms* (- 30 *rejects*))

 (setf *falserate* (/ *alarms* 30))

 (compute-theta)

 (compute-d)

 

;;prints to the data file of an individual participant

 

  (setf *finalpath* (merge-pathnames *basepath* (my-filename)))

  (if (probe-file *finalpath*)

      (setf *exists* t))

 

  (with-open-file (*out* *finalpath* :direction :output :if-does-not-exist :create :if-exists :append)

  (if (not *exists*)

    (progn

    (format *out* "ID")

    (format *out* "       Sess")  

   

    (do (( count 0 (+ count 1)))

            (( = count (length *final*)) (format *out* "   False"))

        (format *out* "   ~a" (concatenate 'string "Rec" (princ-to-string (+ count 1)))))

           

  (format *out*  "        Miss")

  (format *out*  "        Hits")

  (format *out*  "        Rjcts")

  (format *out*  "        AVG")

  (format *out* "         SD")

  (format *out* "         HitRt")

  (format *out* "         FlsRt")

  (format *out* "         Lamda")

  (format *out* "         D")

 

  (do (( count 0 (+ count 1)))

      (( = count (length *falsefinal*)))

    (format *out* "       ~a" (concatenate 'string "Frc" (princ-to-string (+ count 1)))))

 

  (format *out* "         FAVG")

  (format *out* "         FSD")

 

 (do (( count 0 (+ count 1)))

      (( = count (length *reactfinal*)))

    (format *out* "       ~a" (concatenate 'string "sRe" (princ-to-string (+ count 1)))))

 

  (format *out* "         RAVG")

  (format *out* "         RSD")

  (format *out* "~%~730~")))

  (format *out* "~%~a" *partnum*)

  (format *out* "         ~a" *sessnum*)

 

(do ((count 0 (+ count 1)))

     ((=  count (length *final*)) (format *out* "          ~a" (- 30 *rejects*)))

     (format *out* "      ~a" (nth count *final*)))

 

  (format *out* "         ~a"  *misses*)

  (format *out* "         ~a"  *hits*)

  (format *out* "         ~a"  *rejects*)

  (format *out* "         ~5f" (coerce (myavg) 'float))   

  (format *out* "         ~5f" (coerce (my-standard) 'float))      

  (format *out* "         ~5f" (coerce *hitrate* 'float))

  (format *out* "         ~5f" (coerce *falserate* 'float))

  (format *out* "         ~5f"  *theta*)

  (format *out* "         ~5f"  *d*)

 

(do ((count 0 (+ count 1)))

    (( = count (length *falsefinal*)))

  (format *out* "         ~a" (nth count *falsefinal*)))

 

  (format *out* "         ~5f"  (coerce (myavg *alarmlist*) 'float))

  (format *out* "         ~5f"  (coerce (my-standard *alarmlist*) 'float))

 

(do ((count 0 (+ count 1)))

    (( = count (length *reactfinal*)))

  (format *out* "         ~a" (nth count *reactfinal*)))

 

  (format *out* "         ~5f" (coerce (myavg *tempreclist*) 'float))

  (format *out* "         ~5f" (coerce (my-standard *tempreclist*) 'float))

 

(close *out*))

 

;;prints to the data file that stores all of the participants data.

 

 (setf *ALLDATApath* (merge-pathnames *basepath* "SignalDATA.txt"))

 (if (probe-file *ALLDATApath*)

      (setf *dataexists* t))

  (with-open-file (*data* *ALLDATApath* :direction :output :if-does-not-exist :create :if-exists :append)

  (if (not *dataexists*)

    (progn

     (format *data* "ID")

      (format *data* "    Sess")  

 

 (do (( count 0 (+ count 1)))

      (( = count (length *final*)) (format *data* "        False"))

      (format *data* "    ~a" (concatenate 'string "Rec" (princ-to-string (+ count 1)))))

 

  (format *data*  "       Miss")

  (format *data*  "       Hits")

  (format *data*  "       Rjcts")

  (format *data*  "       AVG")

  (format *data* "        SD")

  (format *data* "        HitRt")

  (format *data* "        FlsRt")

  (format *data* "        Lamda")

  (format *data* "        D")

 

  (do (( count 0 (+ count 1)))

      (( = count (length *falsefinal*)))

    (format *data* "      ~a" (concatenate 'string "Frc" (princ-to-string (+ count 1)))))

 

  (format *data* "        FAVG")

  (format *data* "        FSD")

 

  (do (( count 0 (+ count 1)))

      (( = count (length *reactfinal*)))

    (format *data* "      ~a" (concatenate 'string "sRe" (princ-to-string (+ count 1)))))

 

  (format *data* "        RAVG")

  (format *data* "        RSD")))

  (format *data* "~%~a" *partnum*)

  (format *data* "        ~a" *sessnum*)

 

  (do ((count 0 (+ count 1)))

     ((=  count (length *final*)) (format *data* "         ~a" (- 30 *rejects*)))

     (format *data* "     ~a" (nth count *final*)))

 

  (format *data* "        ~a"  *misses*)

  (format *data* "        ~a"  *hits*)

  (format *data* "        ~a"  *rejects*)

  (format *data* "        ~5f" (coerce (myavg) 'float))   

  (format *data* "        ~5f" (coerce (my-standard) 'float))      

  (format *data* "        ~5f" (coerce *hitrate* 'float))

  (format *data* "        ~5f" (coerce *falserate* 'float))

  (format *data* "        ~5f"  *theta*)

  (format *data* "        ~5f"  *d*)

 

(do ((count 0 (+ count 1)))

    (( = count (length *falsefinal*)))

  (format *data* "        ~a" (nth count *falsefinal*)))

 

  (format *data* "        ~5f"  (coerce (myavg *alarmlist*) 'float))

  (format *data* "        ~5f"  (coerce (my-standard *alarmlist*) 'float))

 

(do ((count 0 (+ count 1)))

    (( = count (length *reactfinal*)))

  (format *data* "        ~a" (nth count *reactfinal*)))

 

  (format *data* "        ~5f" (coerce (myavg *tempreclist*) 'float))

  (format *data* "        ~5f" (coerce (my-standard *tempreclist*) 'float))

 

(close *data*))

(sleep 5)

(exit))

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; V. Intiate the Experiment

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

#-:debug (start)