carrien / free-speech

Analysis and plotting code for speech neuroimaging experiments.
MIT License
4 stars 5 forks source link

Button to change OSTs mid-experiment #25

Closed rpkarlin closed 3 years ago

rpkarlin commented 3 years ago

Some small adjustments to existing functions, and a couple of new functions to add button to experiment control screen so you can change OSTs mid-experiment if necessary.

Note that audapter_viewer still does not fully support mixing trials with different OST files, though I believe that functionality could be added fairly easily.

add_adjustOstButton

This function takes in h_fig and adds a button whose callback essentially creates another type of pause state. This function is not strictly necessary to add to your experiment (you don't actually need a button, but it's a nice reminder to have)

adjustOsts

This is the meaty function. It gathers the last 18 trials (or however many exist) from the temp_trial directory in expt.dataPath and creates a data_ostChanged.mat file to feed into audapter_viewer. Generates an altered pause message on the screen for the participant (does not tell them to press spacebar). Waits for you to finish up with audapter_viewer and then you unpause. This function feeds the new OST values into Audapter (another current point of compatibility for only using one OST file)

get_ost

Not a new function, but now has a new potential argument for eventNum, 'full'. This will just give you back ALL the OST information (note that it doesn't give it back to you like in the OST file itself, but rather in form:

OST HEURISTIC_TO_GET_TO_OST PARAM1 PARAM2 PARAM3

This is the same format as you get back if you request a single line.

setup_exptFigs

Simply an aesthetic change to make the window a little bigger so the button fits.

run_measureFormants_audapter

I have simply edited this function to include the elements for adding this feature to your experiments (this can be reverted if preferred, as there is no real reason to make adjustments to OSTs during measureFormants). There is one essential addition (currently line 97):

if get_pause_state(h_fig,'a') % ***** pull request. pause for adjusting OSTs
            adjustOsts(expt, h_fig);
end

Aesthetic addition, i.e. adds button, but does not actually matter as you can just hit the "a" key, currently line 78:

adjustButton = add_adjustOstButton(h_fig); % ****** pull request

Addition for having detail at the trial level for what the OST settings were, but audapter_viewer should be compatible with data that is missing this line as well (currently line 132). I also believe there are not saving problems due to inconsistent fields if you omit the data.bChangeOst line due to how the temp data files are collected and saved together, but I could be wrong:

% ***** in pull request for trial-specific OSTs
        subjOstParams = get_ost('experiment_helpers', 'measureFormants', 'full', 'working'); 
        data.subjOstParams = subjOstParams; 
        data.bChangeOst = 0; 
lhantzsch commented 3 years ago

Tested with simon & varMod experiments - seems to work correctly. Was able to stop in the middle to adjust OSTs, then resume. However, whenever I did this, the close(h_fig) command at the end of the run_audapter script seemed to stop working (the screen saying "Thank you! please wait" did not close automatically, but just remained on the screen). This occurred on both experiments - minor issue, but would be best if it could be resolved.

rpkarlin commented 3 years ago

Robin, this looks great! A couple things:

  • in get_ost, the masterWorking variable switch isn't currently used. Seems like it should be used in L 66 instead of a declarative 'Working.ost'.

Oops! Fixed.

  • Like Lana, I tested this on simonSingleWord, but I had no issues with the figures getting closed. Everything closed at the end of the experiment like it should have. So, not sure what the problem was there, but it might not be in the code in this PR. I should note I was testing this at home, though.

I also tried this in simonSingleWord and it closed for me. Lana said she will try again with coAdapt and let me know!

  • I tested a scenario where I changed the OSTs multiple times in a single experiment. That worked fine during the experiment. But only one data_ostChange.mat file was created, and it just overwrote the previous versions (I'm pretty sure). The real data.mat shows bChangeOst = 1 on all the appropriate rows. How much time you spend working on that might depend on what you had in mind for that file, which I don't have too many personal opinions about.

I'm not sure, either. Mostly it's just there to be loaded into audapter_viewer, and I didn't really have any ideas for future use. Someone else might, though?