Mapping image files from MWorks to BrainIO

Hi Chris,

I’m automating the process by which we translate spike times to PSTH and package them as BrainIO Data Assemblies. I need to label each stimulus presentation event with the stimulus ID of the image file within the associated BrainIO Stimulus Set. I’ve already got a mapping from presentation event to “stimulus_presented” from the .mwk2 file, so all I need to figure out now is how to map from “stimulus_presented” in the .mwk2 to “stimulus_id” in the BrainIO Stimulus Set.

I’m able to use the mwel Python package from the MWorks repo to parse a .mwel file and get an AST, so that’s convenient.

I’m looking at a few example experiments, trying to write something that will work on any of them. In the Oasis900 experiment, I’ve found the “stimulus_group” in the associated .mwel file. It contains a “range_replicator” which contains an “image_file” which acts as a template for the group. To get each file name, it does substitution of a variable called “RSVP_stim_counter” which is the counter defined by the range_replicator. If the counter defined by the range_replicator corresponds to stimulus_presented in the .mwk2 file, this is pretty straightforward, because the file names match the ones in the Oasis900 BrainIO Stimulus Set and that completes the mapping.

However, in the Objectome experiment, the file names used in the Stimulus Set don’t match the ones in the .mwel. So using RSVP_stim_counter doesn’t generalize.

Do you know how “stimulus_presented” in the .mwk2 file gets populated? Is that done by the MWorks application, or does it come from user input?

Thanks,

JJPR

Hi Jon,

There’s no built-in variable named “stimulus_presented”. That must be defined by the particular experiment(s) you’re looking at, so I can’t say when and how it’s being set.

The usual way to get info about stimulus presentations is to extract the variable #stimDisplayUpdate from the event file. The value of that variable is a list of dictionaries, where each dictionary contains the tag and properties of a stimulus that was on screen during that display update. For image file stimuli, the dictionary contains a filename key, whose value is the full path of the image file loaded by MWorks, and a file_hash key, whose value is the SHA-1 hash of the image file (more info). If the filenames used when running the experiment don’t match those in your database, the file hash should provide a way to create a mapping between the two.

Does that answer your question? Apologies if I misunderstood: This is my first day back at work after three weeks of vacation, and my brain isn’t back up to speed yet :slight_smile:

Cheers,
Chris

OMG that is fantastic! I’ve got code for extracting info from MWorks .mwk2 files here:

https://github.com/dicarlolab/brainio-dicarlo/blob/main/brainio_dicarlo/pipeline/utils/mworks.py

It’s mostly based on Sachi’s code and the example code you provided in the doc. It includes the slightly modified version of the MWK2Reader class I told you about. Knowing this, I can extract much more information to attach as metadata on our packaged data assemblies. Having the SHA-1 alone will make things feasible that haven’t been.

Thanks!

JJPR

Thanks, I’ll check it out!

Chris