PTE null permutation testing

Hi,

I want to run a permutation test where, for x number of permutations, I would shuffle the phase of the timeseries of my scouts prior to computing PTE values, then compute PTEs on the phase-shuffled data, and finally store the matrix for each permutation iteration.

However, I have encountered a roadblock at the very first stage. Namely, I can't seem to find the struct field in the MN source kernel I exported to Matlab that would contain the individual ROI timeseries. I can only find the timeseries for the 270 sensors.

I find this a bit strange, as on the other hand it is possible to visualize the scout timeseries in Brainstorm, by right-clicking on the kernel and choosing the appropriate option. So, my question is: would I need to manually compute the scout timeseries data, or is this information contained somewhere I'm not seeing?

Many thanks,
Oscar

I'm not sure which "MN source kernel" you refer here, as it does not have the sensor time series.
The inversion kernel (iconResultKernel in white) among other things contains the inverse model matrix (aka kernel) which have a size [nSources, nSensors], check this link.

The time series for the Scouts (aka ROIs) are computed on the fly. If you want to extract, use the process Extract > Extract scout time series on a source file (full sources or link). The result will be a matrix file with the time series for each of the selected scouts.

Hi Raymundo,

Yes, I guess I meant the Inversion kernel in white. Your link takes me to the exact object I was talking about.

In any case, extracting the scout timeseries as suggested in your second paragraph did the trick.

So you can consider my original question resolved. Thank you very much for your quick reply!

I have a follow-up question about how to move a modified scout timeseries matrix from Matlab back into Brainstorm.

Basically, I extracted the scout timeseries following your suggestion. As you said, this gives me a matrix in Brainstorm, which I then exported into Matlab (under the name 'Mat', let's say).

I then flipped the timeseries in one of the scouts by directly altering the struct field. Namely, I do something like "fliplr(Mat.Value(4, :))", where 4 in the row axis represents the scout whose timeseries I want to flip.

The question is, which of the many functions should I use to reupload this matrix back into Brainstorm? bst_save, bst_add...? I tinkered a bit but kept getting "invalid file type" errors.

Thanks a bunch!
Oscar

Check this link: https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Export.2FImport_with_the_database_explorer

In summary

  1. Right-click > File > Export to Matlab (file to variable)
  2. Modify in Matlab
  3. Right-click > File > Import from Matlab (variable to file)

Thanks, but I want to iterate this process and so prefer using scripts for steps 1 through 3, as opposed to using the GUI.

I already wrote a line of code that does steps 1 and 2, but for step 3 I can't find the right bst_xxx or db_xxx function that would do what point and clicking does.

In the link you sent I spotted "in_bst_matrix(MatrixFile): Read a file with the type "matrix".". Could that be the one?

To automate, since you are only modifying the values, it will be simpler to use the process Pre-process > Run Matlab command selecting the option Overwrite input files:

image

And of course, you can generate an script for this process as shown in here:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Starting_a_new_script

Hi Raymundo,

I was not aware of this great feature. Thanks to this I managed to do what I needed and put it all into one script. So, you can consider this whole thread resolved.

Thanks again for your help!

Best,
Oscar