Super precise timing needed

Posted By: gSet

Super precise timing needed - 09/28/10 17:04

I'm working on a game that will be used as a spatial navigation task for fMRI & MEG research, and so I need to be able to output a logfile with extremely precise timing. From what I understand, ticks are a constant 1/16 of a second, and so total_ticks/16 should be a decent measure at least providing timing information to +/- 62.5 ms. There's also a timer function for information within one frame cycle, but this won't be suitable for longer periods of time such as a five minute scan of the brain. Is there a way to achieve more accurate timing precision than working in ticks? Also, are ticks an absolute constant of 1/16 of a second that can be relied on for this?
Posted By: Quad

Re: Super precise timing needed - 09/28/10 17:16

time_frame give the duration of the last frame in ticks(1/16 secs), but it can have valuse like 0.1
if the last frame is 0.1 ticks it means it took 1/160 secs.
Posted By: gSet

Re: Super precise timing needed - 09/28/10 17:20

LOL I like your signature...

So is there a variable I can use that relies on time_frame and can act as a timer for information as to when events occured?
Posted By: Quad

Re: Super precise timing needed - 09/28/10 18:05

that is the time_frame variable itself.

try this out(copy/paste to sed and run)
Code:
#include <acknex.h>
#include <default.c>

var timePassed = 0;
var lastFrameDuration = 0;
var totalTimeFrame = 0;
var tickInMilisecs = 62.5;
FONT* arialMid ="Arial#14";
PANEL* infoPanel ={
	pos_x = 10; pos_y = 10;
	digits(0,0,"Total Frames:%.1f",arialMid,1,total_frames);
	digits(0,20,"time_frame in ticks:%.6f",arialMid,1,time_frame);
	digits(0,40,"time_frame in milisecs:%.6f",arialMid,1,lastFrameDuration);
	digits(0,60,"Total time frame in ticks:%0.6f",arialMid,1,totalTimeFrame);
	digits(0,80,"Total time passed in milisecs:%0.6f",arialMid,1,timePassed);
	digits(0,100,"Total time passed in secs:%0.6f",arialMid,0.001,timePassed);
	flags = SHOW;
}


void main(){
	fps_max = 30;//play with this
	while(1){
		totalTimeFrame += time_frame;
		lastFrameDuration = time_frame*62.5;
		timePassed += lastFrameDuration;
		wait(1);
	}	
}



Precision of the var type is debatable though it should be precise enough.
Posted By: gSet

Re: Super precise timing needed - 09/29/10 15:05

Looks like this works exactly like I need it to - Clever! I should even be able to simplify it to timePassed += time_frame*62.5. It does seem to jerk slightly when loading the next level, is this compensated for or will this delay build up as more levels are completed?

Edit: After some playing around, it looks like this delay is compensated for following hard-drive access. This is a great solution - I'll let you know how reliable the timing is after I do some testing!
Posted By: carlpa

Re: Super precise timing needed - 09/29/10 18:12

I have used GS in developing reaction time tests. The maximum accuracy with the engine is one frame-cycle. This can be as little as 5 msec but is computer and program dependent. Another serious concern for mseconds of accuracy is the time it takes for the BIOS or operating system to poll the input devices and the hardware response times of those devices. This is the reason that I try to have data be a difference between two measures.

I am very curious what technology you will use that can be near an MRI scanner.

Thanks
Posted By: gSet

Re: Super precise timing needed - 09/30/10 13:27

I'm glad you asked, actually. The study consists of two parts - First MEG, then fMRI. Not many people know what MEG is so I'll give you the quick rundown... Basically it measures the very tiny magnetic fields generated by the brain, and by looking at the patterns of the fields we can locate sources of electrical activity (i.e., clusters of firing neurons, postsynaptic responses). Because of this all magetic sources are shielded by a special and very expensive type of wall. fMRI is the opposite of course, in which your body's molecular orientation is manipulated with the use very strong magnetic fields... As a result, in both cases, only non-magnetic metals can be near the scanners. So that part's actually not too difficult - We just place a projector outside the room, with the image coming through a small waveguide. When a subject is laying in the MRI facing upward, they have a mirror which allows them to see a projector screen behind them. Then, and MRI compatible (non-magnetic) joystick which runs through another waveguide to a stimulus computer (which is also connected to the projector of course) allows them to play our game!

The way our setup works, the important thing is going to be synchronizing parralel port output to the projector's refresh rate - and we've got a system in place that will do this. The parralel port is how we record the timing of events while using MEG, and we needed the high precision for this because MEG is known for extremely high temporal resolution. fMRI on the other hand, would do just as well with a temporal resolution as low as even half a second, because we'll be instituting a block design in which subjects brain activation will be contrasted in 30 second sets.

As for the testing, I haven't gotten around to it but here's the plan - I'm essentially going to run the engine, and create a logfile which corrosponds to a high-contrast onscreen event. Simultaneously, a photo-diode will record the event on the projector screen... And any consistent difference can be hard-coded into the creation of the logfile!

So that's my rant. Sorry, I just find this stuff fascinating grin

edit: If you're interested in the details of the study, let me know and I can tell you about it.
Posted By: carlpa

Re: Super precise timing needed - 09/30/10 15:06

Thank you and very clever. I would like to know more. I am a Neurologist in clinical practice but have been in academic medicine most of my career. Can one measure Event Related Potentials with MEG. In theory anything seen with EEG should be seen with MEG. I would be willing to help if I can.

CER

Email carl.rosenberg@acmchealth.org
Posted By: gSet

Re: Super precise timing needed - 09/30/10 15:36

That's awesome - It's always great to talk to someone involved in neuroscience. Yes, MEG is very similar to EEG but without the issue of signal distortion due to the scalp, since magnetic fields aren't affected by it. Because of this ERPs are one of the primary focal points of MEG research, along with oscillatory neural activity which you also find in EEG research.

I'll keep your offer in mind, but it seems like we've got a pretty full team right now and as a result everything is under control. Our focus is the localization and lateralization of language and memory areas in presurgical epilepsy patients. The task I'm developing is designed to elicit (typically) right hippocampal activation using allocentric spatial navigation techniques... Later it will be integrated with another task I've developed which is a simple memory game intended to elicit activation related to verbal working memory. When the two are eventually combined we should have a single paradigm for localization of working memory for both language and spatial skills.

The study also incorporates MEG alongside EEG to localize epileptogenic regions that are the cause of the patients' epilepsy symptoms. Our goal is to use a combination of MEG, EEG and fMRI to produce a functional laterality index with higher sensitivity and specificity than either MEG or fMRI alone. And of course I'm excited to be incorporating video games into research, because they're a passion of mine wink
Posted By: carlpa

Re: Super precise timing needed - 10/01/10 13:45

Excellent. Please keep me in mind. I would love to see any reprints of articles. You can contact me at the above Email address. I shall look for your results in the literature. Good luck.

It is good to see more researchers using GS or other engine in neuroscience. What surprises me is that you are the first one I have discovered on this forum. I am sure there are others. Perhaps we should start a new "Topic"?
Posted By: gSet

Re: Super precise timing needed - 10/01/10 16:51

That could be a good idea - But I'm struggling to find an appropriate forum for it lol... Also, I'll make sure I let you know when everything's done and we're up for review so you can see our results!
Posted By: Quad

Re: Super precise timing needed - 10/14/10 08:54

I can hear the hammer approaching.
Posted By: carlpa

Re: Super precise timing needed - 10/14/10 15:03

Hammer?
© 2024 lite-C Forums