BioMotionLab / TUX

A framework for experiments in Unity and VR
https://biomotionlab.github.io/TUX/
Other
29 stars 4 forks source link

How to log custom continuous data only when events are called? #64

Closed A-Ivan closed 1 year ago

A-Ivan commented 2 years ago

I was looking at the documentation on logging continuous data and I have some questions about Recorder Resolution and custom data recording.

  1. Instead of recording every x frames I would like to record data (I believe this is what you call a Snapshot) only when a specific event occurs. To do this, would I then create a custom Snapshot script, which would contain the data types I would like to record, and a custom Recorder script to call a function (i.e. via an event) which has the following information?
CustomSnapshot snapshot = recordableComponent.CreateSnapShot(variable1, variable2, ... , variableN);
recordingRecord.AddSnapShot(snapshot);

Where "variable1, variable2, ... , variableN" could be different kinds of variables (string, int, float, Vector3, etc.).

  1. Would this then save these different variable types? Would it save it in this order?

  2. How do I set the header string that would appear for each of these variables in the data (i.e. in the output csv file)?

Thank you.

AdamBebko commented 2 years ago

From what I gather you’re trying to write some data a few times per trial to an output file. One option is to make a dependent variable that’s just a string, and write to that as a list of data ie {value1, value2, value3, value4} at the end of the trial.

If you’d like more structure to your data, but still are only writing a few times per trial, I would recommend writing your own code to write to a CSV file. It’s not super difficult and would probably suit your needs more.

The continuous recorder is more optimized for speed and file size, so it becomes a bit harder to use than simply writing to your own file. I didn’t really build it with calling record events manually. One possibility is to keep “shouldRecord” off, turn it on one frame, then turn it off again. Or you could extend it to your needs. If you think others could benefit maybe a pull request would be good.

Dr. Adam O. Bebko, Ph.D. @.*** adambebko.com

On Mar 18, 2022, at 3:27 PM, Ivan Aguilar @.***> wrote:

I was looking at the documentation https://biomotionlab.github.io/TUX/docs/ContinuousData on logging continuous data and I have some questions about Recorder Resolution and custom data recording.

Instead of recording every x frames I would like to record data (I believe this is what you call a Snapshot) only when a specific event occurs. To do this, would I then create a custom Snapshot script, which would contain the data types I would like to record, and a custom Recorder script to call a function (i.e. via an event) which has the following information? CustomSnapshot snapshot = recordableComponent.CreateSnapShot(variable1, variable2, ... , variableN); recordingRecord.AddSnapShot(snapshot); Where "variable1, variable2, ... , variableN" could be different kinds of variables (string, int, float, Vector3, etc.).

Would this then save these different variable types? Would it save it in this order?

How do I set the header string that would appear for each of these variables in the data (i.e. in the output csv file)?

Thank you.

— Reply to this email directly, view it on GitHub https://github.com/BioMotionLab/TUX/issues/64, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKFU472SGZSUZZK5QVBBNDVATKJRANCNFSM5RCW3OTQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.

A-Ivan commented 2 years ago

Hi Adam,

I believe I will have to write to this file around 100 times per trial.

Thanks for the idea of keeping “shouldRecord” off and turning it on when recording, that may work.

How is the header information for these variables set on the output file? I'll probably have to change that somewhere, maybe on the custom snapshot script?

Thank you. Ivan

AdamBebko commented 2 years ago

Yes the custom snapshot requires overriding a function that supplies the header

Sent from my iPhone

On Mar 19, 2022, at 10:46 AM, Ivan Aguilar @.***> wrote:

 Hi Adam,

I believe I will have to write to this file around 100 times per trial.

Thanks for the idea of keeping “shouldRecord” off and turning it on when recording, that may work.

How is the header information for these variables set on the output file? I'll probably have to change that somewhere, maybe on the custom snapshot script?

Thank you. Ivan

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.

A-Ivan commented 2 years ago

Hi Adam,

I have a question concerning how to access the trial number, block number, trial in block number, output file name, and time elapsed in the current trial during a trial?

I'm looking to log my own continuous data and I would like to save this information with the data but I am not sure how to get this information. Not sure if I missed any information on this in the documentation but could you give me some direction?

Thank you.

AdamBebko commented 2 years ago

If I recall, the custom block script and the trial script both have access to their “Index" property.

If that doesn’t work for you. The quick and dirty solution would be to make a static class that stores two public fields: block index and trial index, and just increment them in the block and trial scripts in the premethod each time.

StaticIndexCounter.BlockIndex; StaticIndexCounter.TrialIndex;

Hope that helps! Adam

On Apr 3, 2022, at 12:23 AM, Ivan Aguilar @.***> wrote:

Hi Adam,

I have a question concerning how to access the trial number, block number, trial in block number, and the participant data during a trial?

I'm looking to log my own continuous data and I would like to save this information with the data but I am not sure how to get this information.

I tried to access the trial number data via "tutorialRunner.trialNumber" in the PreMethod() of the trial script and also tried to access the block number via "tutorialRunner.trialInBlockNumber" in the PreMethod() of the block script but they both returned 0.

I also tried to access "(string) Data["Age"]" in the trial script but wasn't able to get any data.

Not sure if I missed any information on this in the documentation but could you give me some direction?

Thank you.

— Reply to this email directly, view it on GitHub https://github.com/BioMotionLab/TUX/issues/64#issuecomment-1086773892, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKFU46WWHAX545JEI6KV7LVDEMLTANCNFSM5RCW3OTQ. You are receiving this because you commented.

A-Ivan commented 2 years ago

Hi @AdamBebko,

This helps, I will test it out, thanks.

What about access to the current task time (time elapsed so far in the current trial during a trial)?

Thank you.

AdamBebko commented 2 years ago

I don’t think that’s exposed, but it should be easy to modify or create a timer on your own using startTime = time.time and elapsed time = time.time-starttime

On Apr 4, 2022, at 2:17 PM, Ivan Aguilar @.***> wrote:

Hi @AdamBebko https://github.com/AdamBebko,

This helps, I will test it out, thanks.

What about access to the current task time (time elapsed so far in the current trial during a trial)?

Thank you.

— Reply to this email directly, view it on GitHub https://github.com/BioMotionLab/TUX/issues/64#issuecomment-1087867609, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKFU4Z76BXBXHH5Y7QONHTVDMW3NANCNFSM5RCW3OTQ. You are receiving this because you were mentioned.