-
Notifications
You must be signed in to change notification settings - Fork 48
Collect Custom Data
In general this is not necessary, most of the time the data you need to output should be stored in the trial.result
object, or captured with a tracker component. However, in some cases you may need to save arbitrary data associated with a session or a trial. For example, data from a survey, or any other form of data collection.
You can use the the Save*
methods for your Session or Trial. These methods automatically handle the data, and store it in an appropriate location. In the case of trial-level data, using trial.Save*
methods, a reference to the output data location will also be saved in the trial_results
data output.
For example, storing the text abcdefg
to a file called my_text
for the current trial:
session.CurrentTrial.SaveText("abcdefg", "my_text");
Or, saving the text for the entire session (not marked with current trial number):
session.SaveText("abcdefg", "my_text");
The methods you can use on Session
or Trial
are:
trial/session.SaveText(string, "my_text")
-
trial/session.SaveDataTable(UXFDataTable, "my_data_table")
(To do this you will need to construct your own UXFDataTable object - see below for an example) -
trial/session.HandleJSONSerializableObject(List<object>, "my_json_like_object")
(Saves a list of dictionaries, string, float, int, or bool) -
trial/session.HandleJSONSerializableObject(Dictionary<string, object>, "my_json_like_object")
(Saves dictionary with string keys, and string, float, int, bool, or dictionaries values) -
trial/session.SaveDataTable(byte[], "my_bytes.wav")
(Saves some raw bytes, I use this for recording microphone data as a WAV file).
UXF has no direct support for surveys, since it would be difficult to create a solution that allows for Desktop + VR use, also supporting a range of VR systems (OpenXR, SteamVR, Oculus, etc).
You should be able to use VRQuestionnaireToolkit with no compatibility issues, but it will not save data directly within UXF's data handler system.
If you want to create your own data survey system, and have them saves as CSVs or in Databases etc from within UXF's Data Handler system, you can do something like this:
// have this method run after the final trial, but before the session ends
public void SaveSurvey()
{
// ~ example show questions and get responses via the UI ~
string exampleQuestion1 = "How difficult was the task";
string exampleResponse1 = "Easy!";
string exampleQuestion2 = "How are you feeling today on a scale of 1-7";
int exampleResponse2 = 6;
// ~ example show questions and get responses via the UI ~
// questions are headers
var headers = new string[]{ exampleQuestion1, exampleQuestion2 };
var surveyData = new UXF.UXFDataTable(headers);
// one row for the response (only 1 participant here!)
var surveyResponse = new UXF.UXFDataRow();
surveyResponse.Add((exampleQuestion1, exampleResponse1));
surveyResponse.Add((exampleQuestion2, exampleResponse2));
surveyData.AddCompleteRow(surveyResponse);
// save output
UXF.Session.instance.SaveDataTable(surveyData, "survey");
}
This will save a data file survey.csv
in the session/other
directory.
After finishing data collection, you can bulk read all these files into your analysis software and join them row-wise.
๐ง Core topics
- ๐ Background
- โจ UXF 2.0
- โ๏ธ Compatibility
- ๐ถ๏ธ Oculus Quest Setup
- ๐ญ Concepts
- ๐ ๏ธ Get started
- ๐ Examples
- ๐ฅ๏ธ Built-in UI
- ๐ Session generation
- โฐ Events
- ๐ Data collection
- โ๏ธ Collect custom data
- ๐ Custom Data Handler
- ๐ Remote Data Collection
- ๐๏ธ WebGL DynamoDB setup
- ๐ Processing DynamoDB CSVs
- ๐ซ HTTP Post Setup
- ๐ง Settings system
- ๐๐ฝ Tracker system
- ๐ Logging system
โ ๏ธ Common issues- ๐ผ๏ธ Multi-scene experiments
- ๐บ Videos
- ๐จโ๐ Full written tutorial
- ๐ฆ Asset links
- ๐จโ๐ซ Unity tutorial links
- ๐ Useful code snippets
- ๐ก Programming ideas
- ๐งฎ Example R processing