Trouble running `process_import_data_event` from Python

Hi Raymundo,

Lately, I have been having problems with the function process_import_data_event.

When I run it in MATLAB it works just fine; the folders are generated and I obtain the sFilesEpochs1 struct. In Python, however, even though it generates the folders the output file is empty ([ ])
Is there a reason behind this issue?

Thank you!

Hi @claudiarodgadeam, I move this question to its own thread as the problem is not with Brainstorm source code, but with the way Python interacts with it.

It is not possible for me to give you an answer with this little information. Please provide relevant information. For example which Python code are you using?

Hi Raymundo,

Thanks for your message.

Below is the Python code I am using to import events via Brainstorm using the MATLAB engine:

imported_spikes = self.eng.bst_process(
    'CallProcess', 'process_import_data_event',
    output_eeg, [],
    'subjectname', subject_name,
    'condition',   '',
    'eventname',   eventname_str,
    'timewindow',  matlab.double([]),
    'epochtime',   matlab.double([-0.300, 0.300]),
    'createcond',  1,   # Create a new folder for each matching event
    'ignoreshort', 1,
    'usectfcomp',  1,
    'usessp',      1,
    'freq',        [],
    'baseline',    matlab.double([-0.1, -0.0017]),
    nargout=1)

Here, output_eeg is the output file from process_import_data_raw, and eventname_str is a string containing the event names separated by commas (e.g., "f4, c4").

The function correctly creates the folders corresponding to the different event time instants in Brainstorm, but the returned variable imported_spikes is empty ([]).

After that, my intention is to compute the average of the imported events using:

spikesAvg = self.eng.bst_process(
    'CallProcess', 'process_average',
    imported_spikes, [],
    'avgtype',    3,
    'avg_func',   1,
    'weighted',   0,
    'keepevents', 0,
    nargout=1)

However, since imported_spikes is empty, no average is generated.

So my main issue is that although process_import_data_event appears to run correctly and creates the epochs in Brainstorm, it does not return any output file to Python.

Thank you!