PhD research problem

Hello, This is the first time I have posted on here and I have never used the Arduino platform before, so please be patient with me.

As I mentioned in the title, I have a problem with one part of my PhD research methodology. To be more precise, I need to be able to record the response time and hit rate of participants to a stimulus. Ideally, I would like to be able to preset a system to flash a single LED for a variable order (LED flash should miss flashes and not be uniform), and the participants would press a micro-switch to confirm the flash. The system would then give data back for response time in milliseconds and hit rate. If both values are not possible, the response time is the most crucial because the hit rate could be manually recorded, when the response time is being noted; however, if it were possible to have all the data for all the response times and total hit rate that would be preferred.

I understand. That Arduino is supposed to be a platform for hobbyists and this request will likely go against the grain of many of you; however, as simple as the aforementioned task seems, there is no off the shelf system to do this task, and this is just one piece of a large puzzle that I have to complete, so your help on this matter will be gratefully appreciated.

Shindzz.

What you want to do is quite feasible with the Arduino platform. If I understand correctly you need to do the following:
1 Wait for a random time
2 Flash a LED
3 Start a timer
4 Wait for a button press
5 Stop the timer
6 Timer value is the time you want.

I guess if the button is not pressed in a certain time then you record a miss?

Hi, I have seen the various reaction time variants on YouTube etc. However, the system that I require will be administered by the researcher and the participants will only press a switch when they see the light. As well as that to maintain reliability in research methods, the time between light flashes would not be random and in fact be a preset pattern that could be manipulated between test evaluations, identically between participants.

I'm sure that it is possible, but has anyone done it before and able to let me know how? If you have any ideas of how to go about this and what I would have to buy, it would be a great help.

Ps. The participants will be performing other tasks as well and not able to see the LCD display or interact with the researcher. Therefore the system cannot be visible to the participants and can only be administered by the researcher, out of their view.

To start with you'll want to have two Interrupts, one that changes with the flashing light and one for the switch. The interrupt service routine (ISR) for each only needs to save the time the ISR is triggered to a specific variable, and either set a flag or increment a counter for the number of times that particular ISR has been triggered. After that you can have functions to compare times to calculate response time, similar to this sketch. The ISR trigger flags/counters will allow you do things like calculate hit rate.

In terms of Random, but not Random, you could use a Linear Feedback Shift Register (or at least a software implementation of one).

Here is one I used in the past

//Linear Feedback Shift Register
unsigned int shuffler(unsigned int lfsr = 0);
unsigned int shuffler(unsigned int lfsr){
  static unsigned int oldlfsr = 1;
  if(!lfsr){
    lfsr = oldlfsr;
  }
  /* taps: 16 14 13 11; characteristic polynomial: x^16 + x^14 + x^13 + x^11 + 1 */
  boolean newbit  = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 5)) & 1;
  lfsr =  (lfsr >> 1) | (newbit << 15);
  oldlfsr = lfsr;
  return lfsr;
}

Basically, it gives the appearance of randomly generating a number between 1 and 65535 inclusive, but in fact there is a predictable pattern.

What you do is at the beginning you call the function with a starting point, e.g.

unsigned int number = shuffler(123); //start sequence with 123

Then, when you want to generate the next psuedo random number, you just call it with:

number = shuffler(); //get next in the sequence

The sequence generated will always be the same for a given start number. So if you always start with 123, you will always get the same sequence of numbers.
If you want a difference sequence, you just start with a different number.

What you could then do is have a constant array of different times, and use the generated number as an index to select which time to use. It is possible with a simple modification to reduce the output range of the lfsr, so you wouldn't need 65535 different times. For example:

byte number = (shuffler() - 1) % 256; //get next in the sequence
//but limit to a range of 0-255. This still keeps a constant pattern

For your purposes I suggest that you do not rely on a Psuedo-random number generation routine which could bias your study results. I have developed a library for the Arduino, which uses the only method so far that tests out as truly random with the basic components. It should produce a fast enough stream of entropy for your needs, but if you need faster entropy generation, I also have some other links/information at the google code site in my signature block.

