Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
yzeyang

Junior Member
Registered:
Posts: 14
Reply with quote  #1 
Hi Jaewon,

In the "Signal type" menu, does "General Input" mean analog input? If so, are there objects or examples on how they are handled in the runtime script?

Another questions is regarding recording of analog inputs. The ML daq toolbox does provide several examples on analog inputs. I was wondering if there are existing solutions for recording analog/digital inputs with ML.

Many thanks in advance!

 
0
Jaewon

Administrator
Registered:
Posts: 933
Reply with quote  #2 
Yes, "General Input"s are analog input. The menu won't show you any other option. They are recorded and saved automatically when a trial starts and stops. You don't need to do anything for them.

If you need to access the data during trials, see the get_analog_data function.
ftp://helix.nih.gov/lsn/monkeylogic/ML2_doc/runtimefunctions.html#get_analog_data

If you script with the scene framework, digital inputs will be recorded based on a software timer at ~1 kHz. Otherwise, you can feed the digital inputs to analog channels and record them as General Input.
0
yzeyang

Junior Member
Registered:
Posts: 14
Reply with quote  #3 
Hi Jaewon,

Where will  "General Input" data be saved? Would they be recorded according to the "AI sample rate"?

I understand the workaround to feed digtal inputs to analog channels. Would you elaborate on how digital inputs are recorded, when you said "based on a software timer at ~1 kHz"?  Is a specific adapter/signal type required or is the saving synchronized with trial start/end? Similarly to my questions regarding analog inputs, where will the digital inputs be saved (if not treated as analog).

Many thanks
0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #4 
All trial data, including "General Input" data or digital input data, will be saved as either the .bhv2 (recommended, and set as default), .h5 or .mat file. They can later be read and analyzed with mlread() into matlab.
0
Jaewon

Administrator
Registered:
Posts: 933
Reply with quote  #5 
As for the location of the saved data (both analog and digital), read the data file with mlread() and see the "AnalogData" field. Internally ML always samples at 1 kHz, but the data will be saved at the rate you choose on the menu.

Most of cheap DAQ boards do not support digital input sampling, so ML samples digital signals based on the OS timer. It is not as precise as a hardware clock, but not bad. All you need to do is just to wire the input signals to the DAQ board and assign them on the I/O menu.
0
yzeyang

Junior Member
Registered:
Posts: 14
Reply with quote  #6 
Hi Jaewon and Edward,

Your answers are really helpful! Really appreciate your help.

Here is what I got it. Analog data were saved by default as long as assigned in signal types. And it seems that feeding digital signal to analog channel is more reliable workaround.

One additional question, if a "duration" of 1000 msec is specified for "get_analog_data()" at time t=t0, which segment of data is fetched: [t0-1000:t0] or [t0:t0+1000]?

Thanks



0
Jaewon

Administrator
Registered:
Posts: 933
Reply with quote  #7 
Of course, the former. You can't fetch the data that is not acquired yet.
0
dbarack

Junior Member
Registered:
Posts: 26
Reply with quote  #8 
I am trying to save signals from General Input 1 assigned to AnalogInput Channel 2. When I run the I/O test, I can see the signal fine, but it is not saving to AnalogData.General.Gen1. The field AnalogData.General.Gen1 is empty. Besides assigning the input to that channel, is there anything else I need to do? I understand it is supposed to save automatically, but I am not seeing the data. Any thoughts?
0
Jaewon

Administrator
Registered:
Posts: 933
Reply with quote  #9 
Did you run the task in the simulation mode, by any chance?
0
dbarack

Junior Member
Registered:
Posts: 26
Reply with quote  #10 
I was not running in simulation mode.
However, it is saving now. I don't know why it was not saving before. But, here is the change I made:
I wondered if the data might still be in ML somewhere, even though it was not saving while assigned to Gen1. So at the end of each trial I made a get_analog_data call to Gen1, assigned the output to a variable, and saved it under UserVars. When I checked my output file after the run, I had the data saved under my custom var in UserVars, AND all of a sudden I saw that Gen1 had saved it as well.
Very strange. But it's working now... Later today when I go in to do more testing, I will try removing the get_analog_data call and see if the AI is still being saved under Gen1.
0
Jaewon

Administrator
Registered:
Posts: 933
Reply with quote  #11 
You had better think about what you did wrong in your last try. It is simply impossible in NIMH ML that input is available during the I/O test but not during the task. All the changes you made are irrelevant.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.