I am trying to extract time series data from BRIK/HEAD files one of which contains raw data and another which contains a fit for the data. I have no issues loading in the files into MATLAB using BrikLoad; they load in successfully as 4D doubles. My issue is being able to take these 4D doubles and 1. apply an 85x85x85 mask to them, then 2. extract the time series data from the file and then save it as a .mat file. In sections of code written by one of my collaborators he was able to turn these 4D doubles into 85^3 when dealing with files containing beta values. He did this in code written as:
but unfortunately this method does not work with the files containing the fit and raw data since the BRICK_LABS is different and contain no ‘avg_effect#0_Coef’. Is there a simple method that I am overlooking to easily extract the time series data and apply a 85^3 mask to it or is it a more in depth process?
Can you use the regular, ol’ AFNI programs for this: 3dROIstats, 3dmaskave, 3dNetCorr etc.? That is, run these commands on the terminal, like with the system() functionality in Matlab, or just in the terminal directly? That strikes me as easier, but there are several AFNI programs for making/applying masks and averaging time series, etc. I am not sure about Matlab functionality, but if you provide more details about the files you have and what you want to do exactly with them, I can probably help out with AFNI commands.
Hello, thanks for your response, your suggestions helped! We have a few more questions so here is a more in depth explanation of what our original issue was what we decided to do based off of your suggestions.
“We are trying to compare the raw fmri data for 6 runs (about 1400 TRs) of multi echo multiband data, averaged over the dorsal ACC region, to the fitted data generated from afni_proc. We thought the simplest thing to do would be to take our output fitts file, use 3dmaskave afni function to generate the average over the dorsal ACC for all 1400 TRs, use the same function on our residuals file, load it all into matlab and add the residuals to the fits to give us the ‘raw’ then plot this reconstructed ‘raw’ on top of the ‘fits’ to see how good the fits are in AFNI. Is this method valid or are we missing something? We tried to use the pb.04.combine data file in afni originally to look at ‘raw’ data, but it was scaled to extremely different values and we couldn’t figure out how to get everything on the same scale. If you have tips, let us know.”
Yes, the fitts plus the errts should equal the input to 3dDeconvolve, and the input to 3dDeconvolve is probably that scaled data (which has been concatenated into the all_runs dataset). So running 3dmaskave on the fitts, errts and all_runs datasets should satisfy fitt+errts=all_runs.
Of course, you can also test by showing the fitts plot on top of the all_runs plot directly in the afni GUI. Set Underlay to all_runs, and use the “Dataset #N” plugin to show both at once in a Graph window.
For an example of this, see the Start to Finish 15 (of 17) video, and jump to time 17:25, say (it will take a minute or 2 to get to the actual plot).
rick
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.