expe.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # main imports
  2. import numpy as np
  3. import os
  4. import time
  5. from datetime import datetime
  6. import re
  7. # image processing imports
  8. from .processing import crop_images
  9. # expe imports
  10. from .quest_plus import QuestPlus
  11. # load `config` variables
  12. from .. import config as cfg
  13. # PARAMETERS of the psychometric function
  14. chance_level = 0 #e.g. chance_level should be 0.5 for 2AFC (Two-alternative forced choice) procedure
  15. threshold_prob = 1.-(1.-chance_level)/2.0 #the probability level at the threshold
  16. # quest_plus.py comes also with psychometric.py wich includes the definition of the weibull and weibull_db function
  17. # here I define the logistic function using the same template that works with the quest_plus implementation
  18. def logistic(x, params, corr_at_thresh=threshold_prob, chance_level=chance_level):
  19. # unpack params
  20. if len(params) == 3:
  21. THRESHOLD, SLOPE, lapse = params
  22. else:
  23. THRESHOLD, SLOPE = params
  24. lapse = 0.
  25. b = 4 * SLOPE
  26. a = -b * THRESHOLD
  27. return chance_level + (1 - lapse - chance_level) / (1 + np.exp(-(a + b*x)))
  28. # that's a wrapper function to specify wich psychometric function one we want to use for the QUEST procedure
  29. def psychometric_fun( x , params ):
  30. return logistic(x , params , corr_at_thresh=threshold_prob, chance_level=chance_level)