has anyone tried to use the RSA toolbox on BIDS formatted data? I’ve been going through the Recipe_fMRI.m script, trying to prepare my data (from SPM) and my masks for the analysis. In the third line of that script (fullBrainVols = rsa.fmri.fMRIDataPreparation('SPM', userOptions);), I’m getting the following error:
Reading beta volumes for subject number 1 of 26: sub-101........................Invalid field name: 'sub-101'.
Error in rsa.fmri.fMRIDataPreparation (line 134)
fullBrainVols.(thisSubject) = subjectMatrix; clear subjectMatrix;
As far as I can tell, this is due to the subject identifier including a minus sign, which is not allowed in struct field names. The same problem occurs in the next line, for preparing masks. Has anyone got any idea how to get around this?
I am no expert of the RSA toolbox but a quick look at the help of rsa.fmri.fMRIDataPreparation seems to suggest that it takes beta images as “input” or that it will figure out which beta images to use from the SPM.mat and the condition label name you give it.
So it seems that you need to run a subject level GLM first so the BIDS format is not exactly “relevant”.
No RSA-TB expert so I am not entirely sure about all that. Do double check that I am correct.
Hope it helps.
PS: which version the toolbox are you using because line 134 of my rsa.fmri.fMRIDataPreparation does not seem to match yours.
% [fullBrainVols =] fMRIDataPreparation(betaCorrespondence, userOptions)
% betaCorrespondence --- The array of beta filenames.
% betas(condition, session).identifier is a string which referrs
% to the filename (not including path) of the SPM beta image.
% Alternatively, this can be the string 'SPM', in which case the
% SPM metadata will be used to infer this information, provided
% that userOptions.conditionLabels is set, and the condition
% labels are the same as those used in SPM.
It’s been quite a while since I opened matlab or used the RSA toolbox, but I’ll try to provide some hopefully helpful comments. Hence, sorry if I’m super off.
As far as I understand, @kwiebels already conducted the GLM and is now trying to use the outcomes within the RSA toolbox (please correct me, if I’m wrong). I think both of you are right, as the RSA toolbox does not expect data to be in BIDS (nevertheless, having your data in BIDS is of course a good idea ), but is happy with the data of all participants following the same structure. @Remi-Gau is right about the functionality of rsa.fmri.fMRIDataPreparation and also points to the importance of specific versions.
However, @kwiebels correctly identified the underlying error. I remember also having some problems working with BIDS data in matlab. Back then I just used a quick and dirty fix, that is replacing the - with a _ when working with identifiers. Try add something along the following lines at the beginning of your for loop: thisSubject = strrep(thisSubjet,'-','_') .
I know, it’s not super neat, but it should work. And as everything goes into the derivatives folder it should not create problems for subsequent analyses (maybe include a short .json to keep track of these changes).
HTH, best, Peer
P.S.: I’m pretty sure you are aware of this, but just in case: applying multivariate noise normalization before computing your RDMs might be a good idea. The necessary code should also be in the RSA toolbox within the function noiseNormalizeBeta. Sorry, if you already did that or don’t want to do it.
@Remi-Gau: Thanks for your reply and for pointing out the version discrepancy. I downloaded the toolbox from the MRCCBU website a few days ago, so I had assumed it’s the latest version, but the latest version on github has a few differences, including in fMRIDataPreparation.m. Is it generally advisable to download the latest github version? As @PeerHerholz already said, I already conducted the GLM and want to use the resulting betas, so that particular point wasn’t the issue. Sorry if I didn’t make that clear enough.
@PeerHerholz: Thanks for your detailed explanation. The strrep worked. I added this in all relevant scripts now (perhaps not the smartest move, but it seems to work alright now). Thanks also for mentioning the noiseNormalizeBeta. I am pretty new to RSA, so I wasn’t aware of that. Is the idea to run this on the SPM models, and then conduct the RSA analysis on the noise-normalised betas (u_hat)?
I might be wrong but I think that the best is to either use one the tagged / realeased version from github (or zenodo or any other place where the toolbox might be archived). This makes it easier to cite in papers in the end and is better for later reproducibility.
What I used to do before which I think is suboptimal (someone correct me if I am wrong) is to just download the latest version of the master branch (or clone the repo): the problem is that this might hinder later reproduibility if you do not cite which commit of the master branch* you were using for your work.
*Assuming that the master branch is ahead of the latest version tag which is often the case.
Actually the MVNN of the RSA is one the few things I have used it for and that description sounds pretty much liek the right way to go about it to me.