Welcome! Log In Create A New Profile


Accessing data from previous trials

Posted by holmescharles 
Accessing data from previous trials
April 25, 2024 01:42PM
What is the recommended way to access the history of variables saved with bhv_variable? For now, we are using TrialRecord.User.VariableName in parallel to save values from trial to trial (appending to a vector) but this feels like it should be redundant. Any insight would be helpful, thanks!
Re: Accessing data from previous trials
April 25, 2024 09:48PM
I suggest thinking through whether what you feel redundant is really redundant.
Re: Accessing data from previous trials
April 26, 2024 02:37PM
Hopefully this is more clear:

So we are determining which limb a monk reaches. It can be right or left. We want to save this value for each trial so it will be in the output data file, but we ALSO want to access those values for previous trials during the experiment so we can update the task based on which limb is being used more often.

We are doing two things at the end of the timing file:

1. Saving the value with bhv_variable so it will end up in the data file.
2. Append the value to a vector in TrialRecord.User so we can access its value in the following trials.

Again, this feels like its redundant because both methods "record" the information. E.g., perhaps I am unaware of a way to access the data saved with bhv_variable in a later trials. Or perhaps there is a way to ultimately record the data in TrialRecord.User in the data file (from other forum posts, I think this is not the case).

Let me know if you think I should be thinking through anything else. Thanks.
Re: Accessing data from previous trials
April 26, 2024 05:48PM
One is to store a value to a file and the other is to assign a value to a variable. How are they the same? See the two lines of code below. Are they doing a redundant function?
a = 1;                 % assign to a variable
save('test.mat','a');  % store to a file

The value stored to the file is not accessible through the variable. Although the values kept in the file and the variable are the same after the above code, it is just because the variable was used in such a way. The variable can be overwritten anytime and there is nothing that ties the value in the variable to the value stored in the file.

I already gave you an answer in the other post that there is no way to magically access the history of variable changes. You should do something for it, either appending the new value to a vector or recreating such a vector by reading back the saved values from the file.
Re: Accessing data from previous trials
April 29, 2024 08:00PM
Apologies, I had forgotten I posted that follow up question. If I had remembered and seen the answer I would not have made this post to begin with.

Also sorry if I hurt your feelings using the word "redundant".
Re: Accessing data from previous trials
April 29, 2024 10:38PM
No apology is needed. You were thinking the job that you were supposed to do was redundant, so I just tried to make you understand it.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.