Feel free to contact me with specific questions if you have any trouble using the library.

P.S. the test results, so far, are available for the random generation library and may be useful to you purposes as well.

Shindzz:
As well as that to maintain reliability in research methods, the time between light flashes would not be random and in fact be a preset pattern that could be manipulated between test evaluations, identically between participants.

In order to use a predefined pattern, you will need multiple tests with the same subject with different underlying patterns. There has been ample evidence of studies using that methodology where the 'pattern' used affected the results to the point that entirely different results are produced by changing the pattern. That is why I suggest that no pattern be used, but rather a truly random (and hence unpredictable by either subject or researcher) source be used.

Thanks for all your help, you must understand that I am turning to this technology because of need, due to the lack of suitable equipment. However, the knowledge, terminology etc., which is perceived as commonly known is foreign to me. Therefore, it will take me a while to learn these skills, before I can truly understand your advice. Hence, why I asked you to be patient.

With respect to the post of 'Wanderson'. I take what you said about biasing the study on board; and, truly random is fine, so long as the flashes sum up to the same number for each test evaluation (approximately half a dozen minutes), and are random but evenly distributed (paradoxical notion), to avoid all of the flashes randomly occurring in the first minute, which would be possible if the sequence was truly random. This is why I wished to develop a balanced sequence in an ANOVA repeated measures design.

Anyway, any suggestions are useful, because even though I may not fully understand them now, by the time I buy the hardware and start on this, your assistance will be invaluable.

One way to ensure that each test run equals the same total time (less the variance caused by reaction times) is to have a fixed array of intervals and then randomly pull one interval from the array at a time ensuring that that interval is then not reused for that test.

Here is a bit of psuedocode to illustrate

long intervals[] = {1,4,2,5,3,7,...}

for (indx in length(intervals[]))
{
   index = Entropy.random(length(intervals[])
   while (intervals[index] <= 0)
     index = Entropy.random(length(intervals[])
   interval = intervals[index]
   intervals[index] = 0 ; Remove from bin so it will only be used once
   delay_ms(interval);
   ; Do other processing for test with this delay ...
}

I'm sure that it is possible, but has anyone done it before and able to let me know how? If you have any ideas of how to go about this and what I would have to buy, it would be a great help.

The individual elements of this are very easy to do - lighting a LED and reading a switch. What you need to buy depends on how you want to present this user interface to the test subject. Here is the bare bones:

  • Arduino board (an Uno would be more than enough)
  • LED of your preferred colour and a resistor to suit the LED
  • A switch and some components to debounce it (the choice for how it is debounced will have a few components associated with it). Note that the time to debounce the switch needs to be taken into account as it will extend the reaction time that you are measuring.
  • A 5V power supply for the gear. This could be powered by a USB cable but better to supply a separate supply. Easy to build from components and also readily available as a standard board/box.
  • Something to build your circuits on. This could be a prototyping board or just a prototyping shield. In your case it may make sense to get one of the I/O shields that has connectors to avoif having to solder stuff up and allow a more modular design.
  • Boxes, panels, wires, etc to suit the installation

Software will be the smarts that drives this. You could also add an LCD and will you need a link back to a computer to collect the result?

I am sure others will chip in with their own ideas on this. There are a lot of choices and what you need really depends on how you see all this coming together as a project.

Thanks again everyone. You have all given me a lot to consider. After I have had a chance to digest everything and have a go at putting this system together, I will likely be back for some follow-up support. See you then.

Please check your private message.

best regard
Bambang Siswoyo
http:/bsiswoyo.lecture.ub.ac.id

Just a small remark: if you really have to go for millisecond resolution you should be aware that the performance of the switch can have a significant impact on your results. The required force, the movement to actually actuate it and the bounce may all have impact on your measurements. So you should be somewhat careful with your system implementation. It is not sufficient to just focus on the software alone.

Dear Udo Klein
you are right, it can not be simplified only pay attention to the software in the microcontroller. hardware architecture is crucial once the desired performance. so if accuracy is up to the millisecond, the hardware design is crucial. as well as the mechanical construction of the push button of the participants is crucial, too